Uderc programming article aggregator sites

Component.getChilderen() does not include facelet tags

Tags:
Answers: Have 2 answers
Advertisement
Hi,
I’m writing a function to export a dataTable to excel.
Everything works fine! Except when my UIColumn has facelet tags inside.
for (int nr = uiData.getFirst(); nr < uiData.getRowCount(); nr++) {
     List<UIComponent> children = abstractTableComponent.getChildren();
     xls.append("<tr>");
     for(UIComponent child : children){
          xls.append("<td>");
          xls.append(renderChild(new StringBuilder(), child));
          xls.append("</td>");
     xls.append("</tr>");
public StringBuilder renderChild(StringBuilder builder, UIComponent component){
     builder.append(component.getAttributes().get("value"));
     if(component.getChildren() != null){
          for(UIComponent child : component.getChildren()){
               renderChild(builder, child);
     return builder;
}Example 1:
<h:column>
<f:facet name=”header”>
email
</f:facet>
<h:outputText value=”#{e.person.email}” />
</h:column>     
Result: <table><tr><td>[email protected]</td></tr></table>
Example 2:
<h:column>
<f:facet name=”header”>
email
</f:facet>
#{e.person.email}
</h:column>     
Result: <table><tr><td></td></tr></table>
#{e.person.email} is not converted a a component, so it doesn’t have a value.
My question is how to get the value of a Facelets component.
Thanks in advance,
Pieter
Edited by: Pieter_Pareit on Apr 19, 2010 5:34 AM
Advertisement
The best answer: I wouldn't call this a "Facelets Component", after all the issue is that it is not a component.
My advice would be if you want to ensure that everything is available for manipulation via the component tree you ought to make sure everything is a component. You could make this a component by surrounding it with ui:component or ui:fragment or the like.