mardi 21 juillet 2015

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

Hear is my 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 i click checkbox and click submit button the checkbox value is coming to my action i can store it in to session and get it in my jsp but my question is that when second time i click another checkbox and click the submit button that time my first submit checkbox value will gone and new check box value is coming how can i get the first submit check box value and second submit checkbox value




Aucun commentaire:

Enregistrer un commentaire