p:pdataTable/p:dataGrid/ui:repeat 内的 p:commandButton 不调用方法

发布于 2025-01-06 01:46:33 字数 2292 浏览 0 评论 0原文

我在 Glassfish 3.1.1 上使用 Primefaces 3.1、JSF 2.1.6。

我有很多可以正常工作的命令按钮,但这个却不能,我不明白为什么。 javascript 警报会触发,但控制器方法从未被调用。

请注意,第一个命令按钮可以完美触发(“过滤器”按钮),但数据表内的编辑按钮不会触发。我尝试了 ui:repeat 而不是 dataGrid,但这给出了相同的效果/问题。 我有很多其他带有命令按钮的数据表,但它们都工作正常......奇怪。

<h:form id="memberships" prependId="false">
        <h:panelGrid columns="3">
            <h:outputLabel value="Filter on EPS" />
            <p:selectOneMenu value="#{epsMembershipViewController.selectedEps}"
                style="width:200px" effect="fold" editable="false" id="selectEps">
                <f:selectItem itemLabel="Select One" itemValue="" />
                <f:selectItems value="#{epsMembershipViewController.allEps}" />
            </p:selectOneMenu>
            <p:commandButton value="Filter"
                action="#{epsMembershipViewController.repopulateView}" ajax="false" />
        </h:panelGrid>
        <br />

        <p:dataGrid var="eps" value="#{epsMembershipViewController.ldapEpss}"
            columns="1">

            <h:outputLabel value="#{eps}"
                style="font-weight: bold;font-size: 14px;" />

            <p:dataTable var="ldapUser" id="id_#{eps}"
                value="#{epsMembershipViewController.getUsersByEpsFromLdap(eps)}"
                paginator="false" selectionMode="single" rowKey="#{ldapUser.name}"
                rowStyleClass="#{ldapUser.expired == 'Yes' ? 'expired' : null}">

                ....... columns



                <p:column style="width:20px">
                    <f:facet name="header">
                        <h:outputText value="" />
                    </f:facet>
                    <p:commandButton icon="ui-icon-extlink"
                        onclick="alert('this event does not work')" ajax="false"
                        action="#{epsMembershipViewController.edit()}" />
                </p:column>

            </p:dataTable>

            <br />
            <br />

        </p:dataGrid>
    </h:form>

Bean代码

public String edit(ActionEvent e) {

    log.debug("EDIT USER 22222 ");


    return "eps-search";
}

感谢您的帮助, 科恩

I use Primefaces 3.1, JSF 2.1.6 on Glassfish 3.1.1.

I have loads of commandbuttons which work fine, but this one doesn't and I can't figure out why. The javascript alert fires but the controller method is never called.

Note that the first commandbutton fires perfectly (the Filter button) but the edit button inside the datatable does not fire. Instead of a dataGrid I tried ui:repeat but this gives the same effect/issue.
I have a lot of other datatables with a commandbutton but they all work fine...strange.

<h:form id="memberships" prependId="false">
        <h:panelGrid columns="3">
            <h:outputLabel value="Filter on EPS" />
            <p:selectOneMenu value="#{epsMembershipViewController.selectedEps}"
                style="width:200px" effect="fold" editable="false" id="selectEps">
                <f:selectItem itemLabel="Select One" itemValue="" />
                <f:selectItems value="#{epsMembershipViewController.allEps}" />
            </p:selectOneMenu>
            <p:commandButton value="Filter"
                action="#{epsMembershipViewController.repopulateView}" ajax="false" />
        </h:panelGrid>
        <br />

        <p:dataGrid var="eps" value="#{epsMembershipViewController.ldapEpss}"
            columns="1">

            <h:outputLabel value="#{eps}"
                style="font-weight: bold;font-size: 14px;" />

            <p:dataTable var="ldapUser" id="id_#{eps}"
                value="#{epsMembershipViewController.getUsersByEpsFromLdap(eps)}"
                paginator="false" selectionMode="single" rowKey="#{ldapUser.name}"
                rowStyleClass="#{ldapUser.expired == 'Yes' ? 'expired' : null}">

                ....... columns



                <p:column style="width:20px">
                    <f:facet name="header">
                        <h:outputText value="" />
                    </f:facet>
                    <p:commandButton icon="ui-icon-extlink"
                        onclick="alert('this event does not work')" ajax="false"
                        action="#{epsMembershipViewController.edit()}" />
                </p:column>

            </p:dataTable>

            <br />
            <br />

        </p:dataGrid>
    </h:form>

Bean code

public String edit(ActionEvent e) {

    log.debug("EDIT USER 22222 ");


    return "eps-search";
}

Thanks for your help,
Coen

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

背叛残局 2025-01-13 01:46:33

Aaarghh,一如既往,经过半天的调整,我发布了问题,10 分钟后我看到了问题。

问题是数据表没有包装在 ap:column 内。它呈现正常,但这导致表单只执行提交而不调用支持 bean 方法。

<p:dataGrid var="eps" value="#{epsMembershipViewController.ldapEpss}"
            columns="1">

            <p:column> THIS WAS NOT PRESENT !!!!

                <f:facet name="header">
                    <h:outputText value="#{eps}" />
                </f:facet>

                <p:dataTable var="ldapUser" id="id_#{eps}"
                    value="#{epsMembershipViewController.getUsersByEpsFromLdap(eps)}"
                    paginator="false" selectionMode="single" rowKey="#{ldapUser.name}"
                    rowStyleClass="#{ldapUser.expired == 'Yes' ? 'expired' : null}">

                                           ..... COLUMNS .........

                    <p:column style="width:20px">
                        <f:facet name="header">
                            <h:outputText value="" />
                        </f:facet>
                        <p:commandButton icon="ui-icon-extlink"
                            onclick="alert('this event does not work')" ajax="false"
                            action="#{epsMembershipViewController.edit()}" />
                    </p:column>

                </p:dataTable>

            </p:column>

Aaarghh, as ever so often, after half a day of tweaking I posted the question and 10 mins later I see the problem.

The problem is that the datatable is not wrapped inside a p:column. It is rendered OK but that is causing the form to just do a submit without calling the backing bean method.

<p:dataGrid var="eps" value="#{epsMembershipViewController.ldapEpss}"
            columns="1">

            <p:column> THIS WAS NOT PRESENT !!!!

                <f:facet name="header">
                    <h:outputText value="#{eps}" />
                </f:facet>

                <p:dataTable var="ldapUser" id="id_#{eps}"
                    value="#{epsMembershipViewController.getUsersByEpsFromLdap(eps)}"
                    paginator="false" selectionMode="single" rowKey="#{ldapUser.name}"
                    rowStyleClass="#{ldapUser.expired == 'Yes' ? 'expired' : null}">

                                           ..... COLUMNS .........

                    <p:column style="width:20px">
                        <f:facet name="header">
                            <h:outputText value="" />
                        </f:facet>
                        <p:commandButton icon="ui-icon-extlink"
                            onclick="alert('this event does not work')" ajax="false"
                            action="#{epsMembershipViewController.edit()}" />
                    </p:column>

                </p:dataTable>

            </p:column>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文