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 org.rcfaces.core.component.CardBoxComponent;
10  import javax.servlet.jsp.tagext.Tag;
11  import org.apache.commons.logging.LogFactory;
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 CardBoxTag extends AbstractInputTag implements Tag {
17  
18  
19  	private static final Log LOG=LogFactory.getLog(CardBoxTag.class);
20  
21  	private ValueExpression selectionListeners;
22  	private ValueExpression asyncRenderMode;
23  	private ValueExpression preferences;
24  	private ValueExpression scopeSaveValue;
25  	private ValueExpression scopeValue;
26  	private ValueExpression scopeVar;
27  	private ValueExpression asyncDecodeMode;
28  	public String getComponentType() {
29  		return CardBoxComponent.COMPONENT_TYPE;
30  	}
31  
32  	public final void setSelectionListener(ValueExpression selectionListeners) {
33  		this.selectionListeners = selectionListeners;
34  	}
35  
36  	public final void setAsyncRenderMode(ValueExpression asyncRenderMode) {
37  		this.asyncRenderMode = asyncRenderMode;
38  	}
39  
40  	public final void setPreferences(ValueExpression preferences) {
41  		this.preferences = preferences;
42  	}
43  
44  	public final void setScopeSaveValue(ValueExpression scopeSaveValue) {
45  		this.scopeSaveValue = scopeSaveValue;
46  	}
47  
48  	public final void setScopeValue(ValueExpression scopeValue) {
49  		this.scopeValue = scopeValue;
50  	}
51  
52  	public final void setScopeVar(ValueExpression scopeVar) {
53  		this.scopeVar = scopeVar;
54  	}
55  
56  	public final void setAsyncDecodeMode(ValueExpression asyncDecodeMode) {
57  		this.asyncDecodeMode = asyncDecodeMode;
58  	}
59  
60  	protected void setProperties(UIComponent uiComponent) {
61  		if (LOG.isDebugEnabled()) {
62  			if (CardBoxComponent.COMPONENT_TYPE==getComponentType()) {
63  				LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
64  			}
65  			LOG.debug("  asyncRenderMode='"+asyncRenderMode+"'");
66  			LOG.debug("  preferences='"+preferences+"'");
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 CardBoxComponent)==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 'CardBoxComponent'.");
77  		}
78  
79  		super.setProperties(uiComponent);
80  
81  		CardBoxComponent component = (CardBoxComponent) uiComponent;
82  		FacesContext facesContext = getFacesContext();
83  
84  		if (selectionListeners != null) {
85  			ListenersTools1_2.parseListener(facesContext, component, ListenersTools.SELECTION_LISTENER_TYPE, selectionListeners);
86  		}
87  
88  		if (asyncRenderMode != null) {
89  			if (asyncRenderMode.isLiteralText()==false) {
90  				component.setValueExpression(Properties.ASYNC_RENDER_MODE, asyncRenderMode);
91  
92  			} else {
93  				component.setAsyncRenderMode(asyncRenderMode.getExpressionString());
94  			}
95  		}
96  
97  		if (preferences != null) {
98  				component.setValueExpression(Properties.PREFERENCES, preferences);
99  		}
100 
101 		if (scopeSaveValue != null) {
102 			if (scopeSaveValue.isLiteralText()==false) {
103 				component.setValueExpression(Properties.SCOPE_SAVE_VALUE, scopeSaveValue);
104 
105 			} else {
106 				component.setScopeSaveValue(getBool(scopeSaveValue.getExpressionString()));
107 			}
108 		}
109 
110 		if (scopeValue != null) {
111 			if (scopeValue.isLiteralText()==false) {
112 				component.setValueExpression(Properties.SCOPE_VALUE, scopeValue);
113 
114 			} else {
115 				component.setScopeValue(scopeValue.getExpressionString());
116 			}
117 		}
118 
119 		if (scopeVar != null) {
120 			if (scopeVar.isLiteralText()==false) {
121 				component.setValueExpression(Properties.SCOPE_VAR, scopeVar);
122 
123 			} else {
124 				component.setScopeVar(scopeVar.getExpressionString());
125 			}
126 		}
127 
128 		if (asyncDecodeMode != null) {
129 			if (asyncDecodeMode.isLiteralText()==false) {
130 				component.setValueExpression(Properties.ASYNC_DECODE_MODE, asyncDecodeMode);
131 
132 			} else {
133 				component.setAsyncDecodeMode(asyncDecodeMode.getExpressionString());
134 			}
135 		}
136 	}
137 
138 	public void release() {
139 		selectionListeners = null;
140 		asyncRenderMode = null;
141 		preferences = null;
142 		scopeSaveValue = null;
143 		scopeValue = null;
144 		scopeVar = null;
145 		asyncDecodeMode = null;
146 
147 		super.release();
148 	}
149 
150 }