-
1. Re: FacesMessages are not being displayed
johndoe123 Aug 28, 2009 4:18 AM (in response to johndoe123)*FIXT*
Please ignore the first post.
This forum needs an edit-function!
Consider the following example:
Code:
<h:form>
<a4j:outputPanel id="messagePanel" ajaxRendered="true">
<h:message for="myGrid" styleClass="errormsg" />
</a4j:outputPanel>
<h:panelGrid id="myGrid" columns="4" style="margin: 0px; padding: 0px;">
<h:outputText value="stuff" />
<a4j:commandLink value="#{aComponent.doSomething}" rerender="messagePanel" />
</h:panelGrid>
</h:form>
And the method of the component:
Code:
public void doSomething()
{
FacesMessage msg = new FacesMessage();
msg.setSeverity(FacesMessage.SEVERITY_ERROR);
msg.setDetail("A MESSAGE");
FacesContext.getCurrentInstance().addMessage("myGrid", msg);
}
Why doesn't it display the message when clicking the commandLink? I am somewhat clueless and I can't use a messages tag, which works to my surprise.
Please give me some insight. -
2. Re: FacesMessages are not being displayed
ilya_shaikovsky Aug 28, 2009 4:48 AM (in response to johndoe123)/** * <p>Append a {@link javax.faces.application.FacesMessage} to the set of messages associated with * the specified client identifier, if <code>clientId</code> is * not <code>null</code>. If <code>clientId</code> is <code>null</code>, * this {@link javax.faces.application.FacesMessage} is assumed to not be associated with any * specific component instance.</p> * * @param clientId The client identifier with which this message is * associated (if any) * @param message The message to be appended * * @throws IllegalStateException if this method is called after * this instance has been released * @throws NullPointerException if <code>message</code> * is <code>null</code> */ public abstract void addMessage(String clientId, FacesMessage message);
you should pass client Id to this method.