We are having trouble understanding how to accomplish what is a very common
web application use case, using Struts.  

The problem is around pre-populating an "Update/Edit" JSP form, from data
retrieved and stored in a model bean. We are using
org.apache.struts.validator.DynaValidatorForm for the form-bean.  The
specific use case is:

1. Select an item from a list displayed on a JSP.
2. JSP calls a Struts action, which retrieves a data object based on a key
in the list, and creates a populated model bean.  Copy the model bean data
to a form-bean, for use in a Struts JSP.
3. The Struts action forwards to the Update JSP, based on the
action-mappings.
4. The Update JSP should display pre-populated values based on the model
bean data in the form-bean, using the Struts <html:text.../> tags.  If the
form is submitted and then re-displayed due to a validation error, the
pre-populated values should come from the form bean, which would now reflect
the form/request values.

We have tried a number of approaches, none of which have worked.

In #1 above, we have set the action for the List page to use the same
form-bean as the Update action, and in #2 we have used the BeanUtils methods
in the action to copy the data from the model bean to the form bean that was
created.  We have verified that the data is properly copied to the form
bean.  We have set the form-bean into the request, using the form name from
the struts-config.  However, when the action forwards control to the Update
JSP, the form-bean that we populated doesn't appear to be in the request any
longer, so the bean isn't available to the JSP.

We have also tried forwarding to another action from #2, instead of to a
JSP, thinking that this would allow the form-bean to remain in the request.
This also appears to remove the form-bean from the request, when control is
ultimately forwarded to the JSP.


This seems to be one of the most basic use cases of most applications, but
is not described in any Struts documentation I've seen.  What we want to do
is:

JSP item link -> 
action to retrieve model data (and populate form-bean) ->
JSP update form (displaying form-bean from above, populated with model data)

Any advice or solutions or best practices on this would be most appreciated.
We have spent a couple of days on this, researching the jakarta site, and
other resources and mail lists, without finding a definitive answer to this.

Thanks.



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

Reply via email to