开发者

Method always working before any other method

I want to get a database entity using a parameter from query string ,if i use a request scope bean i am doing this at postconstruct method and every thing ok but when i need a session bean

problem begin because i have not any method which working before any other methods.I want to what is most proper way doing this.Actually i need a method which working before any other method as page_load of .net.I am using jsf 1.2 ,if you suggest phase listener is best choice please give me a g开发者_高级运维eneric example


You could define it as actionListener on all command links/buttons.

<h:commandButton actionListener="#{bean.listener}" action="#{bean.action1}" />
<h:commandButton actionListener="#{bean.listener}" action="#{bean.action2}" />

with

public void listener(ActionEvent event) {
    // ...
}

It will get invoked before the action method.

The best approach, however, is to just use request scoped beans for form actions. If you need some session scoped data in the request scoped bean, then just inject it as <managed-property> in the request scoped one by faces-config.xml.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜