开发者

JSF application Deployment time function call

IN JSP i used to put things in bean's constructor which is in APPLCIATION scope, similarly i want to load a function upon deploy of application where i can put .

i tried putting in listener but @ that time i am not getting faces config 's injection .

so is there any way ou开发者_如何学运维t ?


Tt sounds suspicious that the listener hadn't worked for you. It should've worked. What I assume has happened is that you expect your request-scoped beans to get their dependencies injected outside a request/response cycle. Well, this won't happen.

So you'd better do one of these:

  • put the @PostConstruct annotation on every bean and initialize it.
  • register a ServletRequestListener which gets triggered on each request

If you want a managed bean to initialize something application-wide (what is that something, btw):

  1. Create a managed bean with scope application
  2. Do your initialization in a method annotated with @PostConstruct

Btw, you have been wrong to put JSP initialization code in constructor. It should've been in the init(..) method. (and actually, shouldn't have been in a JSP at all)

Alternatively you can use a PhaseListener (in the faces-config.xml), where to lazily load tha application settings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜