title: JSF resets fields when doing an ajax update
body: <p>I have a problem on my JSF page where I type a name into the first billing first name field. If I click on copy billing address checkbox; this stops rendering the delivery address panel and hides it via ajax, the value I just typed into the first field gets reset to its previous state.</p>
  
  <p>JSF Page</p>
  
  <pre><code>&lt;h:form&gt;
      &lt;p:inputText value="#{addressBean.billingAddress.firstName}" required="true"/ &gt;
  
      &lt;p:selectBooleanCheckbox value="#{addressBean.copyBillingAddress}" id="duplicateBillingDetails"&gt;
          &lt;f:ajax render="@form" /&gt;
      &lt;/p:selectBooleanCheckbox&gt;
  
      &lt;h:panelGrid rendered="#{not addressBean.copyBillingAddress}" columns="3"&gt;
          &lt;p:inputText value="#{addressBean.deliveryAddress.firstName}"/&gt;
      &lt;/h:panelGrid&gt;
  
      &lt;p:commandButton value="Checkout" action="#{addressBean.saveAddress}"/&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>Backing Bean</p>
  
  <pre><code>@Component
  @Scope("view")
  public class AddressBean implements Serializable {
      @Inject
      private CurrentUserBean currentUserBean;
      @Inject
      private UserService userService;
      private Address deliveryAddress = new Address();
      private Address billingAddress = new Address();
      private boolean copyBillingAddress;
  
  
      public AddressBean() {
  
      }
  
      public boolean isCopyBillingAddress() {
          return copyBillingAddress;
      }
  
      public void setCopyBillingAddress(boolean copyBillingAddress) {
          this.copyBillingAddress = copyBillingAddress;
      }
  
  
      public String saveAddress() {
          if (copyBillingAddress) {
              deliveryAddress = new Address(billingAddress);
          }
  
          User user = currentUserBean.getUser();
          if (!billingAddress.isSame(user.getBillingAddress())) {
              user.setBillingAddress(billingAddress);
          }
          if (!deliveryAddress.isSame(user.getDeliveryAddress())) {
              user.setDeliveryAddress(deliveryAddress);
          }
          currentUserBean.setUser(userService.save(user));
          return "/checkout.xhtml";
      }
  
      public CurrentUserBean getCurrentUserBean() {
          return currentUserBean;
      }
  
  
      public void setCurrentUserBean(CurrentUserBean currentUserBean) {
          this.currentUserBean = currentUserBean;
      }
  
      public Address getDeliveryAddress() {
          return deliveryAddress;
      }
  
      public void setDeliveryAddress(Address deliveryAddress) {
          this.deliveryAddress = deliveryAddress;
      }
  
      public Address getBillingAddress() {
          return billingAddress;
      }
  
      public void setBillingAddress(Address billingAddress) {
          this.billingAddress = billingAddress;
      }
  
  
  
  
  }
  </code></pre>