Thanks for the answer! Does the resultType="chain" approach preserve the
fieldErrors and the values the user has already typed into the form? Also,
how do you prevent the edit action from retrieving the entity from the
database in the case the validation fails?

I also thought about putting the lists into the http session instead of the
request, but I don't really like cluttering the session with such things.


On Mon, Apr 21, 2008 at 12:55 PM, Adam Hardy <
[EMAIL PROTECTED]> wrote:

> Hi Toni
>
> there are several different approaches. The one I use has an Edit action
> and a Save action. The Edit action fetches the dropdown list and puts it in
> the request and results in the form jsp.
>
> The form submits to Save and if validation fails, the Input result is
> resultType="chain" and pipes the request back to the Edit action.
>
> HTH
> Adam
>
>
> Toni Lyytikäinen on 21/04/08 10:05, wrote:
>
> > Hello,
> >
> > What is generally regarded as the best practise for populating a select
> > element in a form from database so that it works regardless of the
> > action
> > and the result from which the form is displayed?
> >
> > I've tried this:
> >
> > action configuration:
> > <action name="edit" method="edit" class="admin.Users">
> >  <result>/WEB-INF/jsp/admin/userForm.jsp</result>
> > </action>
> > <action name="save" method="save" class="admin.Users">
> >  <result type="redirect-action">
> >    <param name="actionName">list</param>
> >  </result>
> >  <result name="input">/WEB-INF/jsp/admin/userForm.jsp</result>
> > </action>
> >
> >
> > jsp page:
> > <s:form action="save">
> > <s:action name="listIntoRequest" />
> > <s:select list="#request.list" />
> > ...
> > </s:form>
> >
> > where listIntoRequest looks like this:
> >
> > public String listIntoRequest() {
> >   List<Item> list=dao.getListFromDatabase();
> >   request.setAttribute("list", list);
> >   return SUCCESS;
> > }
> >
> > but the problem is with validation. If the validation fails, and the
> > input
> > result is returned in the in the form processing page (save), then the
> > action tag never executes the method listIntoRequest (see WW-2599), and
> > the
> > form will not display correctly.
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to