详细介绍:
http://www.ibm.com/developerworks/cn/java/j-jsf2/index.html可以编写一个
PhaseListener, 我们可以用她来了解 JSF's Request Processing Lifecycle如何工作的.
package com.jsf;
import javax.faces.event.PhaseListener;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
public class MyPhaseListener implements PhaseListener
{
public MyPhaseListener()
{
}
public void beforePhase(PhaseEvent pe)
{
if (pe.getPhaseId() == PhaseId.RESTORE_VIEW)
System.out.println("Processing new Request!");
System.out.println("before - " + pe.getPhaseId().toString());
}
public void afterPhase(PhaseEvent pe)
{
System.out.println("after - " + pe.getPhaseId().toString());
if (pe.getPhaseId() == PhaseId.RENDER_RESPONSE)
System.out.println("Done with Request!\n");
}
public PhaseId getPhaseId()
{
return PhaseId.ANY_PHASE;
}
}
|
当每一个阶段开始和结束的时候,她 在控制台上打印出一些东西.
你需要在 faces-config.xml中来注册该listener
<lifecycle>
<phase-listener>com.jsf.MyPhaseListener />
</lifecycle>
个人理解,可以在这个listener中
进行登录的验证,实现用户登录。而看了下netbeans示例程序JspJpa,
存在于“样例->企业->jspjpa ”中.就是这么实现的
阅读(1258) | 评论(0) | 转发(0) |