简体   繁体   中英

What phases of the JSF Life Cycle should get recalled on page refresh

页面刷新时应调用JSF生命周期的所有阶段的哪些内容

That entirely depends on the kind of request (POST or GET) and the available parameters. A plain vanilla GET request for example would fire the first and last phases only. A "double submit" (refreshing a form submit) would by default go through all phases, but depending on the presence of the immediate="true" in UIInput and/or UICommand components, some phases might be skipped.

You can create yourself a simple PhaseListener and play around with it to learn which phases are executed and which not.

package mypackage;

import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;

public class LifeCycleListener implements PhaseListener {

    public PhaseId getPhaseId() {
        return PhaseId.ANY_PHASE;
    }

    public void beforePhase(PhaseEvent event) {
        System.out.println("START PHASE " + event.getPhaseId());
    }

    public void afterPhase(PhaseEvent event) {
        System.out.println("END PHASE " + event.getPhaseId());
    }

}

Register it as follows in faces-config.xml to get it to run:

<lifecycle>
    <phase-listener>mypackage.LifeCycleListener</phase-listener>
</lifecycle>

See also:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM