jsp - How to add the checkbox value temporary storage and put it in session obj using Struts 2 -


hear checkbox:

<input type="checkbox" value="${subfill.fillingname}"  name="fillings"> ${subfill.fillingname}</input> 

bean class:

public class addcartbean {  public string fillings;      public string getfillings() {         return fillings;     }      public void setfillings(string fillings) {         this.fillings = fillings;         system.out.println("hiii"+fillings);     } } 

action class:

public class cartaction extends actionsupport implements sessionaware,modeldriven<addcartbean>{      addcartbean acb = new addcartbean();       @override     public void setsession(map<string, object> map) {         sessionobj=(sessionmap<string, object>) map;     }      @override     public addcartbean getmodel() {         return acb;     }    public string mycart(){    sessionobj.put("fillings",acb.getfillings());          system.out.println("fillings are....."+acb.getfillings());          return "success";     } 

when first time click checkbox , click submit button checkbox value coming action can store in session , in jsp question when second time click checkbox , click submit button time first submit checkbox value gone , new check box value coming, how can first submit check box value , second submit checkbox value?

the value of s:checkbox tag when submitted set boolean true default. can change providing fieldvalue attribute of s:checkbox tag.

see example s:checkbox:

in struts 2 , can use <s:checkbox> tag create html check box. fieldvalue=”true” actual value submitted check box.

<s:checkbox name="checkme" fieldvalue="true" label="check me testing"/> 

Comments