You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "Raman, Ganapathy" <xg...@ti.com> on 2002/06/11 18:39:10 UTC

re-populating dropdown boxes

I've just started a project on struts and i'm facing a problem while doing
validations in ActionForm. Say if i have a textbox and a dynamically
generated dropdown box in my page and both the fields are mandatory. I
select a value in the dropdown but do not enter anything in the textfield.
The ActionForm performs the validation and returns an ActionError. But when
i'm repopulating the screen i do not have all the dropdown values in my
FormBean (only the selected value is sent as part of request). How do i
handle this situation if i should not make any database calls from the JSP.
I'm sure that this is a standard problem and most of you guys would've faced
this. It would be great if someone can let me know what is the
right/approppriate way to handle this.

Thanks in advance,
Gana

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: re-populating dropdown boxes

Posted by Shivdeep <sh...@sprinttech.com>.
Hi,

I had the same problem and worked around it. Works just fine. 

I had 2 drop-downs for country list and state list in an Employee Update 
page. I traversed to this page from the EmployeeMaster page which had a 
listing of all the employees in a company.. To come to this page I used 
"EditEmployeeAction" servlet and for Saving values "SaveEmployeeAction".
when I change the country i should get the corresponding state list.
I used "submit" to a ActionServlet which I was using for "Save" on change of 
country list drop-down. I got a different reference to the drop-down event 
(say: if(save==null and cancel==null) and called another mapping.findForward. 
This is the same forward used in "EditEmployeeAction" which I used to come to 
the Update page.In the ActionForm, in the reset method I took off the null 
for the Vector for country and state list and repopulated the lists. That is 
all!.

PS-In case U need the source code clipping let me know.

-- 
Sr. Executive
Research & Development
ASSYST (India) Pvt. Ltd
Software Technology Centre,
Opp. Sree Krishna Temple, 
Muttam, Thaikkattukara P.O 
Aluva - 683106, Cochin 
Kerala, INDIA. 
Tel:91-484-628803/06/09/628023
email - shivdeepk@sprinttech.com
Web - www.sprinttech.com, www.assyst.net

On Tuesday 11 June 2002 22:09, you wrote:
> I've just started a project on struts and i'm facing a problem while doing
> validations in ActionForm. Say if i have a textbox and a dynamically
> generated dropdown box in my page and both the fields are mandatory. I
> select a value in the dropdown but do not enter anything in the textfield.
> The ActionForm performs the validation and returns an ActionError. But when
> i'm repopulating the screen i do not have all the dropdown values in my
> FormBean (only the selected value is sent as part of request). How do i
> handle this situation if i should not make any database calls from the JSP.
> I'm sure that this is a standard problem and most of you guys would've
> faced this. It would be great if someone can let me know what is the
> right/approppriate way to handle this.
>
> Thanks in advance,
> Gana
>
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org> For additional commands,
> e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: re-populating dropdown boxes

Posted by James Mitchell <jm...@telocity.com>.
You should post over on the users list.

I'll copy it over for you.

James Mitchell
Software Engineer\Struts Evangelist
Struts-Atlanta, the "Open Minded Developer Network"
http://struts-atlanta.open-tools.org

> -----Original Message-----
> From: Raman, Ganapathy [mailto:xganapat@ti.com]
> Sent: Tuesday, June 11, 2002 12:39 PM
> To: 'Struts Developers List'
> Subject: re-populating dropdown boxes
>
>
> I've just started a project on struts and i'm facing a problem while doing
> validations in ActionForm. Say if i have a textbox and a dynamically
> generated dropdown box in my page and both the fields are mandatory. I
> select a value in the dropdown but do not enter anything in the textfield.
> The ActionForm performs the validation and returns an
> ActionError. But when
> i'm repopulating the screen i do not have all the dropdown values in my
> FormBean (only the selected value is sent as part of request). How do i
> handle this situation if i should not make any database calls
> from the JSP.
> I'm sure that this is a standard problem and most of you guys
> would've faced
> this. It would be great if someone can let me know what is the
> right/approppriate way to handle this.
>
> Thanks in advance,
> Gana
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: re-populating dropdown boxes

Posted by James Mitchell <jm...@telocity.com>.
You should post over on the users list.

I'll copy it over for you.

James Mitchell
Software Engineer\Struts Evangelist
Struts-Atlanta, the "Open Minded Developer Network"
http://struts-atlanta.open-tools.org

> -----Original Message-----
> From: Raman, Ganapathy [mailto:xganapat@ti.com]
> Sent: Tuesday, June 11, 2002 12:39 PM
> To: 'Struts Developers List'
> Subject: re-populating dropdown boxes
>
>
> I've just started a project on struts and i'm facing a problem while doing
> validations in ActionForm. Say if i have a textbox and a dynamically
> generated dropdown box in my page and both the fields are mandatory. I
> select a value in the dropdown but do not enter anything in the textfield.
> The ActionForm performs the validation and returns an
> ActionError. But when
> i'm repopulating the screen i do not have all the dropdown values in my
> FormBean (only the selected value is sent as part of request). How do i
> handle this situation if i should not make any database calls
> from the JSP.
> I'm sure that this is a standard problem and most of you guys
> would've faced
> this. It would be great if someone can let me know what is the
> right/approppriate way to handle this.
>
> Thanks in advance,
> Gana
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>