p:commandButton ajax 未在 p:dataList 内调用
Primefaces 2.2.1
Mojarra 2.1.2
我的 jsf bean 中有一个复杂的方法:
public void saySomething() {
log.debug("SAY SOMETHING !");
}
jsf 中有一个简单的按钮:
<p:commandButton
value="say something"
process="@this" update="@none" action="#{timetableBean.saySomething}" />
单击该按钮,会生成简单的日志记录:
DEBUG PhaseTracker - BEFORE PHASE INVOKE_APPLICATION 5
DEBUG TimetableBean - SAY SOMETHING !
DEBUG PhaseTracker - AFTER PHASE INVOKE_APPLICATION 5
让我们转到下一个简单的情况。 当将相同的按钮放入 ap:dataList 中时,如下所示:
<p:dataList id="groupUsers2" value="#{timetableBean.group.users}" var="user" itemType="circle" style="padding:0; margin: 0;">
<p:commandButton
value="#{user.data['selected'] ? 'V' : 'X'}"
process="@this" update="@none" action="#{timetableBean.saySomething}" />
<p:commandLink value="#{user.userId} - #{user.name}" process="@this" />
</p:dataList>
单击按钮,会导致我的简单日志记录:
DEBUG PhaseTracker - BEFORE PHASE INVOKE_APPLICATION 5
DEBUG PhaseTracker - AFTER PHASE INVOKE_APPLICATION 5
未调用 saySomething() 的方法!
我做错了什么?
Primefaces 2.2.1
Mojarra 2.1.2
I have a sophisticated method in my jsf bean :
public void saySomething() {
log.debug("SAY SOMETHING !");
}
And a simple button in the jsf :
<p:commandButton
value="say something"
process="@this" update="@none" action="#{timetableBean.saySomething}" />
Clicking on the button, results in my simple logging :
DEBUG PhaseTracker - BEFORE PHASE INVOKE_APPLICATION 5
DEBUG TimetableBean - SAY SOMETHING !
DEBUG PhaseTracker - AFTER PHASE INVOKE_APPLICATION 5
Let's go to next simple case.
When placing that identical button inside a p:dataList like this :
<p:dataList id="groupUsers2" value="#{timetableBean.group.users}" var="user" itemType="circle" style="padding:0; margin: 0;">
<p:commandButton
value="#{user.data['selected'] ? 'V' : 'X'}"
process="@this" update="@none" action="#{timetableBean.saySomething}" />
<p:commandLink value="#{user.userId} - #{user.name}" process="@this" />
</p:dataList>
Clicking on the button, results in my simple logging :
DEBUG PhaseTracker - BEFORE PHASE INVOKE_APPLICATION 5
DEBUG PhaseTracker - AFTER PHASE INVOKE_APPLICATION 5
The method of saySomething() was not called !
What did i do wrong ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题解决了。
在此处找到解决方案
为了调用侦听器, p:dataList 内的组件应该用
p:column
封装,但奇怪的是,我在文档中没有看到这一点,因为它没有指定 p:column。也许它在 primefaces 2.2.1 doc 的勘误表中?
相关问题此处。
Problem solved.
Found the solution in here
In order for listener to be invoked, the components inside the p:dataList should be encapsulated with
p:column
Strange though, i didnt see this in the documentation, as it doesnt specify the p:column. Perhaps it's in the errata for primefaces 2.2.1 doc ?
Related problems here.