将初始化参数传递给Manage Bean [英] Passing init params to Manage bean

查看:108
本文介绍了将初始化参数传递给Manage Bean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个授权管理的Bean,以获取要应用于该应用程序的每个jsf中的标签的限制规则.托管bean要求在初始化时知道​​请求的jsf的名称,以便它可以获取特定于该jsf中的标签的限制.最好的方法是什么?

I have a authorization managed bean to fetch restriction rules to be applied to the tags within every jsf of the application. The managed bean requires to know the name of the requested jsf on initiation so it can fetch restrictions specific to the tags within that jsf. What is the best way this can be achieved ?

推荐答案

在web.xml中对其进行声明,如下所示:

Declare it in web.xml as follows:

<context-param>
    <param-name>paramName</param-name>
    <param-value>PARAM_VALUE</param-value>
</context-param>

按以下方式在ManagedBean中访问它:

Access it in ManagedBean as follows:

FacesContext.getCurrentInstance()
                .getExternalContext().getInitParameter("paramName")

希望这有助于解决您的问题.

Hope this helps to solve your problem.

这篇关于将初始化参数传递给Manage Bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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