开发者

Invoking application scoped bean jsf

In my applicatoin I have a application scoped bean, which I call it like this: FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get("name");

What is the best way to initialize it?

The way I do till now it to call one of its properies in the first jsf page, for no need 开发者_Go百科- just initializing the bean.

The page looks like this:

 <h:inputHidden id="inovkeBean" value="#{myBean.nothing}"/> 

And the bean:

@ApplicationScoped
public class MyBean {

String nothing;

public String getNothing() {
    return nothing;
}

}

It works fine, just i'm asking: can anybody tell me a nicer way to initialize the bean?

Thanks!


If you are using JSF2.0 mark it as eager="true" so it will get constructed when JSF context will get initilized

@ManagedBean(eager=true)
@ApplicationScoped
public class SomePojo { }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜