• 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

SelectOneMenu Value not getting set in bean

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am using <h:selectOneMenu> in my code for a dropdon with <f:selectItems>

The problem is strBeanVal bean variable is getting set to blank.

The Value seen in view source html is as highlighted in blue-

<option value="2000000000050019@CENTER FOR MEDICINE-0010006770>2502 B E EMPIRE ST*BLOOMINGTON&Illinois%61704<$ManageSoldTo">CENTER FOR MEDICINE-0010001110</option>


Below is my code


This works fine with --<option value="2000000000050019">CENTER FOR MEDICINE-0010001110</option>

Is the value getting set to blank because of special characters or too many characters in the value??

Any help is appreciated.

Thanks in advance
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You missing the "#" is the <h:selectOneMenu> value attribute.

And welcome to the Ranch.
 
Omkar Anandache
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply.

Its a typo error but my actual code has it.
 
Omkar Anandache
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have edited the post
 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a submit button or something like ajax? Don't expect the value gets assigned magically upon selecting.
 
Omkar Anandache
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a form submit.

As i have mentioned in my post that it works finne with <option value="2000000000050019">CENTER FOR MEDICINE-0010001110</option>
 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code looks fine to me. When the form submits, you should get the value 2000000000050019 in the variable strBeanVal of the bean. Isn't this what you expected?
 
Saloon Keeper
Posts: 27762
196
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 could end up with a blank value if the backing bean's SelectItem list changes and the selection value is no longer in the list. Although that can also lead to validation errors.

A list mismatch can occur for several reasons. One of them would be if you tried to use Request scope on the backing bean. Request scope in JSF isn't as usable as it is in straight J2EE.
 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah yes Tim, the bean's scope can be an issue. I usually use view scope. If must session scope. Hardly request scope.

Omkar, what scope is your managed bean?
reply
    Bookmark Topic Watch Topic
  • New Topic