title: How do I define a component as an attribute of composite component?
body: <p>I'm creating a keyboard (composite component) with some specific symbols that the user will be able to insert in text fields. I need to define two components as the keyboard's attributes, p:inputText and p:inputTextarea, to set to these inputs' values the symbol selected by the user.The problem is that I can't use a component as the keyboard attribute, it is not working. In my index.xhtml file, how do I pass the inputText?
  Index:</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;ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:pe="http://java.sun.com/jsf/composite/pe"
      template="/pages/template/template.xhtml"&gt;
      &lt;ui:define name="content"&gt;
  
  
          &lt;p:inputText widgetVar="asd" id="asd" value="#{disciplineController.discipline.description}"/&gt;
          &lt;pe:keyboard textField="asd"/&gt;
  
  &lt;!-- How do I pass the p:inputText as attribute? 
  Already tried &lt;pe:keyboard textField="#{asd}"/&gt;, it gets null
  --&gt;
  
  
      &lt;/ui:define&gt;
  &lt;/ui:composition&gt;
  </code></pre>
  
  <p>Keyboard
      
      
      </p>
  
  <pre><code>&lt;composite:interface componentType="keyboardComponentBean"&gt;
      &lt;composite:attribute name="textField" type="org.primefaces.component.inputtext.InputText"&gt;&lt;/composite:attribute&gt;
      &lt;composite:attribute name="textFieldArea" type="org.primefaces.component.inputtextarea.InputTextarea"&gt;&lt;/composite:attribute&gt;
  &lt;/composite:interface&gt;
  
  &lt;composite:implementation&gt;
      &lt;h:form&gt;
              &lt;ui:repeat value="#{cc.attrs.SYMBOL_ARRAY}" var="symbol"&gt;
              &lt;ui:fragment rendered="#{symbol == cc.attrs.SYMBOL_ARRAY[0]}"&gt; Conjuntos &lt;br /&gt;&lt;/ui:fragment&gt;
              &lt;ui:fragment rendered="#{symbol == cc.attrs.SYMBOL_ARRAY[11]}"&gt; &lt;br /&gt;Símbolos &lt;br /&gt;&lt;/ui:fragment&gt;
              &lt;ui:fragment rendered="#{symbol == cc.attrs.SYMBOL_ARRAY[24]}"&gt; &lt;br /&gt;Subscrito &lt;br /&gt;&lt;/ui:fragment&gt;
              &lt;ui:fragment rendered="#{symbol == cc.attrs.SYMBOL_ARRAY[39]}"&gt; &lt;br /&gt;Sobrescrito &lt;br /&gt;&lt;/ui:fragment&gt;
              &lt;ui:fragment rendered="#{symbol == cc.attrs.SYMBOL_ARRAY[55]}"&gt; &lt;br /&gt;Grego (maiúsculo) &lt;br /&gt;&lt;/ui:fragment&gt;
              &lt;ui:fragment rendered="#{symbol == cc.attrs.SYMBOL_ARRAY[65]}"&gt; &lt;br /&gt;Grego (minúsculo) &lt;br /&gt;&lt;/ui:fragment&gt;
              &lt;ui:fragment rendered="#{symbol == cc.attrs.SYMBOL_ARRAY[81]}"&gt; &lt;br /&gt;Setas &lt;br /&gt;&lt;/ui:fragment&gt;
              &lt;p:commandButton value="#{symbol}" action="#{cc.addText(symbol)}" /&gt;
              &lt;/ui:repeat&gt;
      &lt;/h:form&gt;
  &lt;/composite:implementation&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>FacesComponent:</p>
  
  <pre><code>package br.com.portal.education.Timer;
  
  import javax.faces.component.FacesComponent;
  import javax.faces.component.UINamingContainer;
  
  import org.primefaces.component.inputtext.InputText;
  import org.primefaces.component.inputtextarea.InputTextarea;
  
  @FacesComponent("keyboardComponentBean")
  public class Keyboard extends UINamingContainer {
  
      private final String[] SYMBOL_ARRAY = {..símbolos..};
  
      public String[] getSYMBOL_ARRAY() {
          return SYMBOL_ARRAY;
      }
  
      public void addText(String symbol) {
          Object textField = getAttributes().get("textField");
          Object textFieldArea = getAttributes().get("textFieldArea");
              if (textField != null){
                  ((InputText) textField).setValue(((InputText) textField).getValue() + symbol);
              }
  
              if (textFieldArea != null){
              ((InputTextarea) textFieldArea).setValue(((InputTextarea) textFieldArea).getValue() + symbol);
          }
      }
  }
  </code></pre>