-
Notifications
You must be signed in to change notification settings - Fork 1
Use of Messages, Growls and Validation
- Flash messages as a result of ajax requests, like: "Resources moved", "Password changed", "Saved"
- For error messages which require users attention, use dialogFramework instead.
Use existing methods from ApplicationBean (usually Beans should extend it) to add growls.
addGrowl(FacesMessage.SEVERITY_INFO, "Changes_saved");Please note, that there is no need to use getLocaleMessage("Changes_saved") for the message as it is automatically translated, just provide a message key
Never add p:growl to your page, it is already part of the main template.
But you can disable it if you need.
- For messages that appear during routing, like missing parameters, invalid data, access denied.
- Other non-ajax messages
Similar to p:growl, just use appropriate methods:
addMessage(FacesMessage.SEVERITY_INFO, "folderCreated", folder.getTitle());You can use addErrorMessage to show error messages, this method also sends an email notification to us (don't use it for expected errors).
To keep messages after redirecting, use setKeepMessages(); before or after a call to addMessage (once per method is enough).
In all normal forms use (including forms with ajax submit):
-
p:messagefor individual fields; - a message on top of the form with a summary of all messages. The message is necessary for mobiles, to make sure that the error message is visible (especially important for long forms).
<p:outputLabel for="@next" value="#{msg.full_name}:" />
<p:inputText value="#{profileBean.selectedUser.fullName}" label="#{msg.full_name}:" />
<p:message for="@previous" />TODO: need an example of a message on top of the form, e.g. using o:messages.