ber*_*tie 34 jsf primefaces jsf-2
据我知道@this是表示当前组件触发事件,比如:
<p:commandButton process="@this" ... />
Run Code Online (Sandbox Code Playgroud)
在JSF 2 Ajax中,@ this也可以表示封装组件,如:
<h:inputText ...>
<f:ajax execute="@this" ... />
</h:inputText>
Run Code Online (Sandbox Code Playgroud)
我有一个案例,其中使用p:datatable,包括或排除@this可能会对Ajax部分提交产生不同的影响
这里的例子,在这种情况下,该进程正在使用@this,这正常工作,当过程发生,其中第一,然后依次setPropertyActionListener和最后的动作被执行:
<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>
Run Code Online (Sandbox Code Playgroud)
但是当我从这个例子中省略@this时,setPropertyActionListener和动作永远不会执行,好像它们不存在一样.
我想知道为什么 ?也许@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>
Run Code Online (Sandbox Code Playgroud)
Bal*_*usC 37
PrimeFaces process和标准JSF execute属性应指向JSF应在整个JSF生命周期中根据ajax请求(获取请求参数,验证它们,更新模型,执行操作)处理的组件的空间分离组件标识符.当前组件的process默认值@form,当前表单和execute默认值@this.在命令链接/按钮中,必须执行与链接/按钮本身相关联的操作.
但是,在您拥有的数据表中process="@this infoAnggaranForm:Anggaran",因此需要处理两个组件.如果省略@this但保留其他组件,则它将仅处理/执行其他组件而不是链接/按钮组件.如果省略该process属性,它将默认为@form.如果您在同一表单中有更多其他输入组件,那么它们也将被处理.
根据具体的功能要求,您可以保留它process="@this infoAnggaranForm:Anggaran",或省略它.然后,JSF将根据您的需要至少处理/执行按钮和其他组件.
| 归档时间: |
|
| 查看次数: |
37959 次 |
| 最近记录: |