I do exactly that although I don't bother with rich:effect
.
I use jQuery. It's personal preference but I find it much easier and direct than using rich:effect (which is based on Scriptaculous). It's worth having a quick look at the jQuery Effects documentation.
An example:
Add jquery to your page (ships with richfaces):
<a:loadScript src="resource://jquery.js"/>
Assign jQuery to $j for convenience (add this to your javascript):
$j = jQuery.noConflict();
Messages Div:
<a:outputPanel id="messagetextPanel" ajaxRendered="true" layout="block" style="z-index:100; display:none;">
<s:div styleClass="messagetext" rendered="#{not empty facesContext.maximumSeverity}">
<h:messages infoClass="infomessage" errorClass="errormessage" warnClass="warningmessage" layout="list" />
<s:div styleClass="messageClose">
<a onclick="hideMessages();">#{messages['messages.close']}</a>
</s:div>
</s:div>
</a:outputPanel>
Some javascript to hide and show the div:
function hideMessages() {
$j("div#messagetextPanel").fadeOut("slow");
}
function showMessages() {
$j("div#messagetextPanel").fadeIn("fast");
}
Now you just have to figure out the best way to call the showMessages() when completing a call (eg. use oncomplete on your a4j:commandButton
etc).
Personally I prefer to not have an effect on the showing of the div so that I can use ajaxRendered to handle everything. You can do this by replacing the first line with:
<a:outputPanel id="messagetextPanel" ajaxRendered="true" layout="block" style="z-index:100; display: #{empty facesContext.maximumSeverity ? 'none' : 'block'};">
This way I don't have to have any code on my button/link/support and the FacesMessages will always be displayed when my Back-end code decides to create one.