2 Replies Latest reply on Jun 15, 2009 12:40 PM by grundor

    rich:contextMenu - icon check to show current selection

      Hello,

      I am using a shared rich:contextMenu that is popped up from a dataTable. When the contextMenu is displayed I want to show an icon (check mark) to show which of the items in the menu is currently enabled/disabled.

      I am using f:param to pass the menu setting to the menu via rich:componentControl. Within the menu, however, I am having trouble using the parameter macro {} within the icon attribute of rich:menuItem.

      The following code does not work (syntax error to place macro within #{}), but is it possible to use the macro within a #{} in some other way to achieve my desired result?:

      <rich:contextMenu attached="false" id="menu" submitMode="ajax">
       <rich:menuItem icon="#{{value1} eq 'YES' ? '/img/check.png' : '/img/blank.png'}">
       Setting 1
       </rich:menuItem>
      </rich:contextMenu>
      


      where value1 is passed in via:

      <h:graphicImage id="img_#{rowid}_#{colid}"
       value="/img/popup.png"
       style="border:0;background:transparent;cursor:pointer">
       <rich:componentControl id="cc_#{rowid}_#{colid}"
       event="onclick" for="menu" operation="show">
       <f:param name="value1"
       value="#{myAction.value1}"/>
       </rich:componentControl>
      </h:graphicImage>
      


      I am not sure where to look for information on using these {} macros - I haven't seen anything in example code that would show me how to use one within context of making a logic decision.

      -Mark

        • 1. Re: rich:contextMenu - icon check to show current selection
          nbelaevski

          Hi Mark,

          Try this:

          {value1 == 'YES' ? 'check.png' : 'blank.png'}


          • 2. Re: rich:contextMenu - icon check to show current selection

            Thanks for the reply - however, I had tried that (and tried again in response to your post).

            When I use this:

            <rich:menuItem ajaxSingle="true" icon="#{value1 == 'YES' ? 'check.png' : 'blank.png'}">
             Attending: {value1}
            </rich:menuItem>
            


            The menu item displays the text "Attending: YES", but the check icon image is not displayed.

            I have validated that the image does in fact display if I do this:

            <rich:menuItem ajaxSingle="true" icon="check.png">
             Attending: {value1}
            </rich:menuItem>
            


            Am I trying to mix 2 things ({}, versus #{}) which are not intended to be used together?

            -Mark