• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

how to display value in htmlSelectOneMenu

 
Ranch Hand
Posts: 31
Hibernate Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all.
i have bind htmlSelectOneMenu. it contains some value. I want to set or display a value after a process.
How to change value
i have tried using setValue method of both binding property and value property of htmlSelectOneMenu.

Same issue is with InputTextArea. how to set value in it via code(RowSelectionListener of icefaces)
 
Saloon Keeper
Posts: 28477
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Forget about binding. It's something that people do too often for the wrong reasons.

If you have a selectOneMenu like this:


You can set the selection in Java code by simply invoking the "set" method: "setSelection(newValue)".

Please note that SelectOneMenu has built-in validation, however, and if you attempt to set a value that's not in the selectItems list, you'll have problems.

 
Balaji Kadam
Ranch Hand
Posts: 31
Hibernate Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your reply

You can set the selection in Java code by simply invoking the "set" method: "setSelection(newValue)".



what to set in value
itemValue or itemLabel .
i am trying itemvalue but it doesnot set properly
 
Tim Holloway
Saloon Keeper
Posts: 28477
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You always set the Value. The label is just for the user's display.

As I said, if the value isn't present in the selectItem list, the attempt will fail.
 
Balaji Kadam
Ranch Hand
Posts: 31
Hibernate Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
value isn't present in the selectItem list.
setValue() method invokes twice. when invokes first it contains proper value but next time it contains null so it doesn't display any value selected in it.

How to avoid second call.
 
Tim Holloway
Saloon Keeper
Posts: 28477
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Value MUST be in the selection list. That is not an option. If it is not, the value WILL be reset.

You also have no control over how many times set/get methods will be called on a property during the JSF request processing lifecycle. Which is why side-effects and long-running operations should not appear in get/set methods.
 
You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic