• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

update html:options

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Luke Zechariah
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
//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
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot G.T. Reddy. This really helped me move faster...!
reply
    Bookmark Topic Watch Topic
  • New Topic