You can do this using Primefaces.
In your Selectonemenu you would have the following properties:
- a Property called required="true" that would say that the field is required.
- a Property called requiredMessade="Your message" where you would say which message you want to add.
Above your form would have a message field to be shown, which could be so:
<p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" />
On your button you would need to add the following properties:
- ajax="true" to validate using ajax.
- immediate="false" (if true it will not do screen validations)
Or if you don’t want to use the first faces, you could put a message using Faces after the click of the button on your Bean, in this way:
FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_INFO, "Qual a mensagem", "O que dizer na mensagem");
Any questions you can check in the site itself:
http://www.primefaces.org/
Hello @Dante, the attribute "ajax" comes set with "true" by default mano.
– Cold
@Coldhack is true, I did not remember this detail, but the information was passed at least. Thanks for the correction!
– Dante