views:

67

answers:

1

Hi,

I am using JSF tags within an XHTML file. My intention is to enable or disable a <rich:MenuItem> context-menu item by setting the "disabled" attribute to "true" or "false" appropriately. To do this, I am using a backing bean variable in a ternary operator and setting an <f:param> value to either "true" or "false" based on the bean variable, as below:

<rich:componentControl event="oncontextmenu" for="network-tree-menu"
operation="show">
       <f:param id="nestlevel" value="#{item.nestLevel > 10 ? 'true' : 'false'}"  
        name="nestlevel" />
 </rich:componentControl>  

where item is the backing bean and item.nestLevel is an integer.

I am using this <f:param> value later in the XHTML file as below:

<rich:contextMenu ...
    <rich:menuItem id="abc" ajaxSingle="true" disabled="{nestlevel}"
            onclick="doSomething();" value="Do something...">
</rich:contextMenu>  

This is not working !! The menu item is always enabled, (I guess this is the default behaviour) even though the result of the ternary operation is "true". Is there something I am missing here w.r.t the syntax, or is there some other way I can do this conditional enabling of context-menu items within the XHTML file?

Thanks in advance.

Regards,
Nagendra U M

+1  A: 

How about this:

<f:param id="nestlevel" value="#{item.nestLevel > 10}" name="nestlevel" />
amorfis
This worked, in the sense that the value {nestlevel} contains "true" or "false" appropriately. (I checked this using alerts). However, the context-menu item is still enabled even though the value of {nestlevel} is "true". Does this mean that the "disabled" attribute of the <rich:menuItem> tag does not accept EL values?? My intention is to conditionally enable and disable a context menu item based on the {nestLevel} value. Please help !!
Nagendra U M