0

I am displaying two values in JSF <h:selectOneMenu> and want to retrieve both values in managed bean. following is my JSF code.

<h:outputLabel value="Product "/>
<h:selectOneMenu value="#{placeOrderController.placeOrder.product}">
    <f:selectItems value="#{itemController.itemList}" var="cs" itemLabel="#{cs.title}  - #{cs.price}" itemValue="#{cs.title}"/>
</h:selectOneMenu>

In above code, I am displaying two values in <f:selectItems>, which are title and price, seperated by "-". I am successfully getting title in managed bean but wondering that how can I get price value too.

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
RK.
  • 973
  • 5
  • 19
  • 45
  • No, if i try this one then both value will come together. how would i separate those ones then ? – RK. May 16 '13 at 07:58
  • I don't understand what you mean with your last comment. Don't you need to display something like "Item Title 1 - 200", "Item Title 2 - 450" and on in a dropdownlist (``)? – Luiggi Mendoza May 16 '13 at 07:59
  • Thats what i am doing currently. Display both values but getting only title in managed bean. i want to get both values in managed bean. – RK. May 16 '13 at 08:03
  • 3
    Ok now I understand your problem. This can be easily solved if you use a converter. This is covered in [StackOverflow selectonemenu wiki](http://stackoverflow.com/tags/selectonemenu/info) – Luiggi Mendoza May 16 '13 at 08:09
  • Try to set unique value by which you can identify both's mapping, e.g. unique relation no. Once the selection is changed then you can query the database to find out both value. – Jitesh May 17 '13 at 12:34

0 Answers0