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.component.CardComponent;
12  import org.rcfaces.core.internal.tools.ListenersTools1_2;
13  import org.rcfaces.core.internal.tools.ListenersTools;
14  import javax.faces.context.FacesContext;
15  
16  public class CardTag extends AbstractOutputTag implements Tag {
17  
18  
19  	private static final Log LOG=LogFactory.getLog(CardTag.class);
20  
21  	private ValueExpression textAlignment;
22  	private ValueExpression verticalAlignment;
23  	private ValueExpression scopeSaveValue;
24  	private ValueExpression scopeValue;
25  	private ValueExpression scopeVar;
26  	private ValueExpression asyncDecodeMode;
27  	private ValueExpression loadListeners;
28  	public String getComponentType() {
29  		return CardComponent.COMPONENT_TYPE;
30  	}
31  
32  	public final void setTextAlignment(ValueExpression textAlignment) {
33  		this.textAlignment = textAlignment;
34  	}
35  
36  	public final void setVerticalAlignment(ValueExpression verticalAlignment) {
37  		this.verticalAlignment = verticalAlignment;
38  	}
39  
40  	public final void setScopeSaveValue(ValueExpression scopeSaveValue) {
41  		this.scopeSaveValue = scopeSaveValue;
42  	}
43  
44  	public final void setScopeValue(ValueExpression scopeValue) {
45  		this.scopeValue = scopeValue;
46  	}
47  
48  	public final void setScopeVar(ValueExpression scopeVar) {
49  		this.scopeVar = scopeVar;
50  	}
51  
52  	public final void setAsyncDecodeMode(ValueExpression asyncDecodeMode) {
53  		this.asyncDecodeMode = asyncDecodeMode;
54  	}
55  
56  	public final void setLoadListener(ValueExpression loadListeners) {
57  		this.loadListeners = loadListeners;
58  	}
59  
60  	protected void setProperties(UIComponent uiComponent) {
61  		if (LOG.isDebugEnabled()) {
62  			if (CardComponent.COMPONENT_TYPE==getComponentType()) {
63  				LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
64  			}
65  			LOG.debug("  textAlignment='"+textAlignment+"'");
66  			LOG.debug("  verticalAlignment='"+verticalAlignment+"'");
67  			LOG.debug("  scopeSaveValue='"+scopeSaveValue+"'");
68  			LOG.debug("  scopeValue='"+scopeValue+"'");
69  			LOG.debug("  scopeVar='"+scopeVar+"'");
70  			LOG.debug("  asyncDecodeMode='"+asyncDecodeMode+"'");
71  		}
72  		if ((uiComponent instanceof CardComponent)==false) {
73  			if (uiComponent instanceof UIViewRoot) {
74  				throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
75  			}
76  			throw new IllegalStateException("Component specified by tag is not instanceof of 'CardComponent'.");
77  		}
78  
79  		super.setProperties(uiComponent);
80  
81  		CardComponent component = (CardComponent) uiComponent;
82  		FacesContext facesContext = getFacesContext();
83  
84  		if (textAlignment != null) {
85  			if (textAlignment.isLiteralText()==false) {
86  				component.setValueExpression(Properties.TEXT_ALIGNMENT, textAlignment);
87  
88  			} else {
89  				component.setTextAlignment(textAlignment.getExpressionString());
90  			}
91  		}
92  
93  		if (verticalAlignment != null) {
94  			if (verticalAlignment.isLiteralText()==false) {
95  				component.setValueExpression(Properties.VERTICAL_ALIGNMENT, verticalAlignment);
96  
97  			} else {
98  				component.setVerticalAlignment(verticalAlignment.getExpressionString());
99  			}
100 		}
101 
102 		if (scopeSaveValue != null) {
103 			if (scopeSaveValue.isLiteralText()==false) {
104 				component.setValueExpression(Properties.SCOPE_SAVE_VALUE, scopeSaveValue);
105 
106 			} else {
107 				component.setScopeSaveValue(getBool(scopeSaveValue.getExpressionString()));
108 			}
109 		}
110 
111 		if (scopeValue != null) {
112 			if (scopeValue.isLiteralText()==false) {
113 				component.setValueExpression(Properties.SCOPE_VALUE, scopeValue);
114 
115 			} else {
116 				component.setScopeValue(scopeValue.getExpressionString());
117 			}
118 		}
119 
120 		if (scopeVar != null) {
121 			if (scopeVar.isLiteralText()==false) {
122 				component.setValueExpression(Properties.SCOPE_VAR, scopeVar);
123 
124 			} else {
125 				component.setScopeVar(scopeVar.getExpressionString());
126 			}
127 		}
128 
129 		if (asyncDecodeMode != null) {
130 			if (asyncDecodeMode.isLiteralText()==false) {
131 				component.setValueExpression(Properties.ASYNC_DECODE_MODE, asyncDecodeMode);
132 
133 			} else {
134 				component.setAsyncDecodeMode(asyncDecodeMode.getExpressionString());
135 			}
136 		}
137 
138 		if (loadListeners != null) {
139 			ListenersTools1_2.parseListener(facesContext, component, ListenersTools.LOAD_LISTENER_TYPE, loadListeners);
140 		}
141 	}
142 
143 	public void release() {
144 		textAlignment = null;
145 		verticalAlignment = null;
146 		scopeSaveValue = null;
147 		scopeValue = null;
148 		scopeVar = null;
149 		asyncDecodeMode = null;
150 		loadListeners = null;
151 
152 		super.release();
153 	}
154 
155 }