users@javaserverfaces.java.net

Re: dataTable of map

From: Thufir <hawat.thufir_at_gmail.com>
Date: Fri, 16 Apr 2010 22:18:26 +0000 (UTC)

Raymond DeCampo <ray@...> writes:

>
>
> If you use an array as the value in a <h:dataTable> it will use ArrayDataModel
> transparently as the DataModel implementation.

In the facelet you still need to specify rows and columns, right? Can't you
pass meta-data describing the table?




<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <body>
        <ui:composition>
            <h:column>
                #{database.list}
                <f:view>
                    <h:form>
                        <h:dataTable id="Products"
                                     var="myProduct"
                                     value="#{database.list}"
                                     headerClass="topRow"
                                     summary="This table visually organizes
product information and is used for layout only"/>
                            <h:column>
                                <f:verbatim><caption>Products
displayed</caption></f:verbatim>
                            </h:column>
                            <h:column>
                                <f:facet name="header"><h:outputText
value="Name" /></f:facet>
                                <h:outputText id="text1" value="#{database.name}" />
                            </h:column>
                            <h:column>
                                <f:facet name="header"><h:outputText
value="Number" /></f:facet>
                                <h:outputText id="text2"
value="#{database.number}" />
                            </h:column>

                    </h:form>
                </f:view>
            </h:column>
        </ui:composition>
    </body>
</html>