1

I'm working on a JSF 2.2 project, jboss 8.x

I created a dynamic form only with selectManyCheckbox.

I have the following code:

<table border="5">
    <ui:repeat var="cat" value="#{beanQuiz.traninigee.questions}">
        <tr>
            <div class="panel-title">
                <i class="fs-14 fa fa-bolt"></i> #{cat.question} :
            </div>
        </tr>
        <tr>
            <h:selectManyCheckbox styleClass="checkbox check-success " value="#{beanQuiz.selectedreponses}"  converter="javax.faces.Integer">
                <f:selectItems  var="xx" value="#{cat.responses}" itemLabel="#{xx.reponse}" itemValue="#{xx.responseId}" />
            </h:selectManyCheckbox>
        </tr>
        <br/><br/>
    </ui:repeat>
</table>

selectedArticles is list of entities.

I found on the web that the value of a selectManyCheckbox can point to a String[] or to a List<String>. With this code selectedArticles donesn't contain all the checked values, only the latest checked group.

What should I do to get all the checked values?

@ManagedBean
@SessionScoped
public class beanQuiz implements Serializable{


    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @EJB
    private trainingServiceLocal local;

    private List<Integer> selectedreponses;

    private List<Training> trainings;

    private Training traninigee=new Training();



public String redirectquiz(int idt){

    traninigee=local.findtrainingbyId(idt);



    return "quiz";
}


    public List<Integer> getSelectedreponses() {
        return selectedreponses;
    }

    public void setSelectedreponses(List<Integer> selectedreponses) {
        this.selectedreponses = selectedreponses;
    }

    public int getInc() {
        return inc;
    }

    public void setInc(int inc) {
        this.inc = inc;
    }


    private int inc;

    public Training getTraninigee() {
        return traninigee;
    }

    public void setTraninigee(Training traninigee) {
        this.traninigee = traninigee;
    }

    @PostConstruct
    public void init() {
        inc=0;
        trainings = local.findAlltrainings();


        //traninigee=local.findtrainingbyId(1);
        //System.out.println("-----||||||||||||----**---"+traninigee);




    }


//  private static Map<String,Object> color2Value;
//  static{
//      color2Value = new LinkedHashMap<String,Object>();
//      for()
//      color2Value.put("Color2 - Red", "Red"); //label, value
//      
//  }





    public List<Training> getTrainings() {
        return trainings;
    }




    public void setTrainings(List<Training> trainings) {
        this.trainings = trainings;
    }

My class diagram is like that: I have a class of trainings that contrains a list of questions (one to many), my class question contains list of reponses (one to many), and my class responses is a simple class that contains the response as string. I'm using jpa.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
tero17
  • 1,570
  • 1
  • 11
  • 20

0 Answers0