Re: Struts reload data
От: Francis Goya Ниоткуда  
Дата: 25.01.06 08:22
Оценка:
Здравствуйте, Аноним, Вы писали:

Привет всем !
Вопрос снимаеться я сегодня ночью осилил эту проблему, результат следующий:

jsp:

  <html:form action="contentEdit.do" method="get">
                    <td width="60">
                        <html:select property="shortCodeId" >
                            <html:options collection="shortCodesc" property="id" labelProperty="shortCode"/>
                        </html:select>
                    </td>
                    <td>
                        <html:hidden property="shortCodeId"/>
                        <html:hidden property="do"value="showContent"/>
                        <html:submit value="Show">
                        </html:submit>
                    </td>
                </html:form>


Action List:

 public class ContentListAction extends Action {

    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,    HttpServletResponse response) throws RemoteException, FinderException
    {
       HttpSession session = request.getSession();
        ContentListForm contentListForm = (ContentListForm) form;
        CommonUtils commonUtils = new CommonUtils();
        commonUtils.loadData();
        session.setAttribute("shortCodesc", commonUtils.getAllShortCode());
        String str = String.valueOf(request.getSession().getAttribute("shortCodeId"));//   getParameter("shortCodeId");
        if(str==null || str.equalsIgnoreCase("null")) str = "1";
        Integer shortCodeIdInt = new Integer(str);
        contentListForm.setContents(commonUtils.getAllContentsByShortCode(shortCodeIdInt));
        return mapping.findForward("showList");
    }
}


Action Edit:


public ActionForward showContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws RemoteException, FinderException {
        HttpSession session = request.getSession();
        CommonUtils commonUtils = new CommonUtils();
        commonUtils.loadData();
        session.setAttribute("shortCodesc", commonUtils.getAllShortCode());
        String str = request.getParameter("shortCodeId");
        if (str == null) str = "1";
        Integer shortCodeId = new Integer(str);
        session.setAttribute("shortCodeId",shortCodeId);
        return mapping.findForward("showList");
    }


Всё остальное осталось таким же как и в предедущем посте.
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.