Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF - Listbox required="true" field problem

 
Deniz Atak
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 200
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic