*
The moose likes JSF and the fly likes JSF - Listbox required= Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF - Listbox required="true" field problem" Watch "JSF - Listbox required="true" field problem" New topic
Author

JSF - Listbox required="true" field problem

Deniz Atak
Ranch Hand

Joined: Jun 29, 2011
Posts: 30
Hi,

I have one textfield and one listbox, both of them are required fields My problem is when the page reloads it does show required message for the text input but not for the list box.

My code is:



Do you have any opinion about this problem?

Thanks in advance.
Guy deLyonesse
Ranch Hand

Joined: Apr 12, 2011
Posts: 200

Not familiar with the webuijsf library but I presume it's similar to listbox-like components from other libraries.

A list box won't fire for an empty value because it doesn't take direct user input. In other words, unlike an inputText control, you don't edit its contents directly. Its value is set to a list of values which may be empty but still not null. If you want to perform some kind of validation to enforce that the user has added items to the list, you'll need to write a custom validator.
Deniz Atak
Ranch Hand

Joined: Jun 29, 2011
Posts: 30
Hi,

thanks for the explanation.

I have written a custom validation for listbox, but still no solution. Here is my modified code:



it is ignoring the required attribute. It doesn't show a red star close to listbox's label..
Deniz Atak
Ranch Hand

Joined: Jun 29, 2011
Posts: 30
I found the problem with my application: in the declaration of the label that belongs to listbox it was not mentioned that it belongs to listbox. The code will be more explanatory :

Thanks for your interest.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF - Listbox required="true" field problem
 
Similar Threads
JSF 2.0 Ajax Implementation
How do I use message bundles from my backing bean
keep the values of my input text fields
h:selectOneListBox validation trouble
JSF - Bean level form validation for listbox - required = "true" is not working properly