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

时间:2014-08-11 21:55:58

标签: jsf datatable

我有一张维修台,您可以对这些维修进行投标,出价将显示在表格中以及接受按钮。当你点击接受按钮时,我希望de datatable刷新并将acceptbutton设置为unaccept。当我调试并点击接受按钮时,我看到它运行了两次dashboardBean.acceptBid(bid)方法。这样bid.accepted将从false变为true并返回false。有没有人看到我做错了什么。

这是必要的代码:

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>

0 个答案:

没有答案