0
votes

I've got a datatable in a .xhtml page, that shows products of a database. Let's say that I can only see Name and Code for every row, how can I show more detail of the product in the same page?

Moreover, my product bean is in ViewScope, so i'm not able to show details in another .xhtml page (I've tried many times, but if in case you guys have a solution for this, that's good).

PS: I don't know anything about Javascript yet, so i'd prefer mostly solutions based on jsf and java :)

1

1 Answers

0
votes

You mean that you want to display more fields at datatable? Add more columns..

<h:dataTable value="#{pr.products}" var="p">
                <h:column>
                    <f:facet name="header">Name</f:facet>
                    #{p.name}
                </h:column>

                <h:column>
                    <f:facet name="header">Code</f:facet>
                    #{p.code}
                </h:column>

                <h:column>
                    <f:facet name="header">Price</f:facet>
                    #{p.price}
                </h:column>
                ........
</h:dataTable>

JSF example: http://www.mkyong.com/jsf2/jsf-2-datatable-example/

If you using primefaces see showcase: http://www.primefaces.org/showcase/ui/data/datatable/basic.xhtml

EDIT If you want to make a dialog that shows the details of the selected product see at primefaces showcase the "selection" example.