【发布时间】:2011-08-07 15:09:17
【问题描述】:
据我所知 @this 是表示当前触发事件的组件,例如:
<p:commandButton process="@this" ... />
在 JSF 2 Ajax 中,@this 也可以表示封装组件,例如:
<h:inputText ...>
<f:ajax execute="@this" ... />
</h:inputText>
我有一种情况,使用 p:datatable,包括或排除 @this 会对 Ajax 部分提交产生不同的影响
这是示例,在这种情况下,进程正在使用 @this,这按预期工作,其中进程首先发生,然后是 setPropertyActionListener 和最后,action 被执行:
<p:column>
<p:commandLink
value="#{anggaranDetail.map['code']}"
process="@this infoAnggaranForm:Anggaran"
update="detailDialogForm:Anggaran detailDialogForm:SubAnggaran"
oncomplete="infoAnggaranDialog.hide()"
image="ui-icon ui-icon-search"
action="#{tInputBean.updateAnggaranSubAnggaran}">
<f:setPropertyActionListener value="#{anggaranDetail}"
target="#{infoAnggaranBean.selectedAnggaranDetail}" />
</p:commandLink>
</p:column>
但是当我从这个例子中省略 @this 时,setPropertyActionListener 和 action 永远不会被执行,就好像它们没有在那里。
我想知道为什么?或许@this除了当前组件还有其他含义,或许是本例中的当前记录?
我使用的是 tomcat 7,这些是我的依赖项:
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0.4-b09</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.0.4-b09</version>
<scope>compile</scope>
</dependency>
【问题讨论】:
标签: jsf jsf-2 primefaces