1
2
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.ISelectionEventCapability;
12 import org.rcfaces.core.event.ISelectionListener;
13
14
15
16
17
18
19 public class SelectionListenerTag extends AbstractListenerTag {
20 private static final String REVISION = "$Revision: 1.1 $";
21
22 private static final long serialVersionUID = 5117953058731866439L;
23
24 private static final Log LOG = LogFactory
25 .getLog(SelectionListenerTag.class);
26
27 protected void addListener(Object type, UIComponent component) {
28 addSelectionListener(type, component);
29 }
30
31 public static void addSelectionListener(Object listener,
32 UIComponent component) {
33 if ((listener instanceof ISelectionListener) == false) {
34 throw new FacesException("Listener '" + listener
35 + "' must implement ISelectionListener.");
36 }
37
38 ISelectionListener selectionListener = (ISelectionListener) listener;
39
40 if ((component instanceof ISelectionEventCapability) == false) {
41 LOG.error("Component '" + component.getId()
42 + "' does not implement ISelectionEventCapability.");
43 return;
44 }
45
46 ((ISelectionEventCapability) component)
47 .addSelectionListener(selectionListener);
48
49 if (LOG.isDebugEnabled()) {
50 LOG.debug("Add selectionListener '" + selectionListener
51 + "' to component '" + component.getId() + "'.");
52 }
53 }
54
55 protected String getListenerName() {
56 return "selection";
57 }
58
59 }