Author: nbelaevski
Date: 2009-06-03 20:06:54 -0400 (Wed, 03 Jun 2009)
New Revision: 14469
Modified:
branches/community/3.3.X/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/std/ScriptObjectTemplateElement.java
branches/community/3.3.X/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/std/ScriptOptionTemplateElement.java
Log:
https://jira.jboss.org/jira/browse/RF-7247
Modified:
branches/community/3.3.X/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/std/ScriptObjectTemplateElement.java
===================================================================
---
branches/community/3.3.X/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/std/ScriptObjectTemplateElement.java 2009-06-03
18:19:07 UTC (rev 14468)
+++
branches/community/3.3.X/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/std/ScriptObjectTemplateElement.java 2009-06-04
00:06:54 UTC (rev 14469)
@@ -26,7 +26,6 @@
import org.ajax4jsf.templatecompiler.builder.CompilationContext;
import org.ajax4jsf.templatecompiler.builder.CompilationException;
import org.ajax4jsf.templatecompiler.elements.A4JRendererElementsFactory;
-import org.ajax4jsf.templatecompiler.elements.TemplateElement;
import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
import org.apache.velocity.VelocityContext;
import org.w3c.dom.NamedNodeMap;
@@ -60,16 +59,14 @@
this.getComponentBean().addVariable(variableName, VARIABLE_TYPE);
}
- @Override
- public void addSubElement(TemplateElement e) {
- super.addSubElement(e);
-
- if (e instanceof ScriptOptionTemplateElement) {
- ((ScriptOptionTemplateElement) e).setMapName(variableName);
- }
- }
+ private static ThreadLocal<String> variableNamesStorage = new
ThreadLocal<String>();
public String getBeginElement() throws CompilationException {
+ if (variableNamesStorage.get() != null) {
+ throw new CompilationException("Nested c:scriptObject tags aren't
allowed!");
+ }
+ variableNamesStorage.set(variableName);
+
VelocityContext context = new VelocityContext();
context.put("variable", this.variableName);
context.put("type", VARIABLE_TYPE.getName().replace('$',
'.'));
@@ -85,6 +82,11 @@
}
public String getEndElement() {
+ variableNamesStorage.set(null);
return null;
}
+
+ static String getVariableName() {
+ return variableNamesStorage.get();
+ }
}
\ No newline at end of file
Modified:
branches/community/3.3.X/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/std/ScriptOptionTemplateElement.java
===================================================================
---
branches/community/3.3.X/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/std/ScriptOptionTemplateElement.java 2009-06-03
18:19:07 UTC (rev 14468)
+++
branches/community/3.3.X/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/std/ScriptOptionTemplateElement.java 2009-06-04
00:06:54 UTC (rev 14469)
@@ -48,8 +48,6 @@
private String defaultValue;
- private String mapName;
-
private String variables = null;
private String attributes = null;
@@ -152,10 +150,6 @@
}
}
- public void setMapName(String mapName) {
- this.mapName = mapName;
- }
-
protected String getTemplateName() {
return TEMPLATE;
}
@@ -163,7 +157,7 @@
public String getBeginElement() throws CompilationException {
VelocityContext context = new VelocityContext();
- context.put("mapName", mapName);
+ context.put("mapName", ScriptObjectTemplateElement.getVariableName());
context.put("valuesList", values);
if (!isEmpty(defaultValue)) {