Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 显示嵌套的datatable而不重复原始数据_Jsf_Richfaces - Fatal编程技术网

Jsf 显示嵌套的datatable而不重复原始数据

Jsf 显示嵌套的datatable而不重复原始数据,jsf,richfaces,Jsf,Richfaces,我想显示数据库中的数据,但不能重复相同的配置文件,只需在现有配置文件中添加一个位置。通过上述示例,您可以清楚地看到: +-------------------+---------------+---------------+ | PROFILE | LOCATION | STATUS | +-------------------+---------------+---------------+ +-------------------+--------

我想显示数据库中的数据,但不能重复相同的配置文件,只需在现有配置文件中添加一个位置。通过上述示例,您可以清楚地看到:

+-------------------+---------------+---------------+
|   PROFILE         |   LOCATION    |   STATUS      |
+-------------------+---------------+---------------+
+-------------------+---------------+---------------+
|   Admin           |   Chief       |   OK          |
+-------------------+---------------+---------------+
|   Director        |   Supervision |   OK          |
+-------------------+---------------+---------------+
|   Secretary       |   Supervision |   OK          |
+-------------------+---------------+---------------+
|                   |   Admin       |   OK          |
|                   |   Chief       |   OK          |
|   Chief-accessor  |   Director    |   OK          |
|                   |   Secretary   |   OK          |
|                   |   Supervision |   OK          |
+-------------------+---------------+---------------+
这段代码是我的数据表,我只能重复它们,但我不能对它们进行分组:

<rich:panel header="User location info" style="margin: 20px 0 !important;">
    <h:dataTable id="userLocationList"
        value="#{userLocation.list()}" var="row"
        styleClass="rich-table"
        headerClass="rich-table-subheader rich-table-subheadercell rich-table-thead"
        rowClasses="rich-table-row"
        columnClasses="rich-table-cell,rich-table-cell,rich-table-cell">
        <h:column>
            <f:facet name="header">
                <h:outputText value="Profile" />
            </f:facet>
            <center>
                <h:outputText value="#{row.profile}" />
            </center>
        </h:column>
        <h:column>
            <f:facet name="header">
                <h:outputText value="Location" />
            </f:facet>
            <h:outputText value="#{row.location}" />
        </h:column>
        <h:column>
            <f:facet name="header">
                <h:outputText value="Status" />
            </f:facet>
            <center>
                <h:outputText value="#{row.profile.status ? 'OK' : 'Inactive'}" />
            </center>
        </h:column>
    </h:dataTable>
</rich:panel>
来自
UserLocation
的方法
list()
只是
表用户位置中的
选择

从UserLocation userLoc中选择userLoc,其中userLoc.user.id=:userId

我尝试按照StackOverflow中的一些回答,将一个数据表放在另一个数据表中,但我可以重复没有组配置文件的所有位置,例如:

+-------------------+---------------+---------------+
|   PROFILE         |   LOCATION    |   STATUS      |
+-------------------+---------------+---------------+
+-------------------+---------------+---------------+
|                   |   Chief       |               |
|                   |   Supervision |               |
|                   |   Supervision |               |
|                   |   Admin       |               |
|   Admin           |   Chief       |   OK          |
|                   |   Director    |               |
|                   |   Secretary   |               |
|                   |   Supervision |               |
+-------------------+---------------+---------------+
|                   |   Chief       |               |
|                   |   Supervision |               |
|                   |   Supervision |               |
|                   |   Admin       |               |
|   Director        |   Chief       |   OK          |
|                   |   Director    |               |
|                   |   Secretary   |               |
|                   |   Supervision |               |
+-------------------+---------------+---------------+
|                   |   Chief       |               |
|                   |   Supervision |               |
|                   |   Supervision |               |
|                   |   Admin       |               |
|   Secretary       |   Chief       |   OK          |
|                   |   Director    |               |
|                   |   Secretary   |               |
|                   |   Supervision |               |
+-------------------+---------------+---------------+
|                   |   Chief       |               |
|                   |   Supervision |               |
|                   |   Supervision |               |
|                   |   Admin       |               |
|   Chief-accessor  |   Chief       |   OK          |
|                   |   Director    |               |
|                   |   Secretary   |               |
|                   |   Supervision |               |
+-------------------+---------------+---------------+
|                   |   Chief       |               |
|                   |   Supervision |               |
|                   |   Supervision |               |
|                   |   Admin       |               |
|   Chief-accessor  |   Chief       |   OK          |
|                   |   Director    |               |
|                   |   Secretary   |               |
|                   |   Supervision |               |
+-------------------+---------------+---------------+
And so it goes...
我怀疑的是我正在进行的一般查询,因此表中的重复内容。有人对这次手术有什么想法吗

有关问题:


由于我无法用它们返回同一配置文件的所有位置的方式,并且只使用一个查询,所以我决定采用不同的方式,我考虑使用两个查询,一个用于所有不重复配置文件的查询(
选择distinct…
),另一个用于根据配置文件的每个位置。仅实现了属性
h:datatable
按列而不是按行呈现(如果我错了请更正)。因此,在某种程度上,第一个profile列返回all而不重复profiles,但是每个单元格中的位置都是相同的,如果该位置将显示的单元格是给定的概要文件,则会显示所有用户位置而不加区别。那时我意识到我非常关注那些关注用户档案的地方

运行
select distinct
配置文件并创建一个方法来返回创建表时配置文件的位置。正如报告的问题一样,一个
datatable
在另一个
datatable

终于得到了我的密码:

<rich:panel header="Informations" style="margin: 20px 0 !important;">
    <h:dataTable id="userLocationList"
        value="#{userLocation.list()}" var="row"
        styleClass="rich-table"
        headerClass="rich-table-subheader rich-table-subheadercell rich-table-thead"
        rowClasses="rich-table-row"
        columnClasses="rich-table-cell,rich-table-cell,rich-table-cell">
        <h:column>
            <f:facet name="header">
                <h:outputText value="Profile" />
            </f:facet>
            <center>
                <h:outputText value="#{row.name}" />
            </center>
        </h:column>
        <h:column>
            <f:facet name="header">
                <h:outputText value="Localizations" />
            </f:facet>
                <h:dataTable id="uLoc" var="c" 
                value="#{home.getLocByProfile(row.idProfile)}">
                    <h:column>
                        <h:outputText value="#{c}" />
                    </h:column>
                </h:dataTable>
        </h:column>
        <h:column>
            <f:facet name="header">
                <h:outputText value="Status" />
            </f:facet>
            <center>
                <h:outputText value="#{row.active ? 'OK' : 'Inactive'}" />
            </center>
        </h:column>
    </h:dataTable>
</rich:panel>

<rich:panel header="Informations" style="margin: 20px 0 !important;">
    <h:dataTable id="userLocationList"
        value="#{userLocation.list()}" var="row"
        styleClass="rich-table"
        headerClass="rich-table-subheader rich-table-subheadercell rich-table-thead"
        rowClasses="rich-table-row"
        columnClasses="rich-table-cell,rich-table-cell,rich-table-cell">
        <h:column>
            <f:facet name="header">
                <h:outputText value="Profile" />
            </f:facet>
            <center>
                <h:outputText value="#{row.name}" />
            </center>
        </h:column>
        <h:column>
            <f:facet name="header">
                <h:outputText value="Localizations" />
            </f:facet>
                <h:dataTable id="uLoc" var="c" 
                value="#{home.getLocByProfile(row.idProfile)}">
                    <h:column>
                        <h:outputText value="#{c}" />
                    </h:column>
                </h:dataTable>
        </h:column>
        <h:column>
            <f:facet name="header">
                <h:outputText value="Status" />
            </f:facet>
            <center>
                <h:outputText value="#{row.active ? 'OK' : 'Inactive'}" />
            </center>
        </h:column>
    </h:dataTable>
</rich:panel>