1 package org.rcfaces.core.internal.taglib;
2
3 import javax.faces.application.Application;
4 import javax.faces.component.UIComponent;
5 import org.rcfaces.core.internal.component.Properties;
6 import javax.el.ValueExpression;
7 import javax.faces.component.UIViewRoot;
8 import org.apache.commons.logging.Log;
9 import javax.servlet.jsp.tagext.Tag;
10 import org.apache.commons.logging.LogFactory;
11 import org.rcfaces.core.internal.tools.ListenersTools1_2;
12 import org.rcfaces.core.component.ViewErrorListenerComponent;
13 import org.rcfaces.core.internal.tools.ListenersTools;
14 import javax.faces.context.FacesContext;
15
16 public class ViewErrorListenerTag extends CameliaTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(ViewErrorListenerTag.class);
20
21 private ValueExpression propertyChangeListeners;
22 private ValueExpression errorListeners;
23 public String getComponentType() {
24 return ViewErrorListenerComponent.COMPONENT_TYPE;
25 }
26
27 public final void setPropertyChangeListener(ValueExpression propertyChangeListeners) {
28 this.propertyChangeListeners = propertyChangeListeners;
29 }
30
31 public final void setErrorListener(ValueExpression errorListeners) {
32 this.errorListeners = errorListeners;
33 }
34
35 protected void setProperties(UIComponent uiComponent) {
36 if (LOG.isDebugEnabled()) {
37 if (ViewErrorListenerComponent.COMPONENT_TYPE==getComponentType()) {
38 LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
39 }
40 }
41 if ((uiComponent instanceof ViewErrorListenerComponent)==false) {
42 if (uiComponent instanceof UIViewRoot) {
43 throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
44 }
45 throw new IllegalStateException("Component specified by tag is not instanceof of 'ViewErrorListenerComponent'.");
46 }
47
48 super.setProperties(uiComponent);
49
50 ViewErrorListenerComponent component = (ViewErrorListenerComponent) uiComponent;
51 FacesContext facesContext = getFacesContext();
52
53 if (propertyChangeListeners != null) {
54 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.PROPERTY_CHANGE_LISTENER_TYPE, propertyChangeListeners);
55 }
56
57 if (errorListeners != null) {
58 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.ERROR_LISTENER_TYPE, errorListeners);
59 }
60 }
61
62 public void release() {
63 propertyChangeListeners = null;
64 errorListeners = null;
65
66 super.release();
67 }
68
69 }