As I understand it (this is quite likely to be a facelets centric view ;) )


  | // Your code
  | ...
  |    <h:dataTable value="#{dataModel}" var="row">
  |       <h:column>#{row.col1}</h:column>
  |       <h:column>#{row.col2}</h:column>
  |    </h:dataTable>
  | 
  |    <c:forEach items="#{list}" var="row">
  |       #{row.col1} #{row.col2}
  |    </c:forEach>
  | ...
  | 

When the component tree is created (compile-time) components like dataTable are 
added to the tree without the backing list being read (i.e. a single instance) 
whilst forEach's backing list is evaluated (so if there are x items in the 
c:forEach list then x copies of forEach's children would be added).

i.e. 


  | // After tree compile - pseudo-code (if list has 3 items)
  | ...
  |    <h:dataTable value="#{dataModel}" var="row">
  |       <h:column>#{row.col1}</h:column>
  |       <h:column>#{row.col2}</h:column>
  |    </h:dataTable>
  | 
  |       #{row1.col1} #{row1.col2}
  |       #{row2.col1} #{row2.col2}
  |       #{row3.col1} #{row3.col2}
  | ...
  | 



When the tree is rendered dataTable's DataModel is read and a row for each item 
in the list is written.


  | 
  | // After tree render - pseudo-code  (if dataModel has 3 items)
  | ...
  |       <h:column>#{row1.col1}</h:column><h:column>#{row1.col2}</h:column>
  |       <h:column>#{row2.col1}</h:column><h:column>#{row2.col2}</h:column>
  |       <h:column>#{row3.col1}</h:column><h:column>#{row3.col2}</h:column>
  | 
  |       #{row1.col1} #{row1.col2}
  |       #{row2.col1} #{row2.col2}
  |       #{row3.col1} #{row3.col2}
  | ...
  | 

In essence the component tree will hold an item per child of forEach and an 
item per dataTable - hence why dataTable is a lighter weight pattern.

It didn't work for you as the dataTable's is evaluated AFTER forEach - so the 
'var' items of dataTable aren't created when forEach is evaluated ;)

Peter

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3944142#3944142

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3944142


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to