此内容没有您所选择的语言版本。
8.6. Success messages
Messages are commonly displayed to the user to indicate the success or failure of an action. A JSF
FacesMessage
is convenient for this function. However, a successful action often requires a browser redirect. Since JSF does not propagate Faces messages across redirects, it is difficult to display success messages in plain JSF.
The built-in conversation-scoped Seam component named
facesMessages
solves this problem. (This requires the Seam redirect filter.)
When a message is added to
facesMessages
, it is used in the nextg render response phase for the current conversation. Since Seam preserves even temporary conversation contexts across redirects, this works even without a long-running conversation.
You can even include JSF EL expressions in a Faces message summary:
facesMessages.add("Document #{document.title} was updated");
facesMessages.add("Document #{document.title} was updated");
Messages are displayed as usual:
<h:messages globalOnly="true"/>
<h:messages globalOnly="true"/>