View Javadoc

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.ExternalBoxComponent;
13  import org.rcfaces.core.internal.tools.ListenersTools;
14  import javax.faces.context.FacesContext;
15  
16  public class ExternalBoxTag extends AbstractOutputTag implements Tag {
17  
18  
19  	private static final Log LOG=LogFactory.getLog(ExternalBoxTag.class);
20  
21  	private ValueExpression loadListeners;
22  	private ValueExpression overStyleClass;
23  	private ValueExpression scrolling;
24  	private ValueExpression contentURL;
25  	public String getComponentType() {
26  		return ExternalBoxComponent.COMPONENT_TYPE;
27  	}
28  
29  	public final void setLoadListener(ValueExpression loadListeners) {
30  		this.loadListeners = loadListeners;
31  	}
32  
33  	public final void setOverStyleClass(ValueExpression overStyleClass) {
34  		this.overStyleClass = overStyleClass;
35  	}
36  
37  	public final void setScrolling(ValueExpression scrolling) {
38  		this.scrolling = scrolling;
39  	}
40  
41  	public final void setContentURL(ValueExpression contentURL) {
42  		this.contentURL = contentURL;
43  	}
44  
45  	protected void setProperties(UIComponent uiComponent) {
46  		if (LOG.isDebugEnabled()) {
47  			if (ExternalBoxComponent.COMPONENT_TYPE==getComponentType()) {
48  				LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
49  			}
50  			LOG.debug("  overStyleClass='"+overStyleClass+"'");
51  			LOG.debug("  scrolling='"+scrolling+"'");
52  			LOG.debug("  contentURL='"+contentURL+"'");
53  		}
54  		if ((uiComponent instanceof ExternalBoxComponent)==false) {
55  			if (uiComponent instanceof UIViewRoot) {
56  				throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
57  			}
58  			throw new IllegalStateException("Component specified by tag is not instanceof of 'ExternalBoxComponent'.");
59  		}
60  
61  		super.setProperties(uiComponent);
62  
63  		ExternalBoxComponent component = (ExternalBoxComponent) uiComponent;
64  		FacesContext facesContext = getFacesContext();
65  
66  		if (loadListeners != null) {
67  			ListenersTools1_2.parseListener(facesContext, component, ListenersTools.LOAD_LISTENER_TYPE, loadListeners);
68  		}
69  
70  		if (overStyleClass != null) {
71  			if (overStyleClass.isLiteralText()==false) {
72  				component.setValueExpression(Properties.OVER_STYLE_CLASS, overStyleClass);
73  
74  			} else {
75  				component.setOverStyleClass(overStyleClass.getExpressionString());
76  			}
77  		}
78  
79  		if (scrolling != null) {
80  			if (scrolling.isLiteralText()==false) {
81  				component.setValueExpression(Properties.SCROLLING, scrolling);
82  
83  			} else {
84  				component.setScrolling(scrolling.getExpressionString());
85  			}
86  		}
87  
88  		if (contentURL != null) {
89  			if (contentURL.isLiteralText()==false) {
90  				component.setValueExpression(Properties.VALUE, contentURL);
91  
92  			} else {
93  				component.setContentURL(contentURL.getExpressionString());
94  			}
95  		}
96  	}
97  
98  	public void release() {
99  		loadListeners = null;
100 		overStyleClass = null;
101 		scrolling = null;
102 		contentURL = null;
103 
104 		super.release();
105 	}
106 
107 }