有时,当使用<h:commandLink>, <h:commandButton>或<f:ajax>时,与标记相关的action, actionListener或listener方法根本没有被调用。或者,bean属性没有更新提交的UIInput值。
可能的原因和解决方法是什么?
有时,当使用<h:commandLink>, <h:commandButton>或<f:ajax>时,与标记相关的action, actionListener或listener方法根本没有被调用。或者,bean属性没有更新提交的UIInput值。
可能的原因和解决方法是什么?
当前回答
还有一种可能性:如果症状是第一次调用有效,但随后的调用无效,那么您可能使用的是PrimeFaces 3。在JSF 2.2中,没有ViewState被发送。
其他回答
这就是解决方法,对我来说很管用。
<p:commandButton id="b1" value="Save" process="userGroupSetupForm"
actionListener="#{userGroupSetupController.saveData()}"
update="growl userGroupList userGroupSetupForm" />
这里,process="userGroupSetupForm"属性是Ajax调用的强制属性。actionListener从@ViewScope Bean调用一个方法。也更新咆哮消息,数据表:userGroupList和表单:userGroupSetupForm。
我有很多有趣的调试问题,其中一个<h:commandLink>的动作在richfaces数据表拒绝发射。这张桌子曾经在某个时候工作过,但没有明显的原因就停了下来。我想尽了一切办法,却发现我的rich:datatable使用了错误的rowKeyConverter,它返回了richfaces愉快地用作行键的空值。这阻止了我的<h:commandLink>动作被调用。
我想再提一点关于Primefaces的p:commandButton!
当你使用p:commandButton来执行需要在服务器上执行的操作时,你不能使用type="button",因为这是用于Push按钮的,用于执行自定义javascript,而不会向服务器发出ajax/非ajax请求。
为此,您可以免除type属性(默认值是"submit"),也可以显式地使用type="submit"。
希望这能帮助到一些人!
<ui:composition>
<h:form id="form1">
<p:dialog id="dialog1">
<p:commandButton value="Save" action="#{bean.method1}" /> <!--Working-->
</p:dialog>
</h:form>
<h:form id="form2">
<p:dialog id="dialog2">
<p:commandButton value="Save" action="#{bean.method2}" /> <!--Not Working-->
</p:dialog>
</h:form>
</ui:composition>
来解决;
<ui:composition>
<h:form id="form1">
<p:dialog id="dialog1">
<p:commandButton value="Save" action="#{bean.method1}" /> <!-- Working -->
</p:dialog>
<p:dialog id="dialog2">
<p:commandButton value="Save" action="#{bean.method2}" /> <!--Working -->
</p:dialog>
</h:form>
<h:form id="form2">
<!-- .......... -->
</h:form>
</ui:composition>
我修复了我的问题,放置:
<h:commandButton class="btn btn-danger" value = "Remove" action="#{deleteEmployeeBean.delete}"></h:commandButton>
In:
<h:form>
<h:commandButton class="btn btn-danger" value = "Remove" action="#{deleteEmployeeBean.delete}"></h:commandButton>
</h:form>