• 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

html:select and pulling out value

 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unfortunately I still don't have a complete grasp on how struts interacts, and am having problems pulling out values from a select box. I have the following in the JSP:
<pre>
<select id="Order">
<logic:iterate name="User" property="orders" id="orders">
<option><bean:write name="orders" property="orderId" />
</option>
</logic:iterate>
</select>
<pre>

The problem is I am not sure how to determine which property was selected in the formbean. Any thoughts or suggestions anyone could offer would be fantastic.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My suggestion would be to use the html tags...they are a good friend to Struts developers. Without knowing what your form and objects looks like I can only guess at the property names, but the code might look like this:


"order" is a property on the form that stores the selected Order ID
"orders" refers to a "getOrders()" method on the form that returns a collection of Order objects
"orderId" refers to the getOrderId() property on the Order object...the same property is used for the value and the label

- Brent
[ November 07, 2006: Message edited by: Brent Sterling ]
 
A knibbs
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help Brent. I found out in the end from what I read using optionsCollection is only valid when you have a collection of beans, not a collection of Strings in which case just using options will work - thought I might put that in incase someone searches on this in the future.

Thanks again.
 
A knibbs
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help Brent. I found out in the end from what I read using optionsCollection is only valid when you have a collection of beans, not a collection of Strings in which case just using options will work - thought I might put that in incase someone searches on this in the future.

Thanks again.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic