3 Replies Latest reply on May 24, 2007 2:11 PM by Cliff Wiggs

    Control of modalPanel not rendering

    Cliff Wiggs Newbie

      I want to follow 'best practices' so please let me know if there is a better way to implement what i'm trying to do.

      Imagine a shopping cart type application with a modalPanel backed by a bean to show detailed info on a product. You can click on any product and it updates the bean and then displays the same modal. Thats the closest analogy to what I'm doing.

      In my app, when I 'update' the modal and display it, the control facet doesn't render. This is where I've placed my 'close' link. Thus I am stuck in the modal.

      I stripped this down to just this demo code and the 'Change Message' link works correctly the first two times, but the 3rd time I click it, the control facet doesn't render.

      Based on another forum thread, should I create an ajax region inside the modalPanel and rerender it instead of rerendering the entire modalPanel?

      Here is my code:

      demo.jsp

      <%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j" %>
      <%@ taglib uri="http://richfaces.ajax4jsf.org/rich" prefix="rich"%>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      
      
      <HTML>
       <HEAD> <title>Demo Page</title> </HEAD>
       <body bgcolor="white">
       <f:view>
       <h:form>
       <f:verbatim>
       <a href="javascript:Richfaces.showModalPanel('popupMsg')">Showpopup</a>
       </f:verbatim>
      
       <a4j:commandLink reRender="popupMsg" value="Change Message" oncomplete="Richfaces.showModalPanel('popupMsg')">
       <a4j:actionparam value="Changed Message" assignTo="#{demo.modalMessage}" />
       </a4j:commandLink>
      
       <rich:modalPanel id="popupMsg" resizeable="false" height="200" width="200" zindex="2000">
       <f:facet name="header"><h:outputText value="Modal Panel"/></f:facet>
       <f:facet name="controls">
       <f:verbatim>
       <a href="javascript:Richfaces.hideModalPanel('popupMsg')">X</a>
       </f:verbatim>
       </f:facet>
      
       <h:outputText value="#{demo.modalMessage}"/>
       </rich:modalPanel>
      
       </h:form>
       </f:view>
       </body>
      </HTML>
      


      DemoBean.java
      package demo.web;
      
      public class DemoBean {
       private String modalMessage="Default Message";
      
       public String getModalMessage() {
       return modalMessage;
       }
      
       public void setModalMessage(String modalMessage) {
       this.modalMessage = modalMessage;
       }
      
      }