Primefaces 2.2.1
Mojarra 2.1.2
我的jsf bean中有一个复杂的方法:
public void saySomething() {
log.debug("SAY SOMETHING !");
}
Run Code Online (Sandbox Code Playgroud)
还有jsf中的一个简单按钮:
<p:commandButton
value="say something"
process="@this" update="@none" action="#{timetableBean.saySomething}" />
Run Code Online (Sandbox Code Playgroud)
单击按钮,将导致我的简单日志记录:
DEBUG PhaseTracker - BEFORE PHASE INVOKE_APPLICATION 5
DEBUG TimetableBean - SAY SOMETHING !
DEBUG PhaseTracker - AFTER PHASE INVOKE_APPLICATION 5
Run Code Online (Sandbox Code Playgroud)
让我们进入下一个简单的案例.将相同的按钮放在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>
Run Code Online (Sandbox Code Playgroud)
单击按钮,将导致我的简单日志记录:
DEBUG PhaseTracker - BEFORE PHASE INVOKE_APPLICATION 5
DEBUG PhaseTracker - AFTER PHASE INVOKE_APPLICATION 5
Run Code Online (Sandbox Code Playgroud)
saySomething()的方法没有被调用!
我做错了什么 ?
ber*_*tie 10
问题解决了.
在这里找到解决方案
为了调用侦听器,应该使用封装p:dataList中的组件 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>
Run Code Online (Sandbox Code Playgroud)
奇怪的是,我没有在文档中看到这一点,因为它没有指定p:列.也许它出现在primefaces 2.2.1 doc的勘误表中?
这里有相关问题.
| 归档时间: |
|
| 查看次数: |
10741 次 |
| 最近记录: |