wood burning stoves 2.0*
The moose likes Struts and the fly likes update html:options Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "update html:options" Watch "update html:options" New topic
Author

update html:options

Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 123
I am using struts, in my jsp page I have options menu where the value is selected depending on the database value, but the value in the database can be any some new value all the time. How should I make a new list then.

For ex: Let's assume there is a field in database: officeCodes having values from 1 through 10.

Now a new value 11 has been added to officeCodes, how should I update the list. The only code I have is as follows:


<bean:message key="clmrcpt.fromFO" />
<html:select name="ClaimReceiptForm" property="fromOffice">
<html ption value="1">one</html ption>
<html ption value="2">two</html ption>
<html ption value="3">three</html ption>
<html ption value="4">four</html ption>
<html ption value="5">five</html ption>
<html ption value="6">six</html ption>
<html ption value="7">seven</html ption>
<html ption value="8">eight</html ption>
<html ption value="9">nine</html ption>
<html ption value="10">ten</html ption>
</html:select>


I do not know how to proceed pls guide me. Thanks for the help in advance.

Arun.
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
instead of using html ption, use html ptions which uses a collection to generate the dropdowns. each time the page is displayed, go back to the database to get the list and put it into the request scope.

you can put the list in the session scope if you don't mind the dropdowns not updated when the user has not established a new session.


-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 123
Alan,

Thanks for the reply. Is it possible for you to send me a sample code on html ptions and give a brief explanation. I really appreciate for your time.

Arun.
G.T. Reddy
Ranch Hand

Joined: Jun 25, 2002
Posts: 45
//server side
public ArrayList getPressSystems(){
ArrayList pressSystems = new ArrayList();
Connection con = DatabaseHelper.prepareConnection();
String query = SDCQueries.SELECT_REF_PART_PRESS_SYSTEMS;
psmt = con.prepareStatement(query);
rs = psmt.executeQuery();
while (rs.next()) {
pressSystems.add(new LabelValueBean(rs.getString(1), rs.getString(1)));

}
return pressSystems;

}

////in action class
ArrayList pressSystems =(ArrayList) searchBo.getPressSystems(estimateId);

form.setPressSystems(pressSystems);

return mapping.findForward(jsppage);

//in jsp page

<html:select name="form" property="pressSystem" size="1">
<html ptions collection = "pressSystems" property = "value" labelproperty = "label"/>
</html:select>
Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 123
Thanks a lot G.T. Reddy. This really helped me move faster...!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: update html:options