I have a jsp associated with an ActionForm. I want a parameter passed in the url become an hidden field of the actionForm.
Created May 7, 2012
Ted Husted Struts uses the ActionForm to encapsulate whatever dynamic properties your
presentation page needs. The best practice would be to make para an ActionForm
property and to link to an ActionMapping rather than directly to a JSP. If you
were to do that, then the ActionServlet would capture the parameter and make
it a property of the ActionForm (assuming there is a para property on your
ActionForm). You can then use the Struts HTML tags to render the para value.
So
(1) Create a para propery on an ActionForm.
(2) Associate that ActionForm with an ActionMapping (e.g. /form).
(3) Have the ActionMapping forward to your JSP.
(4) Link to form.do (or /do/form) rather than form.jsp.
(5) Use the standard Struts HTML tags (or Velocity directives) to render the
para field.
Alternatively, you could use the bean:parameter tag to convert the parameter into a bean and then use bean:write. But it would be better to put the para property on the ActionForm (where it belongs).
HTH, Ted
--
Ted Husted,
Struts in Action