database - How to hold data when page is reloading in jsp struts2 -
i have loading data database arraylist
. use data updating process. search , load data arraylist
. code load data when searching.
system.out.println("in search job method"); region ="test"; pcinitialdataejb pcinejb=new pcinitialdataejb(region); pcinitiladatalist = new arraylist<pcinitialdata>(); system.out.println(hiddentableradiobuttonvalue+"**************************************************************************"); if(idsearchtype.equalsignorecase("comref")) { pcinitiladatalist=pcinejb.getdataforestnumber("510.00/ebs/12/0031","commercial"); system.out.println(idsearchtype); } else if(idsearchtype.equalsignorecase("constructref")) { pcinitiladatalist=pcinejb.getdataforestnumber("510.00/ebs/12/0031","customerref"); } else if(idsearchtype.equalsignorecase("projjobno")) { pcinitiladatalist=pcinejb.getdataforestnumber("510.00/ebs/12/0031","projnojobno"); } pcinitialdata aa=new pcinitialdata(); aa.setdecrp("doorwerfxcv"); pcinitiladatalist.add(aa); system.out.println(pcinitiladatalist.tostring()); for(int = 0; < pcinitiladatalist.size(); i++) { if(i==0) system.out.print(pcinitiladatalist.get(i)); if(i==1) system.out.print((string)pcinitiladatalist.get(i).getdecrp()); }
this code works perfectly. problem after load data jsp table use radio button select raw. click load button load data interface. problem when click load button, pcinitialdata list became null. code load button click.
public string loadvaluesforpage() { if(pcinitiladatalist.equals(null)) { string resrult=searchjob(); } for(int = 0; < pcinitiladatalist.size(); i++) { if((hiddentableradiobuttonvalue.equalsignorecase(pcinitiladatalist.get(i).getestno()))) { pcinitialdata estnoobject=new pcinitialdata(); estnoobject=pcinitiladatalist.get(i); fileno=estnoobject.getestno(); } } return success; }
how can hold data until finish update process??
when click update button, arraylist became null. there way hold data until finish update process. can use hoshmap this??
simple! store data session, , after updation completed remove data session.
in example storing arraylist name myarraylist
session key name holdarrylist
if ( !session.containskey(holdarrylist) ) { // place arraylist session eg. myarraylist session.put(myarraylist, holdarrylist); //myarraylist arraylist ato kept in session name holdarrylist } else { arraylist<integer> list = (arraylist<integer>) session.get("holdarrylist"); list.add( 1 /* here ever want */); // retrieve session data -------------- //--do updation work---- //after remove arraylist session //session.remove("holdarrylist"); }
Comments
Post a Comment