论坛首页 Web前端技术论坛

自定义JSF PhaseListener监听器

浏览 1716 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2013-04-28  

自定义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;
    }

 }

 

论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics