Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Validation of ListBox

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"
 
Saloon Keeper
Posts: 27933
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Forget this weirdo. You guys wanna see something really neat? I just have to take off my shoe .... (hint: it's a tiny ad)
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic