p:pdataTable/p:dataGrid/ui:repeat 内的 p:commandButton 不调用方法
我在 Glassfish 3.1.1 上使用 Primefaces 3.1、JSF 2.1.6。
我有很多可以正常工作的命令按钮,但这个却不能,我不明白为什么。 javascript 警报会触发,但控制器方法从未被调用。
请注意,第一个命令按钮可以完美触发(“过滤器”按钮),但数据表内的编辑按钮不会触发。我尝试了 ui:repeat 而不是 dataGrid,但这给出了相同的效果/问题。 我有很多其他带有命令按钮的数据表,但它们都工作正常......奇怪。
<h:form id="memberships" prependId="false">
<h:panelGrid columns="3">
<h:outputLabel value="Filter on EPS" />
<p:selectOneMenu value="#{epsMembershipViewController.selectedEps}"
style="width:200px" effect="fold" editable="false" id="selectEps">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItems value="#{epsMembershipViewController.allEps}" />
</p:selectOneMenu>
<p:commandButton value="Filter"
action="#{epsMembershipViewController.repopulateView}" ajax="false" />
</h:panelGrid>
<br />
<p:dataGrid var="eps" value="#{epsMembershipViewController.ldapEpss}"
columns="1">
<h:outputLabel value="#{eps}"
style="font-weight: bold;font-size: 14px;" />
<p:dataTable var="ldapUser" id="id_#{eps}"
value="#{epsMembershipViewController.getUsersByEpsFromLdap(eps)}"
paginator="false" selectionMode="single" rowKey="#{ldapUser.name}"
rowStyleClass="#{ldapUser.expired == 'Yes' ? 'expired' : null}">
....... columns
<p:column style="width:20px">
<f:facet name="header">
<h:outputText value="" />
</f:facet>
<p:commandButton icon="ui-icon-extlink"
onclick="alert('this event does not work')" ajax="false"
action="#{epsMembershipViewController.edit()}" />
</p:column>
</p:dataTable>
<br />
<br />
</p:dataGrid>
</h:form>
Bean代码
public String edit(ActionEvent e) {
log.debug("EDIT USER 22222 ");
return "eps-search";
}
感谢您的帮助, 科恩
I use Primefaces 3.1, JSF 2.1.6 on Glassfish 3.1.1.
I have loads of commandbuttons which work fine, but this one doesn't and I can't figure out why. The javascript alert fires but the controller method is never called.
Note that the first commandbutton fires perfectly (the Filter button) but the edit button inside the datatable does not fire. Instead of a dataGrid I tried ui:repeat but this gives the same effect/issue.
I have a lot of other datatables with a commandbutton but they all work fine...strange.
<h:form id="memberships" prependId="false">
<h:panelGrid columns="3">
<h:outputLabel value="Filter on EPS" />
<p:selectOneMenu value="#{epsMembershipViewController.selectedEps}"
style="width:200px" effect="fold" editable="false" id="selectEps">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItems value="#{epsMembershipViewController.allEps}" />
</p:selectOneMenu>
<p:commandButton value="Filter"
action="#{epsMembershipViewController.repopulateView}" ajax="false" />
</h:panelGrid>
<br />
<p:dataGrid var="eps" value="#{epsMembershipViewController.ldapEpss}"
columns="1">
<h:outputLabel value="#{eps}"
style="font-weight: bold;font-size: 14px;" />
<p:dataTable var="ldapUser" id="id_#{eps}"
value="#{epsMembershipViewController.getUsersByEpsFromLdap(eps)}"
paginator="false" selectionMode="single" rowKey="#{ldapUser.name}"
rowStyleClass="#{ldapUser.expired == 'Yes' ? 'expired' : null}">
....... columns
<p:column style="width:20px">
<f:facet name="header">
<h:outputText value="" />
</f:facet>
<p:commandButton icon="ui-icon-extlink"
onclick="alert('this event does not work')" ajax="false"
action="#{epsMembershipViewController.edit()}" />
</p:column>
</p:dataTable>
<br />
<br />
</p:dataGrid>
</h:form>
Bean code
public String edit(ActionEvent e) {
log.debug("EDIT USER 22222 ");
return "eps-search";
}
Thanks for your help,
Coen
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Aaarghh,一如既往,经过半天的调整,我发布了问题,10 分钟后我看到了问题。
问题是数据表没有包装在 ap:column 内。它呈现正常,但这导致表单只执行提交而不调用支持 bean 方法。
Aaarghh, as ever so often, after half a day of tweaking I posted the question and 10 mins later I see the problem.
The problem is that the datatable is not wrapped inside a p:column. It is rendered OK but that is causing the form to just do a submit without calling the backing bean method.