Hi i know that i can use some facet variables in jsf like this:

<h:dataTable>
    <h:column>
        <f:facet name="header">
            <h:outputText value="Item Description" />
        </f:facet>
        <h:outputText value="#{item.description}" />
    </h:column>
</h:dataTable>

is there any documentation which lists all available facets?

i already looked at the sourcecode of

javax.faces.component.html.HtmlDataTable

but cant find any information of the facets here, where are the defined?

有帮助吗?

解决方案

The facets are available by UIComponent#getFacets().

Do note that you need to obtain the particular one in your code snippet from <h:column> (HtmlColumn; UIColumn), not from <h:dataTable> (HtmlDataTable; UIData).

UIData table = getItSomehow();

for (UIComponent child : table.getChildren()) { // child == UIColumn.
    Map<String, UIComponent> facets = child.getFacets();
    UIComponent headerFacet = facets.get("header");
    // ...
}

By the way, looking in source code is funny, but looking in javadoc is the easiest first step. It also lists the methods inherited from superclasses which are otherwise not directly visible in the class' source. You'd immediately have noticed the self-explaining "getFacets()" method when searching for the word "facets" in the javadoc.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top