I'm using <h:dataTable> to iterate over a List that contains Strings and a
HashSet.  I've not been able how to figure out how to iterate over the Set
within the List.  What I want to do is for each row in the List (of
ItemMaster objects) show the data items at the root (stockNumber, model,
description) in their respective columns.  Then iterate over the HashSet (of
ItemDetail objects) continuing on the same row.  So on each row of the
table, there would be columns for stockNumber, model, and description, and
ALSO columns for the pertinent data fields within the details Set (e.g.,
catalogNumber, retailPrice).  The JSP code below is working fine - I can see
the Strings just fine in my table.  My question is, how do I loop through
the Set within the List, showing those items on the same row?  If the answer
is "don't use a Set, use a List", that's fine too, however, I still have the
same question.  Would I use a h:dataTable within a h:dataTable?  I've tried
this without any success.  Is dataTable the correct control to use here?
I've used Struts for years, and I know how I'd do this with the Struts
<logic:iterate> tags. I'm just not sure how to do this using MyFaces.

 

Thanks in advance,

Brennan

 

 

ItemBean.java:

List<ItemMaster> items;

(with getter method for items, of course)

 

 

ItemMaster.java:

String stockNumber;

String model;

String description;

Set<ItemDetail> details = new HashSet<ItemDetail>;

(with getter methods)

 

 

ItemDetail.java:

String catalogNumber;

BigDecimal retailPrice = BigDecimal.ZERO;

(with getter methods)

 

 

itemList.jsp: (works fine with what is shown.  How do I show the data fields
in the 'details' Set here?)

<h:dataTable value="#{itemBean.items}" var="item">

     <h:column>

           <f:facet name="header">

                <h:outputText value="Stock Number"/>

           </f:facet>

           <h:outputText value="#{item.stockNumber}"/>

     </h:column>

     <h:column>

           <f:facet name="header">

                <h:outputText value="Model"/>

           </f:facet>

           <h:outputText value="#{item.model}"/>

     </h:column>

     <h:column>

           <f:facet name="header">

                <h:outputText value="Description"/>

           </f:facet>

           <h:outputText value="#{item.description}"/>

     </h:column>

     <%-- Would like columns here with data items in the 'details' Set --%>

<h:dataTable>

 

 

 

 

Reply via email to