title: JSF2.0 composite component calling set method for a custom datatype
body: <p>Greeting,
  i have created a JSF composite component that takes an object of custom made class, and views its content, everything went good but i need the component to call the set method in the bean holding the custom class object.</p>
  
  <p>Sample Example :</p>
  
  <p>1- the component - componentTest.xhtml :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:composite="http://java.sun.com/jsf/composite"&gt;
  
      &lt;composite:interface&gt;
          &lt;composite:attribute name="valueHolder" required="true" type="com.max.ValueHolder" /&gt;
      &lt;/composite:interface&gt;
      &lt;composite:implementation&gt;
          &lt;h:inputText value="#{cc.attrs.valueHolder.value}" /&gt;
      &lt;/composite:implementation&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>notice that the component use an attribute of a custom type :</p>
  
  <pre><code>&lt;composite:attribute name="valueHolder" required="true" type="com.max.ValueHolder" /&gt;
  </code></pre>
  
  <p>2- the test page - default.xhtml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"   
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:max="http://java.sun.com/jsf/composite/max" &gt;
       &lt;h:body&gt;       
          &lt;h:form target="@self"&gt;      
              &lt;max:componentTest valueHolder="#{user.valueHolder}" /&gt; 
              &lt;h:commandButton value="test" action="#{myBean.action}" /&gt;
          &lt;/h:form&gt;
      &lt;/h:body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>and finally the bean - MyBean.java : </p>
  
  <pre><code>package com.max;
  
  import javax.faces.bean.ManagedBean;
  import javax.faces.bean.SessionScoped;
  
  import com.max.ValueHolder;
  
  @ManagedBean(name="myBean")
  @SessionScoped
  public class MyBean{
      private ValueHolder valueHolder= new ValueHolder();
  
      public ValueHolder getValueHolder() {
          return valueHolder;
      }
      public void setValueHolder(ValueHolder valueHolder) {
          this.valueHolder = valueHolder;
      }
  
      public String action(){
          return "default";
      }
  }
  </code></pre>
  
  <ul>
  <li>My problem is that the method Mybean.setValueHolder() is not being called as the h:inputText is holding the value within the ValueHolder not the ValueHolder itself.</li>
  </ul>
  
  <p>and i have tried setting the value with something like</p>
  
  <pre><code>&lt;c:set var="cachedValueHolder" value="${cc.attrs.valueHolder}"/&gt;
  &lt;a4j:ajax event="change" &gt;
      &lt;a4j:param value="#{cachedValueHolder}" assignTo="#{cc.attrs.valueHolder}" /&gt;
  &lt;/a4j:ajax&gt;
  </code></pre>
  
  <p>but it didnt work im not sure why!</p>
  
  <p>Regards</p>