问题描述
Primefaces 2.2.1
Primefaces 2.2.1
Mojarra 2.1.2
Mojarra 2.1.2
我的jsf bean中有一个复杂的方法:
I have a sophisticated method in my jsf bean :
public void saySomething() {
log.debug("SAY SOMETHING !");
}
在jsf中有一个简单的按钮:
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
让我们转到下一个简单的案例.将相同的按钮放在p:dataList里面时,像这样:
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
saySomething()的方法未调用!
The method of saySomething() was not called !
我做错了什么?
推荐答案
问题已解决.
在此处
为了调用侦听器,应将p:dataList内部的组件封装为p:column
In order for listener to be invoked, the components inside the p:dataList should be encapsulated with p:column
<p:dataList id="groupUsers2" value="#{timetableBean.group.users}" var="user" itemType="circle" style="padding:0; margin: 0;">
<p:column>
<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:column>
</p:dataList>
但是很奇怪,我没有在文档中看到它,因为它没有指定p:column.也许是在Primefaces 2.2.1 doc的勘误表中?
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 ?
相关问题此处.
这篇关于p:commandButton ajax在p:dataList内部未调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!