自定义JSF PhaseListener,需要实现javax.faces.event.PhaseListener.PhaseListener接口,页面使用可以直接用标签:
<f:phaseListener type="org.web.jsf.listener.RegistEditableValueChangePhaseListener"> </f:phaseListener> org.web.jsf.listener.RegistEditableValueChangePhaseListener为我的监听类
主要代码如下:
/* * Copyright (c) 2011-2036 International Air Transport Association corp. * All Rights Reserved. */ package org.iata.seurat.web.jsf.listener; import java.util.Iterator; import javax.faces.component.EditableValueHolder; import javax.faces.component.UIComponent; import javax.faces.component.UIInput; import javax.faces.component.UIViewRoot; import javax.faces.context.FacesContext; import javax.faces.event.PhaseEvent; import javax.faces.event.PhaseId; import javax.faces.event.PhaseListener; /** * Regist the Editable Value Changed. * * @author Xiao Jianbo, 2012-10-17 */ public class RegistEditableValueChangePhaseListener implements PhaseListener { private static final long serialVersionUID = 1L; /** * process after phase event. * * @param event - Phase Event */ @Override public void afterPhase(PhaseEvent event) { FacesContext context = event.getFacesContext(); boolean postback = context.getRenderKit().getResponseStateManager().isPostback(context); if (!postback) { } } @Override public void beforePhase(PhaseEvent event) { } @Override public PhaseId getPhaseId() { return PhaseId.RENDER_RESPONSE; } }