title: How to prevent multiple composite components reset themselves on a JSF page?
body: <p>I put this problem in a simple example, a composite component that calculates the sum of 2 inputs and prints the result in an outputText</p>
  
  <p>Main JSF page:</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ez="http://java.sun.com/jsf/composite/ezcomp/"&gt;
      &lt;h:head&gt;&lt;/h:head&gt;
      &lt;h:body&gt;
        &lt;ez:Calculator /&gt;
        &lt;br/&gt;
        &lt;br/&gt;
        &lt;ez:Calculator /&gt;
        &lt;br/&gt;
        &lt;br/&gt;
        &lt;ez:Calculator /&gt;
      &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Composite component XHTML:</p>
  
  <pre><code>&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:composite="http://java.sun.com/jsf/composite"
    xmlns:h="http://java.sun.com/jsf/html"&gt;
      &lt;h:head&gt;
          &lt;title&gt;This content will not be displayed&lt;/title&gt;
      &lt;/h:head&gt;
      &lt;h:body&gt;
      &lt;composite:interface componentType="calculator"&gt;
      &lt;/composite:interface&gt;
  
      &lt;composite:implementation&gt;
        &lt;h:form&gt;
        &lt;h:inputText id="first" value="#{cc.firstNumber}" /&gt; 
        &lt;h:commandButton value="+" action="#{cc.sum}"/&gt;
        &lt;h:inputText id="second" value="#{cc.secondNumber}" /&gt; 
        &lt;/h:form&gt;
        &lt;h:outputText id="result" value="#{cc.result}" /&gt;
    &lt;/composite:implementation&gt;
  
  &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Composite component backing bean:</p>
  
  <pre><code>package ez;
  
  
  import javax.faces.component.FacesComponent;
  import javax.faces.component.UINamingContainer;
  
  @FacesComponent("calculator")
  public class Calculator extends UINamingContainer  {
  
      private Long firstNumber;
      private Long secondNumber;
      private Long result;
  
      public Calculator() {
      }
  
      @Override
      public String getFamily() { 
        return "javax.faces.NamingContainer"; 
      }
  
      public void setFirstNumber(String firstNumber) {
        this.firstNumber = Long.parseLong(firstNumber);
      }
  
      public String getFirstNumber() {
        if(firstNumber == null) {
          return null;
        }
        return firstNumber.toString();
      }
  
      public void setSecondNumber(String secondNumber) {
        this.secondNumber = Long.parseLong(secondNumber);
      }
  
      public String getSecondNumber() {
        if(secondNumber == null) {
          return null;
        }
        return secondNumber.toString();
      }
  
      public String getResult() {
        if(result == null) {
          return null;
        }
        return result.toString();
      }
  
      public void setResult(String result) {
        this.result = Long.parseLong(result);
      }     
  
      public void sum() {
        this.result = this.firstNumber + this.secondNumber;
      }
  }
  </code></pre>
  
  <p>So, I have 3 Composite Components that all should do the same thing, but when I press a SUM button, after the server processes the request, the result is printed out on the page, but the other 2 components are cleared of their values. </p>
  
  <p>How can I prevent this? How can I force it to retain those values? </p>