File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

update html:options

Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 128
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>

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

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="" target="_blank" rel="nofollow"></a>
Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 128

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.

G.T. Reddy
Ranch Hand

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

return pressSystems;


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


return mapping.findForward(jsppage);

//in jsp page

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

Joined: Sep 27, 2005
Posts: 128
Thanks a lot G.T. Reddy. This really helped me move faster...!
I agree. Here's the link:
subject: update html:options
It's not a secret anymore!