0

I have an <ui:repeat> in which I has a list of object , next to each of those object I need to have a checkbox ( to check this element). I want to know how could I integrate those checkboxes inside the <ui:repeat> in order to have many rows and each rows needs to has the object.getName() and next to it I need to have the checkbox ?

If this is feasible, Please how could I obtain those checked objects in the backing bean ?

 <ui:repeat var="myObject" varStatus="status"
                value="#{Bean.getListObjects}">
            <b>#{status.index+1} .</b>
            <h:outputLabel value="#{myObject.name}" />

             //need the checkbox here for example

  </ui:repeat>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
majdi_ach
  • 13
  • 5
  • 1
    Just create a map with the object UID as the key and a boolean as the value. Then value-bind each checkbox to a map entry (`value="#{map[object.id]}"`). – Jasper de Vries Feb 08 '18 at 10:12

1 Answers1

1

Just create a map with the object UID as the key and a boolean as the value. Then value-bind each checkbox to a map entry.

Assuming your names are unique, you could use them. So, in you bean create a Map<String,Boolean>, and initialize the map with each object.

You can use the map to in the checkbox value like value="#{bean.map[object.name]}".

See also:

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102