4 Replies Latest reply on Oct 13, 2008 2:24 AM by Paul Pantages

    Can't pass boolean parms in componentControl

    Paul Pantages Novice

      Hello Forum,

      I am using:
      Jboss 4.2.2.GA
      Seam 2.0.1.GA
      Richfaces 3.1.6.GA

      I was trying to use componentControl with a context menu inside a rich:tree.

      I can't seem to pass a boolean value true/false to the menu for use in the
      menuItem's disabled attribute.

      My component control is like so.

      <rich:treeNode rendered="#{node.nodeType == node.nodeTypeNe}" iconLeaf="/img/ne16.png">
       ....
       ....
       <rich:componentControl
       event="oncontextmenu"
       for="em" operation="show">
       <f:param value="#{node.description}" name="nm"/>
       <f:param value="#{node.id}" name="id"/>
       <f:param value="#{node.craftUrl}" name="crft"/>
       <f:param value="#{node.craftUrl == null ? true : false }" name="nocrft"/>
       </rich:componentControl>
      </rich:treeNode>
      


      Inside my context menu, I use the value of "nocrft" to disable one
      of the menu items.

      
      <rich:contextMenu id="em" attached="false" submitMode="ajax">
       ....
      
       <rich:menuItem
       value="Launch Craft {nocrft}"
       disabled="{nocrft}"
       onclick="window.open('{crft}','_blank')">
       </rich:menuItem>
      
       ....
      
      


      The menuItem is never disabled. I tried single quotes 'true' and 'false' and
      hard coding "true" for the f:paraemter nocrft, but the menuItem is never
      disabled.

      I put the {nocrft} in the value string to see what it was, and it
      is in fact "true" when expected....

      The answer is probably very simple, but somehow is eluding me.....

      Any help will be appreciated.

      Thanks, PdP


        • 1. Re: Can't pass boolean parms in componentControl
          Kiril Kirov Newbie

          I have the exact same problem. The big question is "Can we affect the component attributes with the parameters passed from componentControl or just the content of the component inside the menuItem.

          This is driving me crazy :( and no solution so far

          • 2. Re: Can't pass boolean parms in componentControl
            Paul Pantages Novice

            Hello k2kirov,

            No, I have not found a solution; I have been distracted with some memory leak issues and have not returned to look at this one. I thought that, in my case, I might be able to write some javascript to set the "disabled" attribute and call it on the onshow event, but I have not tried this.

            I will definitely post if I can get anything to work.

            PdP

            • 3. Re: Can't pass boolean parms in componentControl
              Nick Belaevski Master

              Just the content. A possible workaround is to create two menu items: one disabled another not and make one of them hidden by using style="display: {someParam}" declaration where someParam can be set to 'none' or ''.

              • 4. Re: Can't pass boolean parms in componentControl
                Paul Pantages Novice

                Thank you nick, the workaround fixed me up.

                k2kirov, hope this helps you. I used something like this for my componentControl:

                <rich:componentControl
                 event="oncontextmenu"
                 attachTiming="onload"
                 for="em" operation="show">
                 <f:param value="#{node.description}" name="nm"/>
                 <f:param value="#{node.id}" name="id"/>
                 <f:param value="#{node.craftUrl}" name="crft"/>
                 <f:param value="#{node.craftUrl == null ? 'block' : 'none' }" name="cd"/>
                 <f:param value="#{node.craftUrl == null ? 'none' : 'block' }" name="ce"/>
                </rich:componentControl>
                

                I used 'block' intstead of '' to avoid FF css errors about invalid style.

                In the context menu:
                <rich:menuItem
                 style="display: {cd};"
                 value="Launch Craft"
                 disabled="true"
                 submitMode="none">
                </rich:menuItem>
                <rich:menuItem
                 style="display: {ce};"
                 value="Launch Craft"
                 disabled="false"
                 onclick="launchcrft('{crft}');">
                </rich:menuItem>
                


                PdP