• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validation of ListBox

 
michael nik
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to display an error message if the user do not select anything from the list box. I have the following code in my bean but id doesn't work.



and in my mainForm.xhtml



How can I combine a <h:commandButton> with the above code? Now, in my button I have other method in the action=" " tag. Should I call the validateListBox() method from my button or is completely wrong?
Also, should I declare something in the faces-config.xml ?

Any help please ?

 
kumar toomu
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi michael,
i'm not clear on your code.
but i can see something that might be wrong.
in your validateListBox method, change "mainForm:staff" to "mainForm:Key1" or null
make sure your form id is mainForm
also in you xhtml code change for="staff" to for="key1"
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18108
51
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The more JSF-specific coding you do, the more likely you shouldn't be doing it that way.

Code "required="true"" as an attribute on the selectManyListBox xhtml element. Provide a requiredMessage attribute if you wish to override the standard message. Get rid of the UIComponent nonsense and explicit code in the backing mean. JSF can do it all automatically. And will, if you formulate th definition properly.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic