JSF 2 + RichFaces - 在托管 bean 中设置变量的问题

发布于 2024-12-05 07:55:05 字数 2533 浏览 0 评论 0原文

我有以下代码,每行上的 commandLink 应将 username 传递给 bean,但它传递 null。这是为什么? DataProviderBeanSessionScoped

<h:form>
    <rich:dataTable value="#{dataProviderBean.profileStats}" var="item"
        id="statsTable">
        <f:facet name="noData">No stats are available.</f:facet>
        <rich:column filterValue="#{filteringBean.usernameFilter}"
            filterExpression="#{fn:containsIgnoreCase(item.profile.username, filteringBean.usernameFilter)}">
            <f:facet name="header">
                <h:outputText value="Profile" />
                <br />
                <h:inputText value="#{filteringBean.usernameFilter}">
                    <a4j:ajax event="keyup" render="statsTable@body" execute="@this" />
                </h:inputText>
            </f:facet>
            #{item.profile.username}
        </rich:column>
        <rich:column>
            <f:facet name="header">AO Messages Count</f:facet>
                #{item.aoMessagesCount}
        </rich:column>
        <rich:column>
            <f:facet name="header">MO Messages Count</f:facet>
            #{item.moMessagesCount}
        </rich:column>
        <rich:column>
            <f:facet name="header">Administration</f:facet>
            <a4j:commandLink execute="@this" render="@none"
                oncomplete="#{rich:component('confirmPane')}.show()">
                <h:graphicImage url="./resources/images/delete.png" alt="Delete" />
                <a4j:param value="#{item.profile.username}"
                    assignTo="#{deleteStatsBean.username}" />
            </a4j:commandLink>
        </rich:column>
    </rich:dataTable>

    <a4j:jsFunction name="remove" action="#{deleteStatsBean.delete}"
        render="statsTable" execute="@this"
        oncomplete="#{rich:component('confirmPane')}.hide();" />

    <rich:popupPanel id="confirmPane" autosized="true">
        <h:outputText value="Are you sure you want to delete the profile statistics?" />
        <br />
        <a4j:commandButton value="Delete" onclick="remove(); return false;" />
        <a4j:commandButton value="Cancel"
            onclick="#{rich:component('confirmPane')}.hide(); return false;" />
    </rich:popupPanel>
</h:form>

I have the following code and the commandLink on each row should pass username to the bean but it passes null. Why is that? The DataProviderBean is SessionScoped.

<h:form>
    <rich:dataTable value="#{dataProviderBean.profileStats}" var="item"
        id="statsTable">
        <f:facet name="noData">No stats are available.</f:facet>
        <rich:column filterValue="#{filteringBean.usernameFilter}"
            filterExpression="#{fn:containsIgnoreCase(item.profile.username, filteringBean.usernameFilter)}">
            <f:facet name="header">
                <h:outputText value="Profile" />
                <br />
                <h:inputText value="#{filteringBean.usernameFilter}">
                    <a4j:ajax event="keyup" render="statsTable@body" execute="@this" />
                </h:inputText>
            </f:facet>
            #{item.profile.username}
        </rich:column>
        <rich:column>
            <f:facet name="header">AO Messages Count</f:facet>
                #{item.aoMessagesCount}
        </rich:column>
        <rich:column>
            <f:facet name="header">MO Messages Count</f:facet>
            #{item.moMessagesCount}
        </rich:column>
        <rich:column>
            <f:facet name="header">Administration</f:facet>
            <a4j:commandLink execute="@this" render="@none"
                oncomplete="#{rich:component('confirmPane')}.show()">
                <h:graphicImage url="./resources/images/delete.png" alt="Delete" />
                <a4j:param value="#{item.profile.username}"
                    assignTo="#{deleteStatsBean.username}" />
            </a4j:commandLink>
        </rich:column>
    </rich:dataTable>

    <a4j:jsFunction name="remove" action="#{deleteStatsBean.delete}"
        render="statsTable" execute="@this"
        oncomplete="#{rich:component('confirmPane')}.hide();" />

    <rich:popupPanel id="confirmPane" autosized="true">
        <h:outputText value="Are you sure you want to delete the profile statistics?" />
        <br />
        <a4j:commandButton value="Delete" onclick="remove(); return false;" />
        <a4j:commandButton value="Cancel"
            onclick="#{rich:component('confirmPane')}.hide(); return false;" />
    </rich:popupPanel>
</h:form>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文