Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF: h:dataTable vs h:panelGrid

Tags:

java

jsf

In JSF, h:dataTable and h:panelGrid both create html table-tags.

What is the difference between both?

When to use one or the other?

like image 948
Jan Avatar asked Jul 29 '10 23:07

Jan


People also ask

What is panelGrid in JSF?

In JSF , “h:panelGrid” tag is used to generate HTML table tags to place JSF components in rows and columns layout, from left to right, top to bottom.

What is panel grid?

PanelGrid is an extension to the standard panelGrid with theme integration, grouping and responsive features.


1 Answers

As it names indicates h:dataTable is used mostly for displaying a table containing data from some of the models in your application. Here is an usage example.

<h:dataTable value="#{dataTableBean.items}" var="item">
    <h:column>
        <f:facet name="header" >
            <h:outputText value="Item Category"/>
        </f:facet>    
        <h:outputText value="#{item.category}"/>
    </h:column>
</h:dataTable>

The h:panelGrid is used mostly for layout and placing of elements purpose. Here is an usage example.

<h:panelGrid id="panel" columns="2" border="1">
    <h:outputText value="First Name:" />
    <h:inputText id="first" value="#{backingBean.user.firstName}" />
    <h:outputText value="Last Name:" />
    <h:inputText id="last" value="#{backingBean.user.lastName}" />
</h:panelGrid>
like image 71
Jose Diaz Avatar answered Sep 21 '22 14:09

Jose Diaz