You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Ned Seagoon <th...@hotmail.com> on 2001/04/01 20:17:12 UTC

Re: dropdown values gone after validation error

yeah, I had that problem. What I did was create my own form and
actionservlet like this

#1 define an abstract class called ActionFormEx with the following function

public void populate(ActionMapping mapping, HttpServletRequest request)

#2 add the following code into a derived actionServlet



----- Original Message -----
From: "Martin Cooper" <ma...@tumbleweed.com>
To: <st...@jakarta.apache.org>
Sent: Friday, March 30, 2001 6:07 AM
Subject: Re: dropdown values gone after validation error


> I'm guessing that your form bean has request scope. In this case, a new
bean
> will be created by Struts on the next request. That bean won't have your
> list of network types, which would explain what you are seeing.
>
> You could try putting your form bean in session scope instead. This means
> that it will still be around, with the network types intact, the next time
a
> request comes in. To do this, add 'scope="session"' to the relevant action
> mapping in your struts-config.xml file.
>
> You should also make sure that the form bean's reset() method doesn't
clear
> out the network types.
>
> Hope this helps.


Re: dropdown values gone after validation error

Posted by Ned Seagoon <th...@hotmail.com>.
sorry, too dark here, pressed wrong button :-)

#2 add to a derived action servlet in the function processValidate:

 if ( formInstance instanceof ActionFormEx )
  ((ActionFormEx) formInstance).populate(mapping,request);

in between the section marked

  // Has an input form been specified for this mapping?
..... block of code

and (i.e. add it here).

 // Save our error messages and return to the input form if possible
.... block of code

Correct as of beta-1. Now, when the form fails validation, then populate
will be called on the ActionFormEx. With that, you can then fill in any
stuff you require. I wouldn't go stickit it in the session as that stuff can
stay around for ages. plus also the user may invalidate the information with
another click stream anyway so it better to repopulate the object.

Ned

----- Original Message -----
From: "Ned Seagoon" <th...@hotmail.com>
To: <st...@jakarta.apache.org>
Sent: Sunday, April 01, 2001 7:17 PM
Subject: Re: dropdown values gone after validation error


> yeah, I had that problem. What I did was create my own form and
> actionservlet like this
>
> #1 define an abstract class called ActionFormEx with the following
function
>
> public void populate(ActionMapping mapping, HttpServletRequest request)
>
> #2 add the following code into a derived actionServlet
>
>
>
> ----- Original Message -----
> From: "Martin Cooper" <ma...@tumbleweed.com>
> To: <st...@jakarta.apache.org>
> Sent: Friday, March 30, 2001 6:07 AM
> Subject: Re: dropdown values gone after validation error
>
>
> > I'm guessing that your form bean has request scope. In this case, a new
> bean
> > will be created by Struts on the next request. That bean won't have your
> > list of network types, which would explain what you are seeing.
> >
> > You could try putting your form bean in session scope instead. This
means
> > that it will still be around, with the network types intact, the next
time
> a
> > request comes in. To do this, add 'scope="session"' to the relevant
action
> > mapping in your struts-config.xml file.
> >
> > You should also make sure that the form bean's reset() method doesn't
> clear
> > out the network types.
> >
> > Hope this helps.
>
>