在筑巢的另一个数据表中筑巢时,加载2个或更多的主行时,SplitButton停止工作

发布于 2025-01-26 13:18:34 字数 2138 浏览 3 评论 0原文

因此,我试图将数据嵌套嵌套在RowExpansion标签中的另一个数据表中,如下所示:

<h:form>
    <p:dataTable var="item" 
                 value="#{bean.items}">
        <p:column>
            <p:rowToggler/>
        </p:column>
        <p:column headerText="Item Name">
            <h:outputText value="#{item.name}"/>
        </p:column>
        <p:rowExpansion>
            <p:dataTable var="subitem" 
                         value="#{item.subitems}">
                <p:column headerText="Subitem Name">
                    <h:outputText value="#{subitem.name}" />
                </p:column>
                <p:column>
                    <p:splitButton value="Save" action="#{bean.save}">
                        <p:menuitem value="Update" action="#{bean.update}"/>
                        <p:menuitem value="Delete" action="#{bean.delete}"/>
                    </p:splitButton>
                </p:column>
            </p:dataTable>
        </p:rowExpansion>
    </p:dataTable>
</h:form>

BEAN中的测试方法只是

    public void save() {
        addMessage(FacesMessage.SEVERITY_INFO, "Success!", "Saved subitem");
        PrimeFaces.current().ajax().update(":frmTopbar");
    }

    public void update() {
        addMessage(FacesMessage.SEVERITY_INFO, "Success!", "Updated subitem");
        PrimeFaces.current().ajax().update(":frmTopbar");
    }

    public void delete() {
        addMessage(FacesMessage.SEVERITY_INFO, "Success!", "Deleted subitem");
        PrimeFaces.current().ajax().update(":frmTopbar");
    }
    public void addMessage(FacesMessage.Severity severity, String summary, String detail) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, summary, detail));
    }

仅一个项目及其子项目加载,所有内容都显示,并且SplitButton按钮正常工作。

Bean只是发送一个面孔进行测试,就像我说的那样,该消息适当地显示了3个按钮中的每个按钮。

但是,一旦我加载了2个或更多的项目及其子立法,一切在视觉上看起来都正确,但是SplitButton中的命令不再到达Bean,因此不会发送脸部。

是否有人知道发生了什么事或有关解决问题的建议?

我正在使用PrimeFaces v11.0

非常感谢!

So I'm trying to nest a datatable within another datatable in the rowexpansion tag as follows:

<h:form>
    <p:dataTable var="item" 
                 value="#{bean.items}">
        <p:column>
            <p:rowToggler/>
        </p:column>
        <p:column headerText="Item Name">
            <h:outputText value="#{item.name}"/>
        </p:column>
        <p:rowExpansion>
            <p:dataTable var="subitem" 
                         value="#{item.subitems}">
                <p:column headerText="Subitem Name">
                    <h:outputText value="#{subitem.name}" />
                </p:column>
                <p:column>
                    <p:splitButton value="Save" action="#{bean.save}">
                        <p:menuitem value="Update" action="#{bean.update}"/>
                        <p:menuitem value="Delete" action="#{bean.delete}"/>
                    </p:splitButton>
                </p:column>
            </p:dataTable>
        </p:rowExpansion>
    </p:dataTable>
</h:form>

the testing methods in the bean are just

    public void save() {
        addMessage(FacesMessage.SEVERITY_INFO, "Success!", "Saved subitem");
        PrimeFaces.current().ajax().update(":frmTopbar");
    }

    public void update() {
        addMessage(FacesMessage.SEVERITY_INFO, "Success!", "Updated subitem");
        PrimeFaces.current().ajax().update(":frmTopbar");
    }

    public void delete() {
        addMessage(FacesMessage.SEVERITY_INFO, "Success!", "Deleted subitem");
        PrimeFaces.current().ajax().update(":frmTopbar");
    }
    public void addMessage(FacesMessage.Severity severity, String summary, String detail) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, summary, detail));
    }

If only a single item and its subitems is loaded, everything displays and splitbutton buttons work fine.

The bean just sends a FacesMessage to test and like I said, the message is properly shown for each of the 3 buttons.

But as soon as I load 2 or more items and their subitems, everything looks visually correct, but the commands in splitbutton no longer reach bean, so no FacesMessage is sent.

Does anyone have a clue about what is going on or a suggestion as to what can be done to fix it?

I'm using primefaces v11.0

Thanks a lot!

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

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

发布评论

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

评论(1

怀里藏娇 2025-02-02 13:18:34

我似乎使用Balusc的技巧找到了P:RemoteCommand的解决方法。

因此,我所做的就是将其放在我的页面中的某个地方,该页面将将JavaScript函数映射到BEAN方法。

<p:remoteCommand name="splitButtonMenuitemClicked" actionListener="#{bean.save}" style="display: none;" />

然后,我将此jQuery代码放在我的页面中,以从任何拆分按钮中捕获点击事件:

jQuery( document).delegate( ".ui-splitbuttonmenu .ui-menuitem-link", "click", 
    function(e){
        var menuitemText = $(this).find("span.ui-menuitem-text");
        var itemText = $(menuitemText).text();
        splitButtonMenuitemClicked([{ name: "fooName", value: itemText }])
    }
);

现在,在我的bean函数中,我只是在以下操作中检索我的参数:

public void save() {
    String fooName= FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("fooName");
    //fooName is unique key in may table, so it works well to work on the correct entity
...
}

现在会做到的一个希望。

I seem to have found a workaround with p:remoteCommand using BalusC's tips.

So what I've done, is place this somewhere in my page that will map a javascript function to a bean method.

<p:remoteCommand name="splitButtonMenuitemClicked" actionListener="#{bean.save}" style="display: none;" />

I then place this jquery code in my page to catch the click event from any split button:

jQuery( document).delegate( ".ui-splitbuttonmenu .ui-menuitem-link", "click", 
    function(e){
        var menuitemText = $(this).find("span.ui-menuitem-text");
        var itemText = $(menuitemText).text();
        splitButtonMenuitemClicked([{ name: "fooName", value: itemText }])
    }
);

Now in my bean function, I just retrieve my parameter as follows:

public void save() {
    String fooName= FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("fooName");
    //fooName is unique key in may table, so it works well to work on the correct entity
...
}

It'll do for now, although it would be nice if the components worked as one hopes.

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