This article, and its links, helped in coming up with an answer: http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4061517
Here's the Submit button's code:
<a4j:commandButton action="/home.seam" value="Submit"
oncomplete="#{facesContext.maximumSeverity == null ? 'Richfaces.hideModalPanel(\'mpErrors\');' : 'Richfaces.showModalPanel(\'mpErrors\');'}"/>
You render the oncomplete on the server vs. the client. Based on the FacesContext errors, you either show or hide the modalPanel object.
Here's the modalPanel's code:
<rich:modalPanel id="mpErrors" width="350" height="250">
<f:facet name="header">
<h:panelGroup>
<h:graphicImage value="/img/msginfo.png" style="float:left; margin-right: 3px;" />
<h:outputText value="System Messages" />
</h:panelGroup>
</f:facet>
<f:facet name="controls">
<h:panelGroup>
<h:graphicImage value="/img/close.png" styleClass="hidelink" id="hidelinkmpErrors"/>
<rich:componentControl for="mpErrors" attachTo="hidelinkmpErrors" operation="hide" event="onclick"/>
</h:panelGroup>
</f:facet>
<a4j:outputPanel ajaxRendered="true" style="width:100%">
<rich:messages passedLabel="Data is allowed to be emailed."
style="width:100%; text-align: left; color: red; font-weight: bold;" rendered="#{facesContext.maximumSeverity == null ? 'false' : 'true'}"
layout="list">
<f:facet name="errorMarker">
<h:graphicImage style="margin-right: 5px;" value="/img/msgerror.png" />
</f:facet>
</rich:messages>
<div style="text-align:center">
<a4j:commandButton style="text-align:center; margin: 29px;" id="btnReturn" value="Return to Form" >
<rich:componentControl for="mpErrors" attachTo="btnReturn" operation="hide" event="onclick"/>
</a4j:commandButton>
</div>
</a4j:outputPanel>
</rich:modalPanel>
Next: How do you show a "Please wait..." modalPanel while the page's action is sending an email? Still working on that.
5 comments:
hi,
tank you it was so useful for me
Very nice and simple solution! Saved me a lot of work, thanks!
Can you please post the CSS for
styleClass="hidelink".
Here you go:
.hidelink{
padding-top:2px;
padding-right:1px;
cursor:pointer;
}
Saved my day!
Thank you very much, I will pay you a beer.
Post a Comment