strange behaviour when first opening a modal panel
renegritsch Nov 23, 2010 2:48 AMSince a few weeks we have a problem.
If a redirect to a new page (with a new seam conversation, but i think this doesn´t really matter) and
we open modal panels for the first time, we have a strange behaviour. Rerender doesn´t work well, some datalists are not
refreshed and so on.
If do a page refresh in the browser then, every thing works fine from there on ?!
First of all, this happens to all modal panel, not only in 1 case. I´m pretty sure it is not a richfaces bug, but i´m really at the
end with my ideas what to do to fix this.
Maybe you can give me some hints, what a possible problem could be ?
We are using our own composite for the modal panels with an modalDialogController (conversation scope).
The modal panels have all there own forms and they are not nested. I also had a bug with the layout="block" posted before.
{code:xml}
<ui:component 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:a4j ="http://richfaces.org/a4j"
xmlns:rich ="http://richfaces.org/rich"
xmlns:s ="http://jboss.com/products/seam/taglib"
xmlns:fipos="http://enhancements.fipos/jsf"
xmlns:t="http://myfaces.apache.org/tomahawk"
xmlns:composite="http://java.sun.com/jsf/composite">
<rich:modalPanel id="dialogID" minWidth="600" autosized="true">
<f:facet name="header">
<h:panelGroup>
<a4j:outputPanel id="modalContentHeader">
<h:outputText value="#{model.preview}"></h:outputText>
</a4j:outputPanel>
</h:panelGroup>
</f:facet>
<f:facet name="controls">
<h:panelGroup>
<h:graphicImage value="#{resources.image('message.close')}" styleClass="hidelink" id="dynamicDialogPanelHidelink" style="padding:1px"/>
<rich:componentControl for="dialogID" attachTo="dynamicDialogPanelHidelink" operation="hide" event="onclick"/>
</h:panelGroup>
</f:facet>
<a4j:outputPanel id="modalContent">
<h:form id="dynamicDialogBoxForm">
<table width="100%">
<tr>
<td>
<fipos:include model="#{model}" page="#{page}"/>
</td>
</tr>
<tr style="width:100%;" align="right">
<td>
<fipos:include model="#{model}" page="#{buttonBar}"/>
</td>
</tr>
</table>
</h:form>
</a4j:outputPanel>
</rich:modalPanel>
</ui:component>
{code}
To open the dialogbox we use
{code:xml}
<h:graphicImage value="${resources.image('changeTab')}">
<a4j:support status="waitStatus" action="#{dynamicDialogHandler.setDialogModel(model)}" immediate="true" ajaxSingle="true" event="onclick" reRender="modalContent,modalContentHeader" oncomplete="Richfaces.showModalPanel('dialogID');"/>
</h:graphicImage>
{code}
Here is the DynamicDialogHandler
{code}
package xx;
import java.io.Serializable;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.log.Log;import com.generali.fipos.iss.base.decoration.properties.EmptyDecoratorModel;
import com.generali.fipos.model.Viewable;@SuppressWarnings("serial")
@Name("dynamicDialogHandler")
@Scope(ScopeType.CONVERSATION)
public class DynamicDialogHandler implements Serializable {
//static
@Logger Log log;
//members
//fields
protected Viewable<?> dialogModel = new EmptyDecoratorModel();
boolean mayCloseDialog = false;
protected String default_page = "/gui/common/empty.xhtml";
private String page = default_page;
private final String buttonBar_default = "/gui/composite/buttonBarDynamicDialog.xhtml";
private String buttonBar = buttonBar_default;
/**
* current model of the active dialog
* @return
*/
public Viewable<?> getDialogModel() {
return dialogModel;
}
/**
* returns the link to the button bar
* @return for example /gui/xy.xhtml
*/
public String getButtonBar() {
return buttonBar;
}
/**
*
* @param dialogModel
*/
public void setDialogModel(Viewable<?> dialogModel) {
setDialogModelAndPage(dialogModel,dialogModel.getMainPage());
}
/**
*
* @param dialogModel
*/
public void setDialogModelAndPage(Viewable<?> dialogModel,String differentPage) {
setDialogModelAndPage(dialogModel, differentPage, buttonBar_default);
}
/**
*
* @param dialogModel
*/
public void setDialogModelAndPage(Viewable<?> dialogModel,String differentPage,String differentButtonBar) {
this.dialogModel = dialogModel;
if(differentPage!=null && !differentPage.isEmpty())
this.page = differentPage;
else
this.page = dialogModel.getMainPage();
this.buttonBar = differentButtonBar;
log.debug("DialogHandler setting dialogModel="+getDialogModel()+"\tpage="+getPage()+"\tbuttonBar="+getButtonBar());
}
/**
* Returns the associated page for the current model
* @return
*/
public String getPage() {
if(page!=null && !default_page.equals(page))
return page;
if(getDialogModel()==null || getDialogModel().getMainPage()==null || "".equals(getDialogModel().getMainPage()))
return default_page;
else
return getDialogModel().getMainPage();
}
/**
* marks a dialog id for closing
* @param key dialogid
*/
public void markDialogForClose() {
log.debug("DialogHandler mark dialog to close");
mayCloseDialog=true;
}
/**
* demarks a dialog id for closing
* @param key dialogid
*/
public void demarkDialogForClose() {
log.debug("DialogHandler demark dialog to close");
mayCloseDialog=false;
}
/**
* checks if the dialog may be closed
* @param key dialogid
* @return
*/
public boolean mayCloseDialog() {
boolean b = mayCloseDialog;
mayCloseDialog=false;
return b;
}
}{code}
I´m really happy about any help!!