侦听JSF-SEAM阶段的“正式" SEAM方法是什么? [英] What is the 'official' SEAM way of listening to JSF-SEAM phases?

查看:111
本文介绍了侦听JSF-SEAM阶段的“正式" SEAM方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个简单的标题问题.

我的情况是我想在"RENDER_RESPONSE之前"阶段收听,并更改某些组件的内部状态.

My case is that I want to listen to "before RENDER_RESPONSE" phase, and alter some components internal state.

在SEAM应用程序中,PhaseListener是实现此目的的正确方法"吗?

Is PhaseListener the "right way" to do this in SEAM applications?

推荐答案

如果要更改 JSF 组件内部状态,请依赖JSF阶段侦听器.下面显示了声明JSF阶段监听器的接缝方式

If you want alter JSF component internal state, rely on JSF phase listener. Seam way of declaring JSF phase listener is shown bellow

@Name("applicationPhaseListener")
@Scope(ScopeType.APPLICATION)
public class ApplicationPhaseListener {

    /**
      * Called TRANSPARENTLY by Seam
      */
    @Observer("org.jboss.seam.beforePhase")
    public void beforePhase(PhaseEvent event) {


    }

    /**
      * Called TRANSPARENTLY by Seam
      */
    @Observer("org.jboss.seam.afterPhase")
    public void afterPhase(PhaseEvent event) {

    }



}

但是,如果您想更改 Seam contextual 组件状态,请使用

But if you want to alter Seam contextual component state, use

@Name("applicationPhaseListener")
public class ApplicationPhaseListener {

    @Observer("applicationListener")
    public void applicationListener() {

    }

}

您可以

以编程方式调用您的事件

Events.instance().raiseEvent("applicationListener");

通过使用@RaiseEvent批注,该批注放置在某些操作方法之上

@RaiseEvent("applicationListener")
public void doSomething() {

}

pages.xml

<page id="<PAGE_ID_GOES_HERE>">
    <raise-event type="applicationListener"/>
</page>

这篇关于侦听JSF-SEAM阶段的“正式" SEAM方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆