Author: alexsmirnov
Date: 2010-07-07 19:41:01 -0400 (Wed, 07 Jul 2010)
New Revision: 17767
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AttributesStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-attributes-set.ftl
Log:
https://jira.jboss.org/browse/RF-8306
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AttributesStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AttributesStatement.java 2010-07-07
22:30:23 UTC (rev 17766)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AttributesStatement.java 2010-07-07
23:41:01 UTC (rev 17767)
@@ -36,7 +36,7 @@
*/
public class AttributesStatement extends StatementsContainer {
- private static final Splitter PASS_THGOUGH_SPLITTER =
Splitter.on(Pattern.compile("\\s*,\\s*"));
+ private static final Splitter PASS_THGOUGH_SPLITTER =
Splitter.on(Pattern.compile("\\s+,?\\s*"));
private final Schema attributesSchema;
private final Provider<WriteAttributeStatement> statementProvider;
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java 2010-07-07
22:30:23 UTC (rev 17766)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java 2010-07-07
23:41:01 UTC (rev 17767)
@@ -46,6 +46,14 @@
String type;
Object defaultValue;
Set<String> behaviors = Sets.newHashSet();
+
+ public String getBuilderMethod() {
+ if(Kind.BOOLEAN.equals(kind)){
+ return "bool";
+ } else {
+ return kind.toString().toLowerCase();
+ }
+ }
@Override
public int compareTo(PassThrough o) {
@@ -60,24 +68,41 @@
private static AtomicInteger fieldCounter = new AtomicInteger(0);
- private String passThroughFieldName;
+ private String fieldName;
+ private TreeSet<PassThrough> attributes;
+
@Inject
public WriteAttributesSetStatement(@TemplateModel FreeMarkerRenderer renderer) {
super(renderer, "write-attributes-set");
- passThroughFieldName = PASS_THROUGH_ATTRIBUTES_FIELD_NAME +
fieldCounter.getAndIncrement();
+ fieldName = PASS_THROUGH_ATTRIBUTES_FIELD_NAME + fieldCounter.getAndIncrement();
}
/**
- * @return the passThroughFieldName
+ * @return the fieldName
*/
- public String getPassThroughFieldName() {
- return passThroughFieldName;
+ public String getFieldName() {
+ return fieldName;
}
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param fieldName the fieldName to set
+ */
+ public void setFieldName(String fieldName) {
+ this.fieldName = fieldName;
+ }
+
public void setAttributes(TreeSet<PassThrough> passThroughAttributes) {
- // TODO Auto-generated method stub
-
+ this.attributes = passThroughAttributes;
}
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the attributes
+ */
+ public TreeSet<PassThrough> getAttributes() {
+ return this.attributes;
+ }
+
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-attributes-set.ftl
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-attributes-set.ftl 2010-07-07
22:30:23 UTC (rev 17766)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-attributes-set.ftl 2010-07-07
23:41:01 UTC (rev 17767)
@@ -1,2 +1,6 @@
-RenderKitUtils.renderPassThroughAttributes(${facesContextVariable}, ${componentVariable},
- ${modelItem.passThroughFieldName});
\ No newline at end of file
+<(a)util.constant "Attributes" "${fieldName}"><#list
attributes as attribute>
+
.{attribute.builderMethod}(${attribute.name},${attribute.componentAttribute}<#list
attribute.behaviors as behavior>,${behavior}</#list>)
+</#list></(a)util.constant>
+<(a)util.require "RENDER_ATTRIBUTES_SET"/>
+renderPassThroughAttributes(${facesContextVariable}, ${componentVariable},
+ ${fieldName});
\ No newline at end of file