java - getting value from other class -


i want id number user use log in display data related user id, if make sense. code index bean(index.java), getting id simple inputtext:

    private string id;      public string getid() {     return id; }  public void setid(string id) {     this.id = id; } 

and code user it(class table)

public class table {     index = new index();     final string pno=i.getid(); public list<index> getmylist() {      list<index> list = new arraylist<index>();      preparedstatement pstmt = null;      connection con = null;      resultset rs = null;      try      {         class.forname("com.mysql.jdbc.driver");         con = drivermanager.getconnection("jdbc:mysql://localhost:3306/try", "root", "");          string sql = "select task.tno, clientcase.name "+         "from clientcase join task on clientcase.cno = task.cno "+         "where task.responsiblepno = ? , (task.statue='opened'or task.statue= 'pending')";         pstmt= con.preparestatement(sql);          pstmt.setstring(1, pno);         rs= pstmt.executequery();          while (rs.next())         {              i.settno(rs.getstring("task.tno"));             i.setcompanyname(rs.getstring("clientcase.name"));              list.add(i);             }          }         catch(exception e)         {} 

i have jsf page haveing code id, if make sense:

     <h:inputtext id="personnelid" value ="#{index.id}"/> 

my problem can id number. if replace method in table class real number, works fine. returns null. can me?

the code

index = new index(); final string pno=i.getid(); 

is being run when table first created, , presumably sets pno null. after that, can't change in way. want constructor table allows set pno, can pass in value field.


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -