【发布时间】:2012-02-01 08:40:02
【问题描述】:
我正在尝试使用 搜索按钮 来返回所选项目(可以是多个)并更新数据表。然后我在每个列旁边都有一个 selectBooleanCheckbox,当用户选择“n”个项目然后按 选择选中的项目它插入 DB。
代码如下:
<h:panelGrid columns="5">
<h:form>
<h:outputText value="Item Name"/>
<p:inputText value="#{StockController.itemName}"/>
<h:commandButton value="Search" action="#{StockController.Search}">
<f:ajax execute="@form" render=":results"/>
</h:commandButton>
</h:form>
//下面的代码示例属于BalusC 见帖子here
<h:panelGroup id="results">
<h:form>
<h:dataTable value="#{bean.entities}" var="entity">
<h:column>
<h:selectBooleanCheckbox value="#{bean.checked[entity.id]}" />
</h:column>
...
</h:dataTable>
<h:commandButton value="Select the checked Items" action="#{StockController.insertDao}" >
<f:ajax execute="@form" render=":results"/>
</h:commandButton>
</h:form>
</h:panelGrid>
现在,我已经阅读了很多博客和 Core javaServer Faces 3,我认为 ajax 的使用没有逻辑错误。我通过删除每个 ajax 进行了测试,然后 两者都可以正常工作,但是每当我尝试将 两个 cummondButtons 与 ajax 一起使用时,第二个“选择选中的项目" 甚至不调用 "StockController.insertDao" 方法。
感谢任何帮助。
谢谢大家。
【问题讨论】: