相关疑难解决方法(0)

@this的功能究竟是什么?

据我知道@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)

jsf primefaces jsf-2

34
推荐指数
1
解决办法
4万
查看次数

标签 统计

jsf ×1

jsf-2 ×1

primefaces ×1