java - passing values from one jsf page to another through managed bean -


i need pass value(studentid) jsf view(list.xhtml) jsf page (editor.xhtml) via managed bean (bean.java). can values in bean page not access in editor . can please tell me went wrong ? hope hear suggestions

list.xhtml

    <h:datatable  value="#{student.createlist()}" var="student" styleclass="studenttable"                          columnclasses=",,,fixedwidth" border="1" cellspacing="2" cellpadding="2">                 <h:column>                     <f:facet name="header">student id</f:facet>                     <h:outputtext value="#{student.studentid}"></h:outputtext>                 </h:column>            <h:column>                 <f:facet name="header">name</f:facet>                 <h:outputtext value="#{student.fname}"></h:outputtext>             </h:column>                  <h:column>                     <f:facet name="header">surname</f:facet>                     <h:outputtext value="#{student.lname}"></h:outputtext>                 </h:column>   <h:commandlink  actionlistener="#{student.edit()}" value ="editt">                              <f:param name="id" value="#{student.studentid}"/>                           </h:commandlink> 

editor.xhtml

<h:panelgrid border="" cellpadding="20" cellspacing="20" columns="3">                         <h:outputlabel value="student id" />                         <h:inputtext value="#{student.studentid}" readonly="true" required="true" requiredmessage="id required" id="eid">                         </h:inputtext> <h:message for="eid"/>                          <h:outputlabel value="student name" />                         <h:inputtext value="#{student.fname}" required="true" requiredmessage="name required" id="ename">                          </h:inputtext> <h:message for="ename"/>                         <h:outputlabel value="student age" />                             <h:inputtext value="#{student.lname}" required="true" requiredmessage="age required" id="eage">   <h:commandlink value="update" action="userrecords" actionlistener="#{student.update()}">                          </h:commandlink> 

student.java

public void edit(){      system.out.println("called edit()"+ this.studentid);          list<student> arrlist = createlist();          facescontext fc = facescontext.getcurrentinstance(); mapparam=fc.getexternalcontext().getinitparametermap();          string idstudent;         httpservletrequest request = (httpservletrequest) fc.getexternalcontext().getrequest();           (student studentmanagedbean : arrlist) {             if (studentmanagedbean.getstudentid() == idstudent) {                 this.setstudentid(studentmanagedbean.getstudentid());//error                 this.setfname(studentmanagedbean.getfname());                 this.setlname(studentmanagedbean.getlname());              } system.out.println(" have "+ this.getstudentid() + this.getfname() );         }    } 
 public void update() {          connection conn=null;       try{             class.forname("org.apache.derby.jdbc.clientdriver");          conn = drivermanager.getconnection("jdbc:derby://localhost:1527/xx","xx","xxx");       }catch(exception e){        }        string str = "update student set fname=?,lname=? studentid=?";         facescontext fc = facescontext.getcurrentinstance();         httpservletrequest request = (httpservletrequest) fc.getexternalcontext().getrequest();          int  idstudent = integer.parseint(request.getparameter("id"));         try {             preparedstatement pstmt = conn.preparestatement(str);             pstmt.setstring(1, this.getfname());             pstmt.setstring(2, this.getlname());             pstmt.setint(3, idstudent); //            system.out.println("id student update :" + idstudent);//error             int executeupdate = pstmt.executeupdate();             if (executeupdate > 0) {                 system.out.println("update successfully");              }         } catch (sqlexception ex) {             logger.getlogger(student.class.getname()).log(level.severe, null, ex);         } {          } 


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -