On 10/21/05, R.Vijayaraghavan <[EMAIL PROTECTED]> wrote:
> struts-config.xml
>         <form-beans>
>                 <form-bean name="QueryParamsForm" type="app.QueryParamsForm"/>
>         </form-beans>
>         <action-mappings>
>                 <action path = "/QueryParams"
>                         type = "app.QueryParamsAction"
>                         name = "QueryParamsForm"
>                         validate = "false"
>                         >
>                         <forward name="nextPage" path="/QueryParams.jsp" />
>                 </action>
>         </action-mappings>
>
> ActionForm has the setter and getter methods for name, age and description.
>
> Action:
> public final class QueryParamsAction extends Action {
>
>         public ActionForward execute(ActionMapping mapping,
>                         ActionForm form1,
>                         HttpServletRequest request,
>                         HttpServletResponse response)
>                 throws Exception {
>
>                         QueryParamsForm form = (QueryParamsForm)form1;
>
>                         //String name = (String) 
> PropertyUtils.getSimpleProperty(form, "name");
>                         String name = (String) request.getParameter("name");
>                         //String age = (String) 
> PropertyUtils.getSimpleProperty(form, "age");
>                         String age = (String) request.getParameter("age");
>                         String description = (String) 
> PropertyUtils.getSimpleProperty(form,
> "description");
>
>                         out.println(name);
>                         out.println(age);
>                         out.println(description);
>
>                         return (mapping.findForward("nextPage"));
>                 }
>
> My initial query string is:
>
> http://localhost:8080/vijay/QueryParams.do?name=vijay&age=26
>
> This instantiates the ActionForm, sets age and name, comes to teh Action,
> print age and name correctly, prints description as null(as expected), goes
> to "nextPage" whcih is QueryParams.jsp. In QueryParams.jsp, I print name,
> age and assign a textbox for the atribute 'description' which when submitted
> should set description in the ActionForm. It does so. When it comes back to
> Action, description gets printed but name and age are now null.

You read name and age directly from request object, what else do you
expect? The simplest choice is to set ActionForm scope to session and
to read from ((QueryParamsForm)form1).getName()

Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to