I face the same issue as described here Rich modalpanel closes automatically
I’m using richfaces 3.3.0 (Included in seam 2.12). I tried to isolate the problem, Firebug shows that after the modalpanel shows up, a request to the server is generated. And the panel closes after a few ms. I treied several locations for the rich_modalPanel tag (inside the form outside).
Any ideas?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
xmlns:a="http://richfaces.org/a4j"
xmlns:s="http://jboss.com/products/seam/taglib">
<head />
<body id="pgHome">
<f:view>
<div id="document">
<h:form id="login">
<fieldset>
<h:outputLabel id="UsernameLabel" for="username">Login Name</h:outputLabel>
<h:inputText id="username" value="#{identity.username}" style="width: 175px;" />
</fieldset>
<h:commandButton id="search2" value="modal"
onclick="#{rich:component('mp')}.show()" />
</h:form>
<rich:modalPanel id="mp" height="200" width="500">
<f:facet name="header">
<h:outputText value="Modal Panel Title" />
</f:facet>
</rich:modalPanel>
</div>
</f:view>
</body>
</html>
EDIT:
I finally used this example:
<rich:modalPanel id="modalPanelID">
<f:facet name="header">
<h:outputText value="header" />
</f:facet>
<a onclick="Richfaces.hideModalPanel('modalPanelID');" href="#">Hide</a>
</rich:modalPanel>
<a onclick="Richfaces.showModalPanel('modalPanelID');" href="#">Show</a>
This behavior is normal, as you display your
ModalPanelusing the commandButton using the following code:The
commandButtonwill display theModalPanel, and then will submit the form. This will force the page to be redisplayed completely, and that’s why you get this behavior.To solve your problem, you must
return false;at the end of theonclickevent, which can be translated to Display the Modal Panel and then stop any processing, i.e. do NOT submit the form. The code to use is the following: