fs事件的jsf执行顺序 [英] jsf execution order of f:events

查看:200
本文介绍了fs事件的jsf执行顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这些执行顺序是什么?

以下是有关可能的 f:event 事件名称的问题: JSF 2事件列表

Here is a question about possible f:event event names: List of JSF 2 events?

preRenderComponent
preRenderView
postAddToView
preValidate
postValidate

我想检查用户是否保存在会话bean中,如果不是重定向到登录站点,这需要在view-param转换阶段之前发生,因为使用的转换器取决于登录的用户。 'preValidate'似乎在转换后发生,所以我需要一个更早的事件。

I want to check if a User is saved in a session bean is logged in and if not redirect to the login site, which needs to occur before view-param conversion phase since the used converter depends on the logged in User. 'preValidate' seems to take place after conversion and so I need an earlier event.

<f:event type="preRenderView" listener="#{beanA.checkLoggedIn()}"/>
<f:viewParam name="param" value="#{beanB.param}" converter="#{beanB.converter}" required="true"/>

我也可以将'checkLoggedIn()'放在'beanB'中,但尝试使用单独的请求范围的bean只是用于检查,以便我可以轻松地重用它。

I could have put 'checkLoggedIn()' in 'beanB' too, but tried to use a separate request scoped bean just for the check so that I could reuse it easily.

推荐答案


这些执行顺序是什么?




  • postAddToView 正确运行在视图构建时间(通常在还原视图阶段,但也可以在渲染响应阶段,例如导航)期间添加组件添加到视图之后。

  • preValidate 在组件被验证之前运行(通常在验证阶段,但也可以应用请求值阶段,如果 immediate =tr ue)。

  • postValidate 在组件被验证之后运行(通常在验证阶段,但也可以应用请求如果 immediate =true

  • preRenderView 在渲染响应中呈现视图之前运行阶段。

  • preRenderComponent 在渲染响应阶段渲染组件之前运行。

    • postAddToView runs right after the component is added to view during view build time (which is usually during restore view phase, but can also be during render response phase, e.g. navigation).
    • preValidate runs right before the component is to be validated (which is usually during validations phase, but can also be apply request values phase if immediate="true").
    • postValidate runs right after the component is been validated (which is usually during validations phase, but can also be apply request values phase if immediate="true").
    • preRenderView runs right before the view is rendered during render response phase.
    • preRenderComponent runs right before the component is rendered during render response phase.
    • 点击链接查看javadoc简介中的详细说明。

      Click the links to see detailed description in javadoc introduction.


      我想检查一个用户是否是sa已登录的会话bean被登录,如果不是重定向到登录站点,这需要在视图参数转换阶段之前进行,因为所使用的转换器取决于登录的用户。 'preValidate'似乎在转换后发生,所以我需要一个更早的事件。

      你应该使用一个简单的<一个href =https://stackoverflow.com/tags/servlet-filters/info> servlet过滤器,而不是JSF事件。我已经发布了几个例子:

      You should use a simple servlet filter for this, not a JSF event. I've posted several examples before:

      • Is there any easy way to preprocess and redirect GET requests?
      • Are there some issue at inserting some check into template?

      这篇关于fs事件的jsf执行顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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