1
2
3
4 package org.rcfaces.core.internal.renderkit;
5
6 import javax.el.ValueExpression;
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.internal.capability.IVariableScopeCapability;
12 import org.rcfaces.core.internal.component.Properties;
13
14
15
16
17
18 public abstract class AbstractCameliaRenderer extends AbstractCameliaRenderer0 {
19 private static final String REVISION = "$Revision: 1.17 $";
20
21 private static final Log LOG = LogFactory
22 .getLog(AbstractCameliaRenderer.class);
23
24 private static final String VARIABLE_SCOPE_PROPERTY = "camelia.VARIABLE_SCOPE";
25
26 protected void encodeBegin(IComponentWriter writer) throws WriterException {
27 UIComponent component = writer.getComponentRenderContext()
28 .getComponent();
29 if ((component instanceof IVariableScopeCapability) == false) {
30 return;
31 }
32
33 IVariableScopeCapability variableScopeCapability = (IVariableScopeCapability) component;
34
35 String var = variableScopeCapability.getScopeVar();
36 if (var == null || var.length() < 1) {
37 return;
38 }
39
40 Object value = variableScopeCapability.getScopeValue();
41 if (value == null) {
42 return;
43 }
44
45 ValueExpression valueExpression = component
46 .getValueExpression(Properties.SCOPE_VALUE);
47
48 writer.getComponentRenderContext().getRenderContext().pushScopeVar(var,
49 value, valueExpression, variableScopeCapability.isScopeSaveValue());
50
51 writer.getComponentRenderContext().setAttribute(
52 VARIABLE_SCOPE_PROPERTY, var);
53 }
54
55 protected void encodeEnd(IComponentWriter writer) throws WriterException {
56
57 String scopeVar = (String) writer.getComponentRenderContext()
58 .getAttribute(VARIABLE_SCOPE_PROPERTY);
59 if (scopeVar != null) {
60 writer.getComponentRenderContext().getRenderContext().popScopeVar(
61 scopeVar);
62 }
63
64 super.encodeEnd(writer);
65 }
66 }