How to display error/confirmation message wherever you want
- – Without JSF UI control's Id and help of ice:messge's id attribute
In Backing bean -
- import org.jboss.seam.faces.FacesMessages;
- @In private FacesMessages facesMessages;
- facesMessages.addToControl("msgId", "Saved successfully!!!");
In JSF/Facelets page –
Put the following code wherever you want the error to be displayed -
<ice:message
id="msgId" for="msgId"
/>
- With make use of JSF UI control's Id
In Backing bean -
- import org.jboss.seam.faces.FacesMessages;
- @In private FacesMessages facesMessages;
- facesMessages.addToControl("jsfUIComponentId", "You have error message in the first name");
In JSF/Facelets page –
Put the following code wherever you want the error to be displayed -
<ice:outputText
id="jsfUIComponentId"
value="First Name"
/>
<br/>
<br/>
<!-- without id attribute since we added in outputText UI component -->
<ice:message
for="jsfUIComponentId"
/>
Note: To use facesMessages.addToControl("someJSF_UIComponentId", "some msg") - we need some UI component with Id's values with the same value which we used in the backing bean.
No comments:
Post a Comment