View Javadoc

1   /*
2    * $Id: CheckListenerTag.java,v 1.1 2007/01/05 17:09:51 oeuillot Exp $
3    */
4   package org.rcfaces.core.internal.taglib;
5   
6   import javax.faces.FacesException;
7   import javax.faces.component.UIComponent;
8   
9   import org.apache.commons.logging.Log;
10  import org.apache.commons.logging.LogFactory;
11  import org.rcfaces.core.component.capability.ICheckEventCapability;
12  import org.rcfaces.core.event.ICheckListener;
13  
14  /**
15   * 
16   * @author Olivier Oeuillot (latest modification by $Author: oeuillot $)
17   * @version $Revision: 1.1 $ $Date: 2007/01/05 17:09:51 $
18   */
19  public class CheckListenerTag extends AbstractListenerTag {
20  
21      private static final String REVISION = "$Revision: 1.1 $";
22  
23      private static final long serialVersionUID = 4827027133242453987L;
24  
25      private static final Log LOG = LogFactory.getLog(CheckListenerTag.class);
26  
27      protected void addListener(Object type, UIComponent component) {
28          addCheckListener(type, component);
29      }
30  
31      public static void addCheckListener(Object listener, UIComponent component)
32              throws FacesException {
33          if ((listener instanceof ICheckListener) == false) {
34              throw new FacesException("Listener '" + listener
35                      + "' must implement ICheckListener.");
36          }
37  
38          ICheckListener checkListener = (ICheckListener) listener;
39  
40          if ((component instanceof ICheckEventCapability) == false) {
41              LOG.error("Component '" + component.getId()
42                      + "' does not implement ICheckEventCapability.");
43              return;
44          }
45  
46          ((ICheckEventCapability) component).addCheckListener(checkListener);
47  
48          if (LOG.isDebugEnabled()) {
49              LOG.debug("Add checkListener '" + checkListener
50                      + "' to component '" + component.getId() + "'.");
51          }
52      }
53  
54      protected String getListenerName() {
55          return "check";
56      }
57  
58  }