JSF - Select Item of a Set

1

I want to make an xhtml that returns a list of users and on the side a button will appear to select a certain user. Something like this:

+ ---------------------------- +
| ID | User | (Button)

+ ---------------------------- +

My question is: How do I loop a repeat in xhtml to build the page with all the objs that are inside the set and what is the best way to make the button reference the respective object of its line.

If anyone can help me. Thank you in advance.

    
asked by anonymous 03.05.2016 / 07:30

3 answers

1

Jhow,

As James said above, you can use the PrimeFaces dataTable or you can also use the JSF dataTable. Here's an example below.

Let's have in your class "@ManagedBean (" user ")" a list of the object you want to insert into the table.

    private List<Usuario> usuario = new ArrayList<Usuario>();

   <h:dataTable value="#{usuario.usuario}" var="u">

                <h:column>
                    <f:facet name="header">Order No</f:facet>
                    #{u.id}
                </h:column>

                <h:column>
                    <f:facet name="header">Product Name</f:facet>
                    #{u.nome}
                </h:column>

                <h:column>
                    <f:facet name="header">Price</f:facet>
                    #{u.sexo}
                </h:column>

                <h:column>
                    <f:facet name="header">Quantity</f:facet>
                    <h:commandButton value="submit" type="submit" action="#{usuario.fazAlgumaCoisa(u)}" />
                </h:column>

    </h:dataTable>

Following is a reference link. link

    
03.05.2016 / 13:42
1

Datatable is what most uses link

    
03.05.2016 / 10:10
1

Try

<p:panelGrid columns="3"> .... </p:panelGrid>

The p: is primefaces but works with pure JFS as well.

    
03.05.2016 / 13:30