Using a Java EE Bean to Save a List of Form Data and print out data in a JSF XHTML DataTable -


here how application works.

1.user fills out "voter registration" xhtml form.

2.when user clicks submit, values saved through using sessionscoped cdi java-ee file.

here contents of file:

import java.io.serializable; import javax.enterprise.context.sessionscoped; import javax.inject.named;  @named @sessionscoped public class voterbean implements serializable{     private string firstname;     private string lastname;     private string address;  private string city;  private string state;  private string zip;     private string phone;     private string affil;      public voterbean(){      }      public string getfirstname(){         return firstname;     }      public string getlastname(){         return lastname;     }      public string getaddress(){         return address;     }   public string getcity(){         return city;     }   public string getstate(){         return state;     }   public string getzip(){         return zip;     }       public string getphone(){         return phone;     }      public string getaffil(){         return affil;     }      public void setfirstname(string firstname){         this.firstname = firstname;     }      public void setlastname(string lastname){         this.lastname = lastname;     }      public void setaddress(string address){         this.address = address;     }     public void setcity(string city){         this.city = city;     }    public void setstate(string state){         this.state = state;     }    public void setzip(string zip){         this.zip = zip;     }         public void setphone(string phone){         this.phone = phone;     }      public void setaffil(string affil){         this.affil = affil;     }   } 

3.the user given summary of values he/she filled in. user asked if values ok or not. if user clicks "no" user taken registraiton form able change his/her values.

now problem when click "yes".

i have 2 issues:

issue #1:

i want create bean file after user clicks "yes" form information saved list. if multiple people finish registration process there should multiple lists information.

i think grab information stored in java-ee bean file above , transport java ee file create lists. question how make list of information , keep saved?

issue #2

after user clicks "yes", he/she taken page should show information in jsf xhtml datatable.

from read jsf files insantiate datable in jsf xhtml goes this

<h:datatable value="#{order.orderlist}" var="o" styleclass="order-table" headerclass="order-table-header" rowclasses="order-table-odd-row,order-table-even-row">  </h:datatable> 

assuming had java-ee file called "order" , list variable called "orderlist" data table values in list varable , print each of different lists in separate rows?

any tips helpful.

i suggest that, use alternative way store registration informations of each person, through independant bean called person.java, instanciate in managed bean. new bean contain registration informations you're putting in managed bean. way, you'd not use list except displaying purpose :

public class person implements serializable {      private string firstname;     private string lastname;     private string address;     private string city;     private string state;     private string zip;     private string phone;     private string affil;      public person(){ }      // getters/setters  } 

now, 1 managed bean enough stuff, should in end :

import java.io.serializable; import javax.enterprise.context.sessionscoped; import javax.inject.named;  @named @sessionscoped public class voterbean implements serializable{       private person person = new person();      private list<person> personslist = new arraylist<person>();       public voterbean(){      }       public list<person> getpersonslist() {           return personslist;      }       public string saveregistration(){          personslist.add(person);          return "registrationslist";  // navigation registration list page after each complete registration process (click save button)      }  } 

in display page, call list :

<h:datatable value="#{voterbean.personslist}" var="p" ... >     ... </h:datatable> 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -