aspose file tools*
The moose likes JSF and the fly likes Validation of ListBox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Validation of ListBox" Watch "Validation of ListBox" New topic
Author

Validation of ListBox

michael nik
Greenhorn

Joined: Mar 11, 2012
Posts: 15
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

Joined: Dec 29, 2011
Posts: 14
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

Joined: Jun 25, 2001
Posts: 16019
    
  20

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
wood burning stoves
 
subject: Validation of ListBox