繁体   English   中英

Primefaces CommandButton 在 DataTable 中不起作用

[英]Primefaces CommandButton not working inside DataTable

我在数据表之外有一个功能正常的primefaces commandButton。 在数据表中,我有完全相同的 commandButton,但是当点击数据表中的那个时,它不会调用 actionListener:

 <h:body>
    <h:form>
        <p:messages autoUpdate="true" showDetail="true" closable="true"/>
        <p:accordionPanel >  
            <p:tab title="Visualize data">
                <p:commandButton value="Add Domain" actionListener="#{TripleStoreController.addDomain('Domain')}"
                                 update="DomainSkillTable"/>
                <p:dataTable 
                    id="DomainSkillTable"
                    var="result"
                    value="#{TripleStoreController.domainResults}"
                    rowKey="#{result}">
                    <p:column>
                        #{result}
                    </p:column>
                    <p:column>
                        <p:commandButton value="Add Domain" actionListener="#{TripleStoreController.addDomain('Domain')}"
                                         update="DomainSkillTable"/>
                    </p:column>
                </p:dataTable>
            </p:tab>
        </p:accordionPanel>  
    </h:form>
</h:body>

它应该是工作。 没有错误,我只是在我的 java 类中为相同的方法TripleStoreController.addDomain('Domain')复制并重新生成 bean,方法签名如public void addDomain(String s)和方法有效。 甚至我在我的后台 bean 中通过命令按钮将值传递为“域”。

就我而言,我只是将我的 bean 从 @RequestScoped 制作为 @ViewScoped,它解决了我的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM