| Author |
persist a value in drop down menu
|
Navdeep Singh
Greenhorn
Joined: Nov 18, 2006
Posts: 4
|
|
hi all, is there any solution to persist a value in the drop down menu only by using strtus tags. please do reply. thanks in advance. navdeep
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
I'm not entirely sure what you mean by "persist". If you mean persist to a java class, the answer is yes, there is a solution. By simply using the <html:select> and <html ptions> tags, Struts automatically persists the values entered into the ActionForm bean when the form is submitted. If you mean persist to a database, the answer is no, there is no solution using tags only. Struts is an MVC framwork, and putting logic to access a database in a JSP breaks the MVC model. The Struts way to persist data to a database is to include that logic in the "model" portion of your application and then have your Action class send messages to your model classes to persist data. [ November 19, 2006: Message edited by: Merrill Higginson ]
|
Merrill
Consultant, Sima Solutions
|
 |
Navdeep Singh
Greenhorn
Joined: Nov 18, 2006
Posts: 4
|
|
thanks Merrill for replying .. persist in my case means, when we select a value from a drop down box the selected value must remain selected in drop down box after submitting the form.
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
|
In that case, just use the Struts tags. If the page is submitted and then refreshed, the value will remain.
|
 |
prasanth jalasutram
Greenhorn
Joined: Dec 15, 2004
Posts: 6
|
|
As said you can use struts tags to get persisted. if in case you are using normal html tags you can use javascript also to achieve this. <html> <body> <form name="form1"> <select name=persistMenu onchange="call1()"> <option value="vijayawada">Vijayawada <option value="governorpet">Governorpet </select> </form> </body> </html> <script language="javascript"> var selectedIndex=0; function call1() { selectedIndex=document.forms[0].persistMenu.selectedIndex; document.forms[0].persistMenu.selectedIndex=selectedIndex; } </script> you can use that onchane event in appropriate place.
|
 |
 |
|
|
subject: persist a value in drop down menu
|
|
|