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 ?
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"
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.