3 Replies Latest reply on Apr 2, 2010 11:37 AM by peterlen

    rendered attribute not working on a reRender.... why?

    peterlen

      Hello,

       

      I have a context menu that is defined like:

       

      <rich:contextMenu event="oncontextmenu" id="myMenu" rendered="#{DataFolders.displayMenu}" submitMode="ajax">

          <rich:menuItem value="Paste" onClick="alert('not yet implemented')"/>

      </rich:contextMenu>

       

      The backing bean has the method getDisplayMenu to return true or false.  What I am seeing is that the context menu is rendered, or not rendered, properly when the page loads (based on what gets returned from getDisplayMenu.  After the page loads, however, whenever I do a reRender, I see that the getDisplayMenu method is being called but the context menu does not change its visibility based on the value returned.  For example, I initially have the getDisplayMenu return false.  When the page loads the context menu, as expected, is not available.  Some other action will then occur and a reRender is called.  I then see that the getDisplayMenu returns true, but the context menu does not become available (not rendered).  I can switch it around and initially return true, which in turn renders the context menu after the page loads.  I can then do a reRender and see tha tthe getDisplayMenu returns false, but the context menu is still rendered.  It seems that the context menu is rendered or not rendered based on the initial value and is not changing after that.  I tried wrapping the contextMenu in an a4j outputPanel but that did not work.

       

      Does anyone have any idea about what may be happening or what I am missing?

       

      Thanks - Peter

       

       

        • 2. Re: rendered attribute not working on a reRender.... why?
          peterlen

          Ilya,

           

          Thanks for the response.  The a4j outputPanel on the RichFaces component library page basically states the same thing as the page reference you listed.  When I saw that I wrapped my context menu in an outputPanel so it looked like:

           

          <a:outputPanel id="myMenu" >

               <rich:contextMenu event="oncontextmenu" rendered="#{DataFolders.displayDataTreeRootPasteMenu}" submitMode="ajax">

                <rich:menuItem value="Paste" onClick="alert('not yet implemented')"/>

             </rich:contextMenu>

          </a:outputPanel>

           

          When I ran this, it still did not seem to work and that is what I posted the question.  After going through it all again, I decided to run a test to see if the issue was a rendered attribute on the context menu.  I added an outputText component inside the outputPanel and used the same rendered logic as was on the context menu.  It is defined like:

           

          <a:outputPanel id="myMenu" >

           

             <h:outputText value="Hello there" rendered="#{DataFolders.displayDataTreeRootPasteMenu}"/>

           

             <rich:contextMenu event="oncontextmenu" rendered="#{DataFolders.displayDataTreeRootPasteMenu}" submitMode="ajax">

           

                <rich:menuItem value="Paste" onClick="alert('not yet implemented')"/>

           

             </rich:contextMenu>

          </a:outputPanel>

           

          When I ran it, the outputText was displayed, or not displayed, based on the "rendered" value just as it was suppose to.  The context menu does not have that same behavior.

           

          So now the issue is why is the rendered attribute not being evaluated for a context menu component like it is for other components.  Is it that context menus are not suppose use a rendered attribute?  or something else.

           

          Any thoughts on this new twist?

           

          Thanks - Peter

           

           

           

           

           

          • 3. Re: rendered attribute not working on a reRender.... why?
            peterlen

            It is all working now.   I did a slight switch to not use the render attribute on the context menu but to use a disabled attribute to the menuItem instead.