title: row editable data table column with dialog in jsf
body: <p>I am new to JSF. I am using row editable data table in JSF primefaces. In row editable datatable input text column it have two ajax calls.one is blur and another one is Commandbuuton. I want to get value from this input text column from backing bean.</p>
  
  <p>Here is my Code:</p>
  
  <pre><code>&lt;h:form id="frm1"&gt;
  &lt;p:dataTable var="fert" value="#{fertilizerEntryBean.fertList}" id="fertList" editable="true"  scrollable="true" scrollWidth="900" scrollHeight="250" &gt;
  
                              &lt;p:ajax event="rowEdit" listener="#{fertilizerEntryBean.onEdit}" update=":frm1:messages :frm1:ha_amount" /&gt;  
                              &lt;p:ajax event="rowEditCancel" listener="#{fertilizerEntryBean.onCancel}" update=":frm1:messages :frm1:ha_amount" /&gt;  
                              &lt;p:column headerText="...." width="15"&gt;
                                  &lt;p:rowEditor /&gt;  
                              &lt;/p:column&gt;
  &lt;p:column headerText="Receiver Plot No." width="150"&gt;
                                  &lt;p:cellEditor&gt;  
                                      &lt;f:facet name="output"&gt;&lt;h:outputText value="#{fert.receiverPlot}" /&gt;&lt;/f:facet&gt;  
                                      &lt;f:facet name="input"&gt;
                                          &lt;p:inputText id="receiverPlot" value="#{fert.receiverPlot}" size="15"&gt;
                                              &lt;p:ajax event="blur" listener="#{fertilizerEntryBean.loadReceiverDetails(fert)}" update="receiverCode,receiverName"/&gt;
                                          &lt;/p:inputText&gt;&amp;nbsp;
                                          &lt;p:commandButton icon="ui-icon-search" style="height: 25px;position: absolute;" onclick="receiver_dialog.show();"/&gt;
                                      &lt;/f:facet&gt;  
                                  &lt;/p:cellEditor&gt;  
                              &lt;/p:column&gt;
  &lt;/p:datatable&gt;
  &lt;/h:form&gt;
  &lt;h:form id="receiverForm"&gt;
              &lt;p:dialog widgetVar="receiver_dialog" id="receiver_dialog"&gt;
                  &lt;p:dataTable id="receiver_table" value="#{fertilizerEntryBean.mediumFertModel}" selection="#{fertilizerEntryBean.selectedList}" selectionMode="single" var="fert" rows="10" liveScroll="true"  paginator="true" paginatorPosition="bottom" 
                               paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  rowsPerPageTemplate="5,10,20"&gt;
                      &lt;p:ajax event="rowSelect" listener="#{fertilizerEntryBean.onRowSelect}" update=':frm1:fertList:receiverPlot'/&gt;
                      &lt;p:column id="state_id_column" headerText="Receiver Code"&gt;
                          &lt;h:outputText value="#{fert.receiverPlot}"/&gt;
                      &lt;/p:column&gt;
                  &lt;/p:dataTable&gt;
                  &lt;p:commandButton style="alignment-adjust: central;" value='OK' onclick="receiver_dialog.hide();"/&gt;
              &lt;/p:dialog&gt;
          &lt;/h:form&gt;
  </code></pre>
  
  <p>And my Bean Class:</p>
  
  <pre><code>public class FertilizerEntryBean implements Serializable{
  private List&lt;FertModel&gt; fertList=null;
  private FertDataModel mediumFertModel;
  private FertModel selectedList;
  public List&lt;FertModel&gt; getFertList() {
      return fertList;
  }
  
  public void setFertList(List&lt;FertModel&gt; fertList) {
      this.fertList = fertList;
  }
  public FertDataModel getMediumFertModel() {
      getReceiverCode();
      return mediumFertModel;
  }
  
  public void setMediumFertModel(FertDataModel mediumFertModel) {
      this.mediumFertModel = mediumFertModel;
  }
  
  public FertModel getSelectedList() {
      return selectedList;
  }
  
  public void setSelectedList(FertModel selectedList) {
      this.selectedList = selectedList;
  }
  public List&lt;FertModel&gt; getReceiverCode(){
  Session session=HibernateUtil.getSessionFactory().openSession();
  try{
      List&lt;DosVendormaster&gt; vendorList=session.createCriteria(DosVendormaster.class).add(Restrictions.eq("vendortype", "CGRV")).add(Restrictions.eq("block", "X")).list();
      if(vendorList.size()&gt;0){
          for (Iterator&lt;DosVendormaster&gt; it = vendorList.iterator(); it.hasNext();) {
              DosVendormaster dosVendormaster = it.next();
              fertList.add(new FertModel(dosVendormaster.getSapVendorcode()));
          }
          mediumFertModel=new FertDataModel(fertList);
      }
  }catch(Exception ex){
      ex.printStackTrace();
  }finally{
      session.close();
  }
  return fertList;
  }
  
  public void onRowSelect(SelectEvent event) {
      FacesMessage msg = new FacesMessage(" Selected", ((FertModel)        event.getObject()).getReceiverPlot());
      FacesContext.getCurrentInstance().addMessage(null, msg);
      FertModel fert=new FertModel();
      fert.setReceiverPlot(((FertModel) event.getObject()).getReceiverPlot());
  }
  }
  </code></pre>