title: JSF2 composite component - condition on method attribute existenc
body: <p>I have a simple composite component with an optional ajax listener implemented with the richfaces a4j:ajax component.</p>
  
  <p>Here is the interface definition :</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;!-- INTERFACE --&gt;
  &lt;composite:interface name="inplaceInput"&gt;
      &lt;composite:attribute name="value" required="true" /&gt;
      &lt;composite:attribute name="render" default="@this" /&gt;
      &lt;composite:attribute name="ajaxListener" method-signature="void actionListener(javax.faces.event.AjaxBehaviorEvent)" /&gt;
  &lt;/composite:interface&gt;
  </code></pre>
  
  <p>The following code works fine using two duplicated blocks with opposite rendered condition :</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;composite:implementation&gt;
      &lt;rich:inplaceInput value="#{cc.attrs.value}" rendered="#{!empty cc.attrs.ajaxListener}"&gt;
          &lt;a4j:ajax event="change" render="#{cc.attrs.render}" execute="@this" listener="#{cc.attrs.ajaxListener}" /&gt;
      &lt;/rich:inplaceInput&gt;
      &lt;rich:inplaceInput value="#{cc.attrs.value}" rendered="#{empty cc.attrs.ajaxListener}"&gt;
          &lt;a4j:ajax event="change" render="#{cc.attrs.render}" execute="@this" /&gt;
      &lt;/rich:inplaceInput&gt;
  &lt;/composite:implementation&gt;
  </code></pre>
  
  <p>But I'd like to avoid the duplication because my component as to be far more complicated...</p>
  
  <p>Using a rendered condition on the a4j:ajax was my first idea :</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;rich:inplaceInput value="#{cc.attrs.value}"&gt;
      &lt;a4j:ajax event="change" render="#{cc.attrs.render}" execute="@this" listener="#{cc.attrs.ajaxListener}" rendered="#{!empty cc.attrs.ajaxListener}"  /&gt;
      &lt;a4j:ajax event="change" render="#{cc.attrs.render}" execute="@this" rendered="#{empty cc.attrs.ajaxListener}" /&gt;
  &lt;/rich:inplaceInput&gt;
  </code></pre>
  
  <p>But it doesn't work, and the error is quite obscure: </p>
  
  <pre><code>javax.faces.FacesException: Unable to resolve composite component from using page using EL expression '#{cc.attrs.ajaxListener}'
  at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:444)
  at org.ajax4jsf.component.behavior.MethodExpressionAjaxBehaviorListener.processAjaxBehavior(MethodExpressionAjaxBehaviorListener.java:73)
  </code></pre>
  
  <p>I tried with a c:if handler because the tree doesn't need to have both components:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;rich:inplaceInput value="#{cc.attrs.value}"&gt;
      &lt;c:if test="#{!empty cc.attrs.ajaxListener}"&gt;
          &lt;a4j:ajax event="change" render="#{cc.attrs.render}" execute="@this" listener="#{cc.attrs.ajaxListener}" /&gt;
      &lt;/c:if&gt;
      &lt;c:if test="#{empty cc.attrs.ajaxListener}"&gt;
          &lt;a4j:ajax event="change" render="#{cc.attrs.render}" execute="@this" /&gt;
      &lt;/c:if&gt;
  &lt;/rich:inplaceInput&gt;
  </code></pre>
  
  <p>And then got another error (using ajaxListener="#{itemList.updateValue}"):</p>
  
  <pre><code>javax.el.PropertyNotFoundException: /pages/itemList.xhtml @71,81 ajaxListener="#{itemList.updateValue}": Property 'updateValue' not found on type com...ItemListManager
  </code></pre>
  
  <p>If the attribute was an EL returning a value, I could test a default value. I could also add a boolean attribute to tell if the listener is set... Or add a default method on a componentType bean doing nothing... But that's not pretty...</p>
  
  <p>How can I test if a attribute is set without accessing it's value or method binding ?</p>
  
  <p>Thanks in advance for any idea,</p>
  
  <p>Rgds,</p>
  
  <p>FM</p>