4 Replies Latest reply on Jul 17, 2009 9:05 AM by nbelaevski

    modal panel once again...

      Hey,

      I'm having some problems with a modal panel.
      I have a few on my side, but there is one which doesn't work well.

      F.ex. 2 commandButtons:

      <a4j:commandButton id="buttonKommentar" onclick="Richfaces.showModalPanel('kommentar', {top:'30px', left:'70px', height:'250', width:'400'});" value="add comment" />
      <a4j:commandButton id="buttonLoeschen" onclick="Richfaces.showModalPanel('loeschen', {top:'30px', left:'70px', height:'250', width:'400'}, reRender='tmp');" value="Löschen" />
      


      The first one shows the modal panel when clicking on it, the second doesn't.

      Here the code for the modal panels:
      <rich:modalPanel id="kommentar">
       <f:facet name="header">
       <h:outputText value="add comment" />
       </f:facet>
       <h:form>
       <p>
       blabla<br><br>
       <h:inputTextarea value="#{mb.newKommentar}" cols="65" rows="5" />
       </p>
       <h:panelGrid columns="1" columnClasses="alignRight" styleClass="maxWidth">
       <h:panelGroup>
       <h:commandButton value="Abbrechen" onclick="Richfaces.hideModalPanel('kommentar')" />
       <h:commandButton value="Kommentar erfassen" actionListener="#{mb.addKommentar}" />
       </h:panelGroup>
       </h:panelGrid>
       </h:form>
      </rich:modalPanel>
      
      (...)
      
      <rich:modalPanel id="loeschen" rendered="#{mb.show}">
      <div id="tmp">
       <f:facet name="header">
       <h:outputText value="löschen" />
       </f:facet>
       <h:form>
       <p>
       Do you really ...?<br>
       </p>
       <h:panelGrid columns="1" columnClasses="alignRight" styleClass="maxWidth">
       <h:panelGroup>
       <h:commandButton value="Abbrechen" onclick="Richfaces.hideModalPanel('loeschen')" />
       <h:commandButton value="Bestätigen" actionListener="#{mb.loeschen}" />
       </h:panelGroup>
       </h:panelGrid>
       </h:form>
      </div>
      


      The only difference beetween these two modal panels is that the second one has an attribute rendered which is in the beginning false. I can't change this otherwise the getter for some properties in my modal panel returns a NullPointerException because there aren't all informations laoded yet.

      So could this be the problem? Or am I doing something else wrong?

      One pretty interesting fact:
      When I first click on the Button for the first modal panel and click after that on the button for the second modal pannel everythin works.
      But when I start clicking on the second button I get this error:

      panel has no properties
      hideModalPanel()modalPanel.js.jsf (line 108)
      showModalPanel(function())modalPanel.js.jsf (line 107)
      showModalPanel("loeschen", Object top=30px left=70px height=250 width=400, "tmp")modalPanel.js.jsf (line 108)
      onclick(click clientX=0, clientY=0)fondsgesellschaft... (line 1)
      [Break on this error] invoke(function(){panel.component.show(event,opts);});};Richfaces.hideModalPanel...
      


      Any ideas?
      Thanks in advance!

        • 1. Re: modal panel once again...

          Indeed the problem occurs of the rendered="#{mb.show}".
          When I remove this property I don't have any errors opening the modal panel.

          Because of this I have to add to each inputfield of the modal panel which shows some informations this rendered attribut (otherwise I get some errors at start up).
          So far so good - BUT: When I click at the button for opening the modal panel I can add a actionListener-method. My problem is that first the modal panel gets opened and after that I reach my action method to change my rendered attribute from false to true --> thats to late. There are no inputfields displayed :(

          Apart from that it is pretty circuitous to add the rendered attribute to each inputfield instead of placing it at the <rich:modalPanel>-tag.

          Are there any solutions for this problem or does anybody has an idea for a workaround?

          Thanks in advance.

          • 2. Re: modal panel once again...
            ilya_shaikovsky

            conditionally rendered components should not be reRendered directly. visit FAQ.

            • 3. Re: modal panel once again...

               

              "ilya_shaikovsky" wrote:
              conditionally rendered components should not be reRendered directly. visit FAQ.


              Thanks for the hint. Propably you mean 1.59 (http://www.jboss.org/file-access/default/members/jbossrichfaces/freezone/docs/devguide/en/faq/faq.html#reRenderingfailed)?!

              So I tried to adopt this to my code but without a success.
              I surrounded my modal panel with a <a4j:outputPanel id='tmp'> and extended my a4j:command button by the reRendered attribute.

              <a4j:commandButton id="buttonLoeschen" actionListener="#{mb.method}" onclick="Richfaces.showModalPanel('loeschen', {top:'30px', left:'70px', height:'250', width:'400'});" value="Löschen" reRender="tmp" />
              


              Now I'm getting the error from the beginning:
              panel has no properties
              hideModalPanel()modalPanel.js.jsf (line 108)
              showModalPanel(function())modalPanel.js.jsf (line 107)
              showModalPanel("loeschenFondsgesellschaft", Object top=30px left=70px height=250 width=400, undefined)modalPanel.js.jsf (line 108)
              onclick(click clientX=0, clientY=0)fondsgesellschaft... (line 1)
              [Break on this error] invoke(function(){panel.component.show(event,opts);});};Richfaces.hideModalPanel...


              I don't even reach my action method to switch the value of the reRendered attribute of my modal panel.

              • 4. Re: modal panel once again...
                nbelaevski

                Hi,

                If the panel is not rendered, then it's not output to client. If it's not output, then it couldn't be located on the client, thus failing with JS error (similar to NPE in Java).