title: values in primefaces edit dialog not getting updated
body: <p>I have table Providers.I am displaying the table contents in primefaces datatable and performing create,edit and delete operations on it using Jdbc and Tomcat 7.0.</p>
  
  <p>In the edit dialog there are save and cancel buttons. When I click the cancel button and click on the edit button of another row the values of previous row are getting displayed.</p>
  
  <p>I am getting the following warnings when I click on the cancel button:</p>
  
  <p>com.sun.faces.application.view.FaceletPartialStateManagementStrategy saveDynamicActions
  WARNING: Unable to save dynamic action with clientId 'editproviderform:btnCancelProviders' because the UIComponent cannot be found</p>
  
  <p>Providers table structure:</p>
  
  <p>ProviderId,
  ProviderFirstName and
  ProviderLastName</p>
  
  <p>Providers.java</p>
  
  <pre><code>public class Providers implements Serializable {
  
  private static final long serialVersionUID = 1L;
  private Integer providerId;
  private String providerFirstName;
  private String providerLastName;
  
  public Providers() {
  }
  
  public Providers(Integer providerId) {
      this.providerId = providerId;
  }
  
  public Providers(Integer providerId, String providerFirstName, String providerLastName) {
      this.providerId = providerId;
      this.providerFirstName = providerFirstName;
      this.providerLastName = providerLastName;
  }
  
  public Integer getProviderId()
  {
      return providerId;
  }
  
  public void setProviderId(Integer providerId)
  {
      this.providerId=providerId;
  }
  
  public String getProviderFirstName()
  {
      return providerFirstName;
  }
  
  public void setProviderFirstName(String providerFirstName)
  {
      this.providerFirstName=providerFirstName;
  }
  
  public String getProviderLastName()
  {
      return providerLastName;
  }
  
  public void setProviderLastName(String providerLastName)
  {
      this.providerLastName=providerLastName;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>ProvidersBean.java</p>
  
  <pre><code>@ManagedBean(name = "providersBean")
  @SessionScoped
  public class ProvidersBean implements Serializable {
  
  private Providers selectedProvider;
  
  public Providers getSelectedProvider() {
      return selectedProvider;
  }
  
  public void setSelectedProvider(Providers selectedProvider) {
      this.selectedProvider = selectedProvider;
  }
  private Connection con;
  @Resource(name = "jdbc/abc")
  private DataSource ds;
  
  public ProvidersBean() {
      try {
          Context ctx = new InitialContext();
          ds = (DataSource) ctx.lookup("java:comp/env/jdbc/ClinicalStudy");
      } catch (NamingException e) {
          e.printStackTrace();
      }
  }
  
  public void updateProvider() {
      try {
          con = ds.getConnection();
          PreparedStatement ps = con.prepareStatement("UPDATE Providers SET 
      ProviderFirstName=?,ProviderLastName=? WHERE ProviderId=?");
          ps.setString(1, selectedProvider.getProviderFirstName());
          ps.setString(2, selectedProvider.getProviderLastName());
          ps.setInt(3, selectedProvider.getProviderId());
          ps.executeUpdate();
          clearSelectedProvider();
          ps.close();
          con.close();
      } catch (SQLException e) {
          System.out.println("SQLException:" + e.getMessage());
      }
  }
  
  @PostConstruct
  public void init()
  {
      selectedProvider=new Providers();
  }
  
  public void clearSelectedProvider()
  {
      selectedProvider = null;
  }
  
  public void close(CloseEvent event)
  {
      event.getComponent().getChildren().clear();
      clearSelectedProvider();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Edit dialog code</p>
  
  <pre><code>&lt;p:dialog id="_EditProvider" header="Edit Provider" widgetVar="EditProvider" modal="true"
                    showEffect="fade" hideEffect="fade" resizable="false" position="center" 
                    appendToBody="true"&gt;
              &lt;p:ajax event="close" listener="#{providersBean.close}"
                      update=":editproviderform" global="false"/&gt;
              &lt;h:form id="editproviderform"&gt;
                  &lt;p:panelGrid columns="2" rendered="#{not empty providersBean.selectedProvider}"&gt;
  
                      &lt;h:outputLabel for="EdtProviderFirstName" value="ProviderFirstName*:"/&gt;
                      &lt;p:inputText id="EdtProviderFirstName" value="#{providersBean.selectedProvider.providerFirstName}"
                                   required="true" requiredMessage="FirstName must be entered" maxlength="30"
                                   validatorMessage="FirstName must be an alphanumeric value"&gt;
                          &lt;f:validateRegex pattern="[a-zA-Z0-9\s]+"/&gt;
                      &lt;/p:inputText&gt;
  
                      &lt;h:outputLabel for="EdtProviderLastName" value="ProviderLastName*:"/&gt;
                      &lt;p:inputText id="EdtProviderLastName" value="#{providersBean.selectedProvider.providerLastName}"
                                   required="true" requiredMessage="LastName must be entered" maxlength="30"
                                   validatorMessage="LastName must be an alphanumeric value"&gt;
                          &lt;f:validateRegex pattern="[a-zA-Z0-9\s]+"/&gt;
                      &lt;/p:inputText&gt;
  
                      &lt;p:commandButton id="btnUpdateProvider" value="Save" actionListener="#{providersBean.updateProvider()}" 
                                       update=":providersform:providersdt :providersmessages:messages" oncomplete="handleEditProviders(xhr,status,args)"/&gt;
                      &lt;p:commandButton id="btnCancelProviders" value="Cancel" actionListener="#{providersBean.clearSelectedProvider()}"  
                                       oncomplete="EditProvider.hide()"/&gt;
  
                  &lt;/p:panelGrid&gt;
              &lt;/h:form&gt;
          &lt;/p:dialog&gt;
  </code></pre>
  
  <p>Below is the code for the edit button in datatable:</p>
  
  <pre><code>&lt;p:column style="text-align: center;"&gt;
                      &lt;p:commandButton id="btneditproviders" value="Edit" update=":editproviderform" oncomplete="EditProvider.show()" title="Edit"&gt;
                          &lt;f:setPropertyActionListener value="#{item[0]}" target="#{providersController.selectedProvider}"/&gt;
                      &lt;/p:commandButton&gt;                        
                  &lt;/p:column&gt;
  </code></pre>