jsf - How to access the form objects in bean -


iam calling dialog using ajax, problem have defined form in dialog , accepting data's when click save want details in bean.

my issue: 1 ) when click save button not hit bean. 2) iam not able access objects of form in bean.

thanks in advance :)

my jsf file

<h:form id="outcompform">    <table border="0"  class="innerbox"    width="60%">               <tr><th  colspan="7" align="center" class="clstitle">outbound complaints</th></tr>               <tr>                    <td>consignment no </td>                    <td>consignor branch</td>                    <td>consignor  </td>                    <td>contact no </td>                     <td>remark</td>               </tr>                <tr>                    <td><h:inputtext  id="acno" value="#{outbound.accno}" onfocus="this.select()" styleclass="formtext"  /></td>                    <td>                             <h:selectonemenu value="#{outbound.cnor_branch}" id="fcobran" styleclass="formtext" >                                 <f:selectitems value="#{outbound.cnor_branchli}" var="c" />                             </h:selectonemenu>                         </td>                         <td>                             <p:selectonemenu value="#{outbound.cnor_name}"  id="fcnnam" editable="true">                                   <f:selectitem itemlabel="select one" itemvalue="" />                                   <f:selectitems value="#{outbound.cnor_nameli}" />                               </p:selectonemenu>                           </td>                         <td><h:inputtext  id="fcocont" value="#{outbound.cnor_contact}" onfocus="this.select()" styleclass="formtext"  /></td>                         <td><h:inputtext  id="fremark" value="#{outbound.remark}" onfocus="this.select()" styleclass="formtext"  /></td>                     </tr>                     <tr>                         <td>consignee branch</td>                         <td>consignee name </td>                         <td>address</td>                         <td>contact no</td>                         <td >booking date </td>                     </tr>                     <tr>                         <td>                             <h:selectonemenu value="#{outbound.cnee_branch}" id="fcebran" styleclass="formtext" >                                 <f:selectitems value="#{outbound.cnee_branchli}" var="c" />                             </h:selectonemenu>                         </td>                         <td><h:inputtext  id="fcename" value="#{outbound.cnee_name}" onfocus="this.select()" styleclass="formtext"  /></td>                         <td><h:inputtext  id="fceadr" value="#{outbound.cnee_addr}" onfocus="this.select()" styleclass="formtext"  /></td>                         <td><h:inputtext  id="fcecnt" value="#{outbound.cnee_contact}" onfocus="this.select()" styleclass="formtext"  /></td>                         <td>  <p:calendar value="#{outbound.booking_date}" id="fbdat"  >  </p:calendar>  </td>                          <td> <h:commandbutton value="save" action="#{outbound.saveaction}" onclick="return validate()" /> </td>                      </tr>                     <tr>                         <td colspan="7">                              <h:message for="acno"/>                         </td>                     </tr>                 </table>                 <p:growl id="growl" showdetail="true"/>                   <p:datatable id="tbl" var="o" value="#{  outbound.tick_list}"                                paginator="true" rows="10" rowsperpagetemplate="5,10,15"                               rowkey="#{o.accno}" selection="#{outbound.outselected}" selectionmode="single"  >                        <p:ajax event="rowselect" listener="#{outbound.onrowselect}"                                 update=":outcompform:display :outcompform:growl" oncomplete="accdialog.show()"   />                        <p:column headertext="booking date" sortby="#{o.date_conv}">                         <h:outputtext value=" #{o.date_conv.substring(0, 10)}" />                      </p:column>                     <p:column headertext="consignment no" sortby="#{o.accno}">                         <h:outputtext value=" #{o.accno}" />                       </p:column>                     <p:column headertext="con branch" sortby="#{o.cnor_branch}">                         <h:outputtext value=" #{o.cnor_branch}" />                       </p:column >                     <p:column headertext="consignor" sortby="#{o.cnor_name}">                         <h:outputtext value=" #{o.cnor_name}" />                      </p:column>                     <p:column headertext="con contact" sortby="#{o.cnor_contact}">                         <h:outputtext value=" #{o.cnor_contact}" />                      </p:column>                     <p:column headertext="remarks" sortby="#{o.remark}">                         <h:outputtext value=" #{o.remark}" />                      </p:column>                     <p:column headertext="cnee branch" sortby="#{o.cnee_branch}">                         <h:outputtext value=" #{o.cnee_branch}" />                      </p:column>                     <p:column headertext="cnee name" sortby=" #{o.cnee_name}">                         <h:outputtext value=" #{o.cnee_name}" />                      </p:column>                     <p:column headertext="cnee addr" sortby="#{o.cnee_addr}">                         <h:outputtext value=" #{o.cnee_addr}" />                      </p:column>                     <p:column headertext="cnee contact" sortby="#{o.cnee_contact}">                         <h:outputtext value=" #{o.cnee_contact}" />                      </p:column>                   </p:datatable>                    <p:dialog id="dialog" header="complaint details" widgetvar="accdialog" resizable="false" appendtobody="true"                             showeffect="fade" hideeffect="slide">                     <h:panelgrid id="display" columns="2" cellpadding="4">                           <h:form id="formtrans">                             <table border="0"  class="popupbox"  >                                 <tr>                                     <td>consignment no.</td>                                     <td colspan="3"> <h:outputtext value="#{outbound.outselected.accno}" />  </td>                                 </tr>                                 <tr class="formlabel" >                                     <td>detail</td>                                     <td>suggestion</td>                                     <td>privacy</td>                                     <td>status</td>                                 </tr>                                 <tr>                                     <td><h:inputtextarea  id="fdetail" value="#{outbound_trans.details}" onfocus="this.select()" styleclass="formtext"  /></td>                                     <td><h:inputtextarea  id="fsuggest" value="#{outbound_trans.suggest}" onfocus="this.select()" styleclass="formtext"  /></td>                                     <td>                                         <h:selectonemenu value="#{outbound_trans.privacy}" id="fpriv" styleclass="formtext" >                                             <f:selectitems value="#{outbound_trans.privacyli}" var="c" />                                         </h:selectonemenu>                                     </td>                                     <td>                                         <h:selectonemenu value="#{outbound_trans.status}" id="fstatus" styleclass="formtext" >                                             <f:selectitems value="#{outbound_trans.statusli}" var="c" />                                         </h:selectonemenu>                                     </td>                                   </tr>                                 <tr>                                     **<td> <h:commandbutton value="save" action="#{outbound_trans.savetrans}" onclick="return validate1()" /> </td> **                           </tr>                </table>              </h:form>       </h:panelgrid>        </p:dialog> </h:form> 

outbound bean

@managedbean(name = "outbound") @sessionscoped public class outbound implements serializable {  private string database, finyear; private int usercode, cnt = 0, ticketno; private string accno, cnor_branch, cnor_name, cnor_contact, cnee_branch, cnee_name, cnee_addr, cnee_contact, message = "error";  private string cnor_addr, cnor_email, cnee_email, remark; private date booking_date; private int cnee_branchcode, cnor_code; private arraylist cnor_branchli = new arraylist(); private arraylist cnee_branchli = new arraylist(); private arraylist cnor_nameli = new arraylist(); datafetch fetch; dataconnect datapush; facesmessage donemessage = null; resultset rs; private arraylist<outboundb> tick_list; connection con; statement stat; preparedstatement pstat; dbconnection dbconn = new dbconnection(); utility datefetch = new utility(); private outboundb outselected;   public outbound() {     facescontext ctx = facescontext.getcurrentinstance();     httpsession session = (httpsession) ctx.getexternalcontext().getsession(false);     this.database = (string) session.getattribute("database");     this.finyear = (string) session.getattribute("finyear");     this.usercode = (integer) session.getattribute("usercode");      if (this.database == null) {         donemessage = new facesmessage("session expired");     } else {         fetch = new datafetch(this.database);         cnor_branchli = fetch.getarraystring("select subbranchcode subbranch  order subbranchcode");         cnor_nameli = fetch.getarraystring("select firmname accountscustomer flag='acti' order firmname");         cnee_branchli = fetch.getarraystring("select distinct city destinationmaster order city");         addlist();         fetch.closeall();     }   }  public string saveticketout() {     // program save database }  public string saveaction() {     //validation before saving     return null; }    public void onrowselect(selectevent event) {   facesmessage msg = new facesmessage("acc selected", ((outboundb) event.getobject()).getaccno());      facescontext.getcurrentinstance().addmessage(null, msg);   }    public void onrowunselect(unselectevent event) {       facesmessage msg = new facesmessage("acc unselected", ((outboundb) event.getobject()).getaccno());       system.out.println("entered unselect");     facescontext.getcurrentinstance().addmessage(null, msg);   }     public static class outboundb {     private int cnor_branchcode, cnee_branchcode, cnor_code, usercode, ticketno;     private string accno, cnor_branch, cnor_name, cnor_contact, cnee_branch, cnee_name, cnee_addr, cnee_contact,date_conv;     private string cnor_addr, cnor_email, cnee_email, remark, type, escala;     private date booking_date, ticket_date;     utility datefetch1 = new utility();      public outboundb() {     }      public outboundb(string conbran, string connam, string cnocnt, string acno, string cneebran, string cneenam, string cneadd, string cneecnt, date bodate) {         this.accno = acno;         this.cnor_branch = conbran;         this.cnor_name = connam;         this.cnor_contact = cnocnt;         this.cnee_name = cneenam;         this.cnee_branch = cneebran;         this.cnee_addr = cneadd;         this.cnee_contact = cneecnt;         this.date_conv = datefetch1.setcorrectdate(bodate);         this.booking_date = bodate;     }  } } 

// have deleted getter , setter outbound_trans bean

@managedbean(name = "outbound_trans") @sessionscoped public class outboundtrans {  private string database, finyear, username; private int usercode; private string  details, suggest,  privacy, status,message; private arraylist statusli = new arraylist(); private arraylist privacyli = new arraylist(); // datafetch fetch;  connection con; statement stat; preparedstatement pstat; dbconnection dbconn = new dbconnection(); utility datefetch = new utility(); //  public void savetrans( ) {  system.out.println(this.details); if(this.details==null){       system.out.println("save trans");  }else{       system.out.println(this.details);  }   // code validate , save  }  public class outboundtransb {      private int ticketno, responsecount;     private date resp_date;     private string oebrach, debranch, details, suggest, tickettype, flag, privacy;   } } 

after reviewing code have noticed you have nested forms! extremly bad , can create unpredictable behaviour. fix , test again if problem persists.

additional information

if problem ability of retrieving form values suggest looking at:

string value = facescontext.getcurrentinstance().getexternalcontext() .getrequestparametermap().get("myinputfield"); 

inside method being called. should let value method inside form.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -