mercredi 28 juin 2017

Struts2 Multiple CheckBox inside a Form Get Value Checked

Good morning:

I am having so many problems with my java-jsp trying to get the values of the checkbox in a jsp to java.

There are dynamic checkboxes due to the number of reports there are on the data base.

Mi jsp is

<s:checkbox name="reportFactured<s:property value='id'/>" id="reportFactured" fieldValue="reportFactured<s:property value='id'/>" label="Factured" theme="simple"/>

I am trying to recover variables like "reportFactured3" or "reportFactured9", depends on which one are checked or not.

My .Java is:

import org.apache.struts2.interceptor.SessionAware;

public class PostIntroducirFacturaInforme extends ActionSupport implements SessionAware {

private ArrayList arrayFacturedReport = new ArrayList();

public String execute() throws Exception
{

    for(int i=0; i <= 100; i++)
    {
        arrayFacturedReport (i);

        System.out.println("FACTURED REPORT " + i + " == " + arrayFacturedReport.get(i).toString());
    }

    return "success";
}

//Getters y Setters

public ArrayList<Boolean> arrayFacturedReport () {
    return arrayFacturedReport ;
}

public void setArrayFacturedReport (ArrayList<Boolean> arrayFacturedReport ) {
    this.arrayFacturedReport = arrayFacturedReport ;
}   }

But the results are all false:

FACTURED REPORT 1 == false
FACTURED REPORT 2 == false
FACTURED REPORT 3 == false
FACTURED REPORT 4 == false
FACTURED REPORT 5 == false
FACTURED REPORT 6 == false
FACTURED REPORT 7 == false

I tried different methods but all do the same.

Does anybody know how can I get the different values on the jsp (i am not sure if is ok, and recover them on JAVA?

Thanks.




Aucun commentaire:

Enregistrer un commentaire