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

    Control of modalPanel not rendering

    cliffwiggs

      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;
       }
      
      }
      


        • 1. Re: Control of modalPanel not rendering
          cliffwiggs

          Update. I've discovered this is not due to the Control facet, but to the verbatim tag.

          I moved the verbatim tag to my modalPanel body and it would sometimes render and sometimes not.

          I changed to a commandButton and it works even within the control facet.

          I would still like comments on any 'bad style' in my approach and some thoughts on why the verbatim tag sometimes doesn't generate.

          Thank you for your time.

          • 2. Re: Control of modalPanel not rendering
            ilya_shaikovsky

            Unfortunatelly I have no problem with your code on the latest snapshot

            Al you need to remember - f:verbatim is required around plain html in JSF 1.1

            • 3. Re: Control of modalPanel not rendering
              cliffwiggs

              Thank you for the reply anyway.

              Even on my system it wasn't a consistent error. I try to test things completely before posting to make sure it isn't something wrong with my environment or something covered in the documentation. I'm having a problem with the dropSupport right now, but I'm not done testing it locally yet.

              Cliff