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数据表,方法运行两次_Jsf_Datatable - Fatal编程技术网

刷新jsf数据表,方法运行两次

刷新jsf数据表,方法运行两次,jsf,datatable,Jsf,Datatable,我有一个维修表,你可以对这些维修出价,出价将显示在表中以及接受按钮。当您点击acceptbutton时,我希望de datatable刷新并将acceptbutton设置为unaccept。当我调试并点击accept按钮时,我看到它运行dashboardBean.acceptBidbid方法两次。通过这种方式,中标人将从“假”变为“真”,再变为“假”。有人知道我做错了什么吗 以下是必要的代码: public void acceptBid(Bid bid){ activeBid = bid

我有一个维修表,你可以对这些维修出价,出价将显示在表中以及接受按钮。当您点击acceptbutton时,我希望de datatable刷新并将acceptbutton设置为unaccept。当我调试并点击accept按钮时,我看到它运行dashboardBean.acceptBidbid方法两次。通过这种方式,中标人将从“假”变为“真”,再变为“假”。有人知道我做错了什么吗

以下是必要的代码:

public void acceptBid(Bid bid){
    activeBid = bid;

    if(bid.isAccepted()){
        repairService.clearBid(bid);
    }else{
        repairService.acceptBid(activeBid);
    }
}
以下是页面:

<h:commandButton id="showOpen" value="#{msg['welcome.button.showDashboard']}" action="#{dashboardBean.showDashboard}" update="table-open-wrapper"/><br/><br/>
                <h:panelGroup id="table-open-wrapper">
                    <h3>#{msg['welcome.title.openRepairs']}</h3>
                    <h:dataTable id="itemToRepair" value="#{dashboardBean.openRepairsArray}" binding="#{dashboardBean.dataTableOpen}" var="itemToRepair"> <ui:remove>rendered="#{dashboardBean.openRepairsVisible}"</ui:remove>
                        <h:column headerText="Open repairs">
                            <h:outputText value="#{itemToRepair}"/>
                        </h:column>
                        <br/>
                        <p:column headerText="bidsPerItem">
                            <ui:repeat value="#{itemToRepair.bids}" var="bid">
                                <h:outputText value="#{bid.repairer.username}"/>
                                <h:outputText value="#{bid.price}"/>
                                <h:column headerText="Buttons">
                                    <h:commandButton id="acceptItemBid" value="#{msg['welcome.button.acceptBid']}" rendered="#{!bid.accepted}" action="#{dashboardBean.acceptBid(bid)}" update="itemToRepair"/>
                                    <h:commandButton id="unacceptItemBid" value="#{msg['welcome.button.unacceptBid']}" rendered="#{bid.accepted}" action="#{dashboardBean.acceptBid(bid)}" update="itemToRepair"/><br/>
                                </h:column>
                            </ui:repeat>
                        </p:column>

您使用的是哪个JSF实现版本?我使用的是2.2h版本:commandButton本身没有ajax功能,更新属性对它来说是无用的。请将接受/不接受按钮更改为p:commandButton。