aspose file tools*
The moose likes JSF and the fly likes SelectOneMenu Value not getting set in bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "SelectOneMenu Value not getting set in bean" Watch "SelectOneMenu Value not getting set in bean" New topic
Author

SelectOneMenu Value not getting set in bean

Omkar Anandache
Greenhorn

Joined: Jul 22, 2013
Posts: 5
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
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2594
    
    9

You missing the "#" is the <h:selectOneMenu> value attribute.

And welcome to the Ranch.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Omkar Anandache
Greenhorn

Joined: Jul 22, 2013
Posts: 5
Thanks for your reply.

Its a typo error but my actual code has it.
Omkar Anandache
Greenhorn

Joined: Jul 22, 2013
Posts: 5
have edited the post
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2594
    
    9

Is there a submit button or something like ajax? Don't expect the value gets assigned magically upon selecting.
Omkar Anandache
Greenhorn

Joined: Jul 22, 2013
Posts: 5
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

Joined: Sep 13, 2007
Posts: 2594
    
    9

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?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16242
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2594
    
    9

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SelectOneMenu Value not getting set in bean