Reputation: 660
i want to present one shopping cart in index i want to show 3 column and 5 row for each category Example
Books
|| Books A || Books B || Books C
||============||===============||=========
|| Books D || Books E || Books F
||============||===============||=========
|| Books G || Books H || Books I
Video
|| Video A || Video B || Video C
||============||===============||=========
|| Video D || Video E || Video F
||============||===============||=========
|| Video G || Video H || Video I
How can i do it like my example ?
Upvotes: 0
Views: 1733
Reputation: 15770
If you use JSF2.0 and Facelets, you could use <ui:repeat>
and <h:dataTable>
tags. Make your bean return items grouped in categories. In categories, keep list of items rows. Row is just an array (could be list too).
@ManagedBean
public class Cart {
List<CategoryItems> getItemsGroupedInCategories() {
//get items here
}
}
public class CategoryItems {
private String categoryName;
private List<Item[]> itemsRows;
//constructors, getters/setters
}
Then in JSF XHTML you put:
<ui:repeat value="#{cart.itemsGroupedInCategories}" var="categoryItems">
<h:dataTable value="#{categoryItems.itemsRows}" var="row" >
<f:facet name="header">
<h:outputText value="#{categoryItems.categoryName}" />
</f:facet>
<h:column>
<h:outputText value="#{row[0]}" />
</h:column>
<h:column>
<h:outputText value="#{row[1]}" />
</h:column>
<h:column>
<h:outputText value="#{row[2]}" />
</h:column>
</h:dataTable>
</ui:repeat>
Upvotes: 1