You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Sundararaman, Anand" <An...@ps.net> on 2009/03/02 19:19:14 UTC

Struts 2 - After validation failure populating the drop downs

Hi,
  I guess there is an elegant solution for this but I could not find out in the user list.
  
I am using Struts 2 and creating some form validations. If a validation fails on a JSP screen, the input result takes back the control to the same screen, but the drop downs are not populated. I need to know the best way of showing the validation failures and also populating the drop downs.

Thanks a Lot,

Anand


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 - After validation failure populating the drop downs

Posted by hernan gonzalez <hg...@gmail.com>.
You should tell us how the dropdowns were populated in the first page.
If only one Action class is involved, and the dropdowns are populated
by reading some attribute of it
(eg:   getOptionListForDropDown() which looks at the
optionListForDropDown list )
you should fill that list, not in the action method that is invoked
for generating the
first form page, but in the prepare method, or in the constructor, or
making the getter method a "lazy getter" (my preferred way, in
general; but this depends on the scenario)

Hernán J. González
http://hjg.com.ar/



--

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 - After validation failure populating the drop downs

Posted by Lukasz Lenart <lu...@googlemail.com>.
Implement Preparable interface [1] and take a look on Prepare
interceptor [2], it should be what you want

[1] http://struts.apache.org/2.1.6/struts2-core/apidocs/com/opensymphony/xwork2/Preparable.html
[2] http://struts.apache.org/2.1.6/docs/prepare-interceptor.html


Regards
-- 
Lukasz
http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 - After validation failure populating the drop downs

Posted by Jim Kiley <jh...@summa-tech.com>.
In your action class, write a method like so:
public String input() {
// populate my dropdowns
return Action.INPUT;
}

Obviously you will have to write the code to populate your dropdowns there,
as that depends on what you are up to.  But the input() method of your
action class will be called if validation fails, so if you have things that
you want to make sure occur on validation failure, put them there.

jk

On Mon, Mar 2, 2009 at 1:30 PM, Sundararaman, Anand <
Anand.Sundararaman@ps.net> wrote:

> Hi,
>  Would you able to specify in little more detail? Sorry for that as I am
> new to Struts 2.
>
> Thanks,
> Anand
>
>
> -----Original Message-----
> From: Jim Kiley [mailto:jhkiley@summa-tech.com]
> Sent: Monday, March 02, 2009 12:23 PM
> To: Struts Users Mailing List
> Subject: Re: Struts 2 - After validation failure populating the drop downs
>
> Populating the dropdowns in an input() method that returns Action.INPUT
> should do the trick.
> jk
>
> On Mon, Mar 2, 2009 at 1:19 PM, Sundararaman, Anand <
> Anand.Sundararaman@ps.net> wrote:
>
> > Hi,
> >  I guess there is an elegant solution for this but I could not find out
> in
> > the user list.
> >
> > I am using Struts 2 and creating some form validations. If a validation
> > fails on a JSP screen, the input result takes back the control to the
> same
> > screen, but the drop downs are not populated. I need to know the best way
> of
> > showing the validation failures and also populating the drop downs.
> >
> > Thanks a Lot,
> >
> > Anand
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> --
> Jim Kiley
> Technical Consultant | Summa
> [p] 412.258.3346 [m] 412.445.1729
> http://www.summa-tech.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Jim Kiley
Technical Consultant | Summa
[p] 412.258.3346 [m] 412.445.1729
http://www.summa-tech.com

RE: Struts 2 - After validation failure populating the drop downs

Posted by "Sundararaman, Anand" <An...@ps.net>.
Hi,
  Would you able to specify in little more detail? Sorry for that as I am new to Struts 2.

Thanks,
Anand


-----Original Message-----
From: Jim Kiley [mailto:jhkiley@summa-tech.com] 
Sent: Monday, March 02, 2009 12:23 PM
To: Struts Users Mailing List
Subject: Re: Struts 2 - After validation failure populating the drop downs

Populating the dropdowns in an input() method that returns Action.INPUT
should do the trick.
jk

On Mon, Mar 2, 2009 at 1:19 PM, Sundararaman, Anand <
Anand.Sundararaman@ps.net> wrote:

> Hi,
>  I guess there is an elegant solution for this but I could not find out in
> the user list.
>
> I am using Struts 2 and creating some form validations. If a validation
> fails on a JSP screen, the input result takes back the control to the same
> screen, but the drop downs are not populated. I need to know the best way of
> showing the validation failures and also populating the drop downs.
>
> Thanks a Lot,
>
> Anand
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Jim Kiley
Technical Consultant | Summa
[p] 412.258.3346 [m] 412.445.1729
http://www.summa-tech.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 - After validation failure populating the drop downs

Posted by Jim Kiley <jh...@summa-tech.com>.
Populating the dropdowns in an input() method that returns Action.INPUT
should do the trick.
jk

On Mon, Mar 2, 2009 at 1:19 PM, Sundararaman, Anand <
Anand.Sundararaman@ps.net> wrote:

> Hi,
>  I guess there is an elegant solution for this but I could not find out in
> the user list.
>
> I am using Struts 2 and creating some form validations. If a validation
> fails on a JSP screen, the input result takes back the control to the same
> screen, but the drop downs are not populated. I need to know the best way of
> showing the validation failures and also populating the drop downs.
>
> Thanks a Lot,
>
> Anand
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Jim Kiley
Technical Consultant | Summa
[p] 412.258.3346 [m] 412.445.1729
http://www.summa-tech.com