You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by rapsy <ro...@gmail.com> on 2007/02/13 18:42:38 UTC

Drop down list is blank


Hi all,

I am using struts 1.1 version for my application.

I have to prepopulate  drop-down lists on various jsp pages. 
The approach I am taking right now is in the reset method I make a call to
database which returns me all the values for a list..for example it returns
me all states.
Then I put this variable in session and access in jsp to display the values
in drop down.
The problem is sometimes the drop down is blank but if I go to that page
again after some time it comes back. I have seen this problem couple of
times only but not able to reproduce every time.
I am trying to find out what could be the reason for this kind of behavior. 
Also, is there any other better approach to prepopulate the drop down list?
Should I just make call to database from jsp page.

Any help is appreciated.
Thanks

-- 
View this message in context: http://www.nabble.com/Drop-down-list-is-blank-tf3222141.html#a8949164
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Drop down list is blank

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Rapsy,

rapsy wrote:
> Also, is there any other better approach to prepopulate the drop down list?
> Should I just make call to database from jsp page.

You should have an action whose job it is to setup the request for this
kind of thing. Consider this setup:

request -> setup action -> display JSP

The setup action fetches your (static) data from the database and
puts it into the request attributes.

Your JSP uses that data from the request scope to populate the drop-down.

Submit your page to your "submit action", but set the "input" attribute
of that <action> to the setup action above instead of the JSP. This way,
you always get your states in the drop-down, even if the form fails
validation.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF0fx89CaO5/Lv0PARAp35AJ9yDKbMG0YWASKwLS2IreaX5BbCYQCfaqeq
GJ5nYtH7qVrHaPapSs7PObc=
=Jjjx
-----END PGP SIGNATURE-----

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