[英]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. 这完全取决于请求的类型(POST或GET)和可用参数。 A plain vanilla GET request for example would fire the first and last phases only.
例如,普通的GET请求仅会触发第一阶段和最后阶段。 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. 默认情况下,“双重提交”(刷新表单提交)将经历所有阶段,但是根据
UIInput
和/或UICommand
组件中是否存在“ immediate="true"
,可能会跳过某些阶段。
You can create yourself a simple PhaseListener
and play around with it to learn which phases are executed and which not. 您可以创建自己一个简单的
PhaseListener
并进行操作,以了解执行了哪些阶段以及不执行哪些阶段。
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: 在
faces-config.xml
中将其注册如下,以使其运行:
<lifecycle>
<phase-listener>mypackage.LifeCycleListener</phase-listener>
</lifecycle>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.