Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing EL expression to composite component
    primarykey
    data
    text
    <p>we are still in a JSF 1.2 to 2.0 migration scenario and we are now facing a problem related to c:set or ui:param variables used inside an EL expression.</p> <p>Here are the facts. There is a button as composite component:</p> <pre class="lang-html prettyprint-override"><code>&lt;cc:interface name="button" shortDescription="A button."&gt; ... &lt;cc:attribute name="disabled" required="false" default="false" shortDescription="The disabled flag." /&gt; ... &lt;/cc:interface&gt; &lt;cc:implementation&gt; &lt;ice:commandButton ... disabled="#{cc.attrs.disabled}" ... /&gt; &lt;/cc:implementation&gt; </code></pre> <p>Now we are trying to use this button component inside a toolbar. The disabled state of the button is determined inside the toolbar using a c:set or a ui:param (we already tried both ways).</p> <pre class="lang-html prettyprint-override"><code>&lt;c:set var="isButtonEnabled" value="#{backingBean.buttonEnabled}" /&gt; or &lt;ui:param name="isButtonEnabled" value="#{backingBean.buttonEnabled}" /&gt; #{isButtonEnabled} &lt;ctrl:button ... disabled="#{!isButtonEnabled}" ... /&gt; </code></pre> <p>So here is our problem. If we simple print out the value of "isButtonEnabled" in the toolbar, it is always correct. So the backing bean is ok. But when we try to pass this value to the composite component, it is not working. "Disabled" is always evaluated to false. </p> <p>Sure we could pass the method expression directly (#{!backingBean.isButtonEnabled}) and this will work fine. But in our scenario the determination of the enabled-flag is much more complicated and I just tried to keep the example as simple as possible. Aditionally this flag is used for multiple buttons inside the toolbar, so we wanted to keep the code maintainable by using a c:set or ui:param. Is this the wrong way to handle this? What do you recommend?</p> <p>Thanks in advance.</p> <p>SlimShady</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload