在生命周期的特定阶段调用JSF 2.0绑定方法

时间:2012-07-18 14:09:33

标签: jsf jsf-2

我有以下情况:

    form1.xhtml:
    <h:commandButton action="#{bean1.action1}" /> <!-- action1 returns "form2" -->
    form2.xhtml:
    <h:form binding="#{bean2.init}">
    ...
    <h:commandButton action="#{bean2.action2}" /> <!-- *** -->
    </h:form>

    Bean2.java:
    @Named
    Bean2{
    public Object getInit(){
        return null;
    }

    public void setInit (Object i){
        //do something
    }

提交 form1 时,绑定方法setInit()在第6阶段执行RENDER_RESPONSE(在action1()返回“form2”之后)并显示form2。

提交 form2 时,如果action2()返回“null”,则在第1阶段RESTORE_VIEW期间执行setInit()。但是如果action2()返回“form2”而不是null,则在第6阶段调用该方法

你知道为什么吗?如果操作返回null,是否可以调用绑定方法?

非常感谢!

0 个答案:

没有答案