Author: alexsmirnov
Date: 2010-07-09 19:05:13 -0400 (Fri, 09 Jul 2010)
New Revision: 17794
Added:
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/create-attributes.ftl
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/render-attributes-set.ftl
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/StartElementTest.java
Modified:
root/cdk/branches/RF8755/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Adapters.java
root/cdk/branches/RF8755/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Attribute.java
root/cdk/branches/RF8755/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Element.java
root/cdk/branches/RF8755/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Schema.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/RequireImports.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/RuntimeImport.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ResourceDependency.java
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/HelperMethod.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodFactoryImpl.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/RendererUtilsMethod.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/SwitchStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/case.ftl
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/class.ftl
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/constant-return.ftl
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/end-element.ftl
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/if-else.ftl
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/start-element.ftl
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/switch.ftl
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-attribute.ftl
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-boolean-attribute.ftl
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-uri-attribute.ftl
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateParserTest.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectTest.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/ForEachTest.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/WtiteTextTest.java
root/cdk/branches/RF8755/plugins/maven-cdk-plugin/src/it/annotated-component/pom.xml
root/cdk/branches/RF8755/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/templates/testComponent.xml
Log:
https://jira.jboss.org/browse/RF-8306 - done
Modified:
root/cdk/branches/RF8755/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Adapters.java
===================================================================
---
root/cdk/branches/RF8755/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Adapters.java 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Adapters.java 2010-07-09
23:05:13 UTC (rev 17794)
@@ -86,7 +86,20 @@
}
}
+
+ public static final class NormalizedStringAdapter extends XmlAdapter<String,
String> {
+ @Override
+ public String marshal(String text) {
+ return text.trim();
+ }
+
+ @Override
+ public String unmarshal(String v) throws Exception {
+ return v.trim();
+ }
+ }
+
private Adapters() {
}
}
Modified:
root/cdk/branches/RF8755/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Attribute.java
===================================================================
---
root/cdk/branches/RF8755/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Attribute.java 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Attribute.java 2010-07-09
23:05:13 UTC (rev 17794)
@@ -27,6 +27,7 @@
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
* @author Nick Belaevski
@@ -78,6 +79,7 @@
* @return the name
*/
@XmlElement
+ @XmlJavaTypeAdapter(Adapters.NormalizedStringAdapter.class)
public String getName() {
return name;
}
@@ -113,6 +115,7 @@
* @return the defaultValue
*/
@XmlElement(name = "default-value")
+ @XmlJavaTypeAdapter(Adapters.NormalizedStringAdapter.class)
public String getDefaultValue() {
return defaultValue;
}
@@ -143,6 +146,7 @@
* @return the componentAttributeName
*/
@XmlElement(name = "component-attribute-name")
+ @XmlJavaTypeAdapter(Adapters.NormalizedStringAdapter.class)
public String getComponentAttributeName() {
return componentAttributeName != null ? componentAttributeName : name;
}
Modified:
root/cdk/branches/RF8755/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Element.java
===================================================================
---
root/cdk/branches/RF8755/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Element.java 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Element.java 2010-07-09
23:05:13 UTC (rev 17794)
@@ -71,6 +71,7 @@
* @return the name
*/
@XmlElement
+ @XmlJavaTypeAdapter(Adapters.NormalizedStringAdapter.class)
public String getName() {
return name;
}
Modified:
root/cdk/branches/RF8755/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Schema.java
===================================================================
---
root/cdk/branches/RF8755/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Schema.java 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Schema.java 2010-07-09
23:05:13 UTC (rev 17794)
@@ -71,6 +71,7 @@
* @return the namespace
*/
@XmlElement
+ @XmlJavaTypeAdapter(Adapters.NormalizedStringAdapter.class)
public String getNamespace() {
return namespace;
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-07-09
23:05:13 UTC (rev 17794)
@@ -27,8 +27,10 @@
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.EnumSet;
+import java.util.List;
import java.util.Set;
+import javax.faces.application.ResourceDependencies;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -60,6 +62,7 @@
import org.richfaces.cdk.templatecompiler.model.CdkWhenElement;
import org.richfaces.cdk.templatecompiler.model.CompositeImplementation;
import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
+import org.richfaces.cdk.templatecompiler.model.ResourceDependency;
import org.richfaces.cdk.templatecompiler.model.Template;
import org.richfaces.cdk.templatecompiler.model.TemplateVisitor;
import org.richfaces.cdk.templatecompiler.statements.AttributesStatement;
@@ -117,11 +120,12 @@
*
*/
public static final String FACES_CONTEXT_VARIABLE = "facesContext";
- public static final ImmutableMap<String, Object> ENCODE_METHOD_VARIABLES =
ImmutableMap.<String, Object> builder()
- .put("facesContextVariable",
RendererClassVisitor.FACES_CONTEXT_VARIABLE)
- .put("componentVariable", RendererClassVisitor.COMPONENT_VARIABLE)
- .put("responseWriterVariable",
RendererClassVisitor.RESPONSE_WRITER_VARIABLE)
- .put("clientIdVariable",
RendererClassVisitor.CLIENT_ID_VARIABLE).build();
+ public static final ImmutableMap<String, Object> ENCODE_METHOD_VARIABLES =
+ ImmutableMap.<String, Object> builder()
+ .put("facesContextVariable",
RendererClassVisitor.FACES_CONTEXT_VARIABLE).put("componentVariable",
+
RendererClassVisitor.COMPONENT_VARIABLE).put("responseWriterVariable",
+
RendererClassVisitor.RESPONSE_WRITER_VARIABLE).put("clientIdVariable",
+ RendererClassVisitor.CLIENT_ID_VARIABLE).build();
/**
*
*/
@@ -171,9 +175,34 @@
// TODO remove this after improving Java model
// this.generatedClass.addImport(Generated.class);
+ List<ResourceDependency> resourceDependencies =
compositeInterface.getResourceDependencies();
+ ELType dependencyType =
typesFactory.getType(javax.faces.application.ResourceDependency.class);
+ if (1 == resourceDependencies.size()) {
+ ResourceDependency resource = resourceDependencies.get(0);
+ this.generatedClass.addAnnotation(createResourceAnnotation(dependencyType,
resource));
+ } else if (resourceDependencies.size() > 1) {
+ StringBuilder resources = new StringBuilder("{");
+ for (ResourceDependency resource : resourceDependencies) {
+ if (resources.length() > 1) {
+ resources.append(',');
+ }
+ resources.append("@ResourceDependency(");
+
resources.append("name=\"").append(resource.getName()).append("\",library=\"").append(
+
resource.getLibrary()).append("\",target=\"").append(resource.getTarget()).append("\"").append(")");
+ }
+ resources.append("}");
+ this.generatedClass.addAnnotation(new
JavaAnnotation(typesFactory.getType(ResourceDependencies.class),
+ resources.toString()));
+
this.generatedClass.addImport(javax.faces.application.ResourceDependency.class);
+ }
this.createMethodContext();
}
+ private JavaAnnotation createResourceAnnotation(ELType dependencyType,
ResourceDependency resource) {
+ return new JavaAnnotation(dependencyType, "name=\"" +
resource.getName() + "\"", "library=\""
+ + resource.getLibrary() + "\"", "target=\"" +
resource.getTarget() + "\"");
+ }
+
private void addHelperMethod(HelperMethod helperMethod) {
if (addedHelperMethods.add(helperMethod)) {
JavaMethod helperJavaMethod =
helperMethodFactory.getHelperMethod(helperMethod);
@@ -278,7 +307,6 @@
}
protected void addStatement(TemplateStatement statement) {
- addHelperMethods(statement);
currentStatement.addStatement(statement);
}
@@ -327,7 +355,7 @@
public void startElement(AnyElement anyElement) throws CdkException {
QName elementName = anyElement.getName();
if (Template.isDirectiveNamespace(elementName)) {
- log.error("Unknown directive element "+elementName);
+ log.error("Unknown directive element " + elementName);
} else {
StartElementStatement startElementStatement =
addStatement(StartElementStatement.class);
startElementStatement.setElementName(elementName);
@@ -360,7 +388,7 @@
public void visitElement(String text) throws CdkException {
if (text != null) {
String trimmedText = text.trim();
- if (trimmedText.length()>0) {
+ if (trimmedText.length() > 0) {
WriteTextStatement statement = addStatement(WriteTextStatement.class);
statement.setExpression(trimmedText);
}
@@ -499,7 +527,7 @@
}
String type = cdkObjectElement.getType();
DefineObjectStatement statement = addStatement(DefineObjectStatement.class);
- statement.setObject(name,type,value);
+ statement.setObject(name, type, value);
}
/*
@@ -520,7 +548,7 @@
// collectionElementClass = Object.class;
// }
ForEachStatement forEachStatement = pushStatement(ForEachStatement.class);
- forEachStatement.setItemsExpression(items,cdkForEachElement.getVar());
+ forEachStatement.setItemsExpression(items, cdkForEachElement.getVar());
// currentStatement.setVariable(cdkForEachElement.getVar(),
lastCompiledExpressionType.getContainerType());
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/RequireImports.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/RequireImports.java 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/RequireImports.java 2010-07-09
23:05:13 UTC (rev 17794)
@@ -1,6 +1,8 @@
package org.richfaces.cdk.templatecompiler.builder.model;
+import java.util.Collections;
+
import com.google.common.base.Function;
public interface RequireImports {
@@ -8,6 +10,9 @@
@Override
public Iterable<JavaImport> apply(RequireImports from) {
+ if(null == from){
+ return Collections.emptySet();
+ }
return from.getRequiredImports();
}
};
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/RuntimeImport.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/RuntimeImport.java 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/RuntimeImport.java 2010-07-09
23:05:13 UTC (rev 17794)
@@ -21,6 +21,8 @@
package org.richfaces.cdk.templatecompiler.builder.model;
+import java.util.regex.Pattern;
+
/**
* Implementation of import taht cannot be resolved in design time
*
@@ -28,6 +30,8 @@
*/
public class RuntimeImport implements JavaImport {
+ private static final Pattern JAVA_LANG_PATTERN =
Pattern.compile("^java\\.lang\\.[^\\.]+$");
+
private String name;
public RuntimeImport(String name) {
@@ -46,7 +50,7 @@
return true;
}
- if (name.matches("^java\\.lang\\.[^\\.]+$")) {
+ if (JAVA_LANG_PATTERN.matcher(name).matches()) {
return true;
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ResourceDependency.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ResourceDependency.java 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ResourceDependency.java 2010-07-09
23:05:13 UTC (rev 17794)
@@ -39,9 +39,9 @@
private String name;
- private String library;
+ private String library ="";
- private String target = "head";
+ private String target = "";
/**
* <p class="changed_added_4_0"></p>
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-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AttributesStatement.java 2010-07-09
23:05:13 UTC (rev 17794)
@@ -154,7 +154,7 @@
passThrough.kind = schemaAttribute.getKind();
passThrough.defaultValue = schemaAttribute.getDefaultValue();
try {
- PropertyBase componetProperty = findComponentAttribute(componentAttribute);
+ PropertyBase componetProperty =
findComponentAttribute(passThrough.componentAttribute);
passThrough.type = componetProperty.getType().toString();
for (EventName event : componetProperty.getEventNames()) {
passThrough.behaviors.add(event.getName());
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethod.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethod.java 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethod.java 2010-07-09
23:05:13 UTC (rev 17794)
@@ -44,7 +44,7 @@
EMPTINESS_CHECK(IS_EMPTY_FUNCTION, Boolean.TYPE, Object.class),
EQUALS_CHECK(IS_EQUAL_FUNCTION, Boolean.TYPE, Object.class, Object.class),
SHOULD_RENDER_ATTRIBUTE("shouldRenderAttribute", Boolean.TYPE,
Object.class),
- CREATE_ATTRIBUTES("attributes", Collection.class),// TODO - define
RenderKitUtils.Attributes type ?
+ CREATE_ATTRIBUTES("attributes", "Attributes"),
RENDER_ATTRIBUTES_SET("renderPassThroughAttributes",
Void.TYPE,FacesContext.class,UIComponent.class,Collection.class),
RENDER_ATTRIBUTE("renderAttribute",Void.TYPE,FacesContext.class,String.class,Object.class);
@@ -52,11 +52,11 @@
private static final Set<HelperMethod> CONVERSION_METHODS =
EnumSet.of(TO_STRING_CONVERSION, TO_BOOLEAN_CONVERSION);
- private String name;
+ private final String name;
- private Class<?> returnType;
+ private final String returnType;
- private Class<?>[] argumentTypes;
+ private final Class<?>[] argumentTypes;
static {
for (HelperMethod method : HelperMethod.values()) {
@@ -64,18 +64,21 @@
}
}
-
- private HelperMethod(String name, Class<?> returnType, Class<?>...
argumentTypes) {
+ private HelperMethod(String name, String returnType, Class<?>... argumentTypes)
{
this.name = name;
this.returnType = returnType;
this.argumentTypes = argumentTypes;
}
+
+ private HelperMethod(String name, Class<?> returnType, Class<?>...
argumentTypes) {
+ this(name,returnType.getName(),argumentTypes);
+ }
public String getName() {
return name;
}
- public Class<?> getReturnType() {
+ public String getReturnType() {
return returnType;
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodFactoryImpl.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodFactoryImpl.java 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodFactoryImpl.java 2010-07-09
23:05:13 UTC (rev 17794)
@@ -23,7 +23,9 @@
package org.richfaces.cdk.templatecompiler.statements;
+import java.io.IOException;
import java.util.EnumMap;
+import java.util.List;
import org.richfaces.cdk.Generator;
import org.richfaces.cdk.Logger;
@@ -82,22 +84,25 @@
buildHelperMethod(HelperMethod.TO_BOOLEAN_CONVERSION, false,
"conversion-to-boolean-method", "object");
buildHelperMethod(HelperMethod.TO_STRING_CONVERSION, false,
"conversion-to-string-method", "object");
buildHelperMethod(HelperMethod.SHOULD_RENDER_ATTRIBUTE, true,
"should-render-attribute", "attributeValue");
- buildHelperMethod(HelperMethod.RENDER_ATTRIBUTE, true,
"render-attribute", "attributeValue");
- buildHelperMethod(HelperMethod.RENDER_ATTRIBUTES_SET, true,
"render-attributes-set",
"context","component","attributes");
+ buildHelperMethod(HelperMethod.RENDER_ATTRIBUTE, true,
"render-attribute",
"attributeValue").getExceptions().add(typesFactory.getType(IOException.class));
+ JavaMethod renderAttributes =
buildHelperMethod(HelperMethod.RENDER_ATTRIBUTES_SET, true,
"render-attributes-set", "context","component");
+ // TODO - put unknown 'Attributes' class into HelperMethod.
+ List<Argument> arguments = renderAttributes.getArguments();
+ arguments.add(new
Argument("attributes",typesFactory.getType("Attributes")));
+ renderAttributes.getExceptions().add(typesFactory.getType(IOException.class));
buildHelperMethod(HelperMethod.CREATE_ATTRIBUTES, true,
"create-attributes");
}
private JavaMethod buildHelperMethod(HelperMethod helperMethod, boolean utilsMethod,
String templateName,
String... argumentNames) {
JavaMethod helperJavaMethod;
- if (utilsMethod && null != rendererUtilsClass) {
+ if (utilsMethod &&
!RendererUtilsMethod.BUILT_IN.equals(rendererUtilsClass)) {
helperJavaMethod = new RendererUtilsMethod(helperMethod,
rendererUtilsClass);
} else {
Class<?>[] argumentTypes = helperMethod.getArgumentTypes();
- Argument[] arguments = new Argument[argumentTypes.length];
- for (int i = 0; i < arguments.length; i++) {
- String argumentName = i < argumentNames.length ? argumentNames[i] :
"arg" + i;
- arguments[i] = new Argument(argumentName,
typesFactory.getType(argumentTypes[i]));
+ Argument[] arguments = new Argument[argumentNames.length];
+ for (int i = 0; i < argumentNames.length; i++) {
+ arguments[i] = new Argument(argumentNames[i],
typesFactory.getType(argumentTypes[i]));
}
ELType returnType = typesFactory.getType(helperMethod.getReturnType());
helperJavaMethod = new JavaMethod(helperMethod.getName(), returnType,
arguments);
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/RendererUtilsMethod.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/RendererUtilsMethod.java 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/RendererUtilsMethod.java 2010-07-09
23:05:13 UTC (rev 17794)
@@ -23,24 +23,31 @@
package org.richfaces.cdk.templatecompiler.statements;
-import java.util.Collections;
+import java.util.TreeSet;
import org.richfaces.cdk.templatecompiler.builder.model.JavaImport;
import org.richfaces.cdk.templatecompiler.builder.model.JavaMethod;
import org.richfaces.cdk.templatecompiler.builder.model.RuntimeImport;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
public class RendererUtilsMethod extends JavaMethod {
+
+ public static final String BUILT_IN = "#built-in";
- private Iterable<JavaImport> runtimeImport;
+ private TreeSet<JavaImport> runtimeImport =
Sets.newTreeSet(JavaImport.COMPARATOR);
public RendererUtilsMethod(HelperMethod helper,String rendererUtilsClassName) {
super(helper.getName());
- this.runtimeImport = Collections.<JavaImport>singleton(new
RuntimeImport(rendererUtilsClassName));
+ this.runtimeImport.add(new RuntimeImport("static "
+rendererUtilsClassName+".*"));
+ this.runtimeImport.add(new RuntimeImport(rendererUtilsClassName));
+ this.runtimeImport.add(new
RuntimeImport(rendererUtilsClassName+".Attributes"));
}
@Override
@@ -50,6 +57,6 @@
@Override
public Iterable<JavaImport> getRequiredImports() {
- return runtimeImport;
+ return Iterables.concat(super.getRequiredImports(),runtimeImport);
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/SwitchStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/SwitchStatement.java 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/SwitchStatement.java 2010-07-09
23:05:13 UTC (rev 17794)
@@ -21,9 +21,16 @@
*/
package org.richfaces.cdk.templatecompiler.statements;
+import org.richfaces.cdk.Logger;
import org.richfaces.cdk.generate.freemarker.FreeMarkerRenderer;
+import org.richfaces.cdk.templatecompiler.ELParser;
import org.richfaces.cdk.templatecompiler.TemplateModel;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaField;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaImport;
+import org.richfaces.cdk.templatecompiler.el.ParsingException;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+import com.google.common.collect.Iterables;
import com.google.inject.Inject;
/**
@@ -32,17 +39,22 @@
public class SwitchStatement extends FreeMarkerTemplateStatementBase {
private String keyExpression;
+ private final ELParser parser;
+ private final Logger log;
+ private TypedTemplateStatement statement;
@Inject
- public SwitchStatement(@TemplateModel FreeMarkerRenderer renderer) {
+ public SwitchStatement(@TemplateModel FreeMarkerRenderer renderer,ELParser
parser,Logger log) {
super(renderer,"switch");
+ this.parser = parser;
+ this.log = log;
}
/**
* @return the keyExpression
*/
- public String getKeyExpression() {
- return keyExpression;
+ public TemplateStatement getKeyExpression() {
+ return statement;
}
/**
@@ -50,6 +62,26 @@
* @param keyExpression the keyExpression to set
*/
public void setKeyExpression(String keyExpression) {
- this.keyExpression = keyExpression;
+ try {
+ this.keyExpression = keyExpression;
+ this.statement = parser.parse(keyExpression, this,
TypesFactory.OBJECT_TYPE);
+ statement.setParent(this);
+ } catch (ParsingException e) {
+ log.error("Error parse switch statement expression", e);
+ }
}
+ @Override
+ public Iterable<JavaImport> getRequiredImports() {
+ return
Iterables.concat(super.getRequiredImports(),statement.getRequiredImports());
+ }
+
+ @Override
+ public Iterable<HelperMethod> getRequiredMethods() {
+ return
Iterables.concat(super.getRequiredMethods(),statement.getRequiredMethods());
+ }
+
+ @Override
+ public Iterable<JavaField> getRequiredFields() {
+ return
Iterables.concat(super.getRequiredFields(),statement.getRequiredFields());
+ }
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/case.ftl
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/case.ftl 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/case.ftl 2010-07-09
23:05:13 UTC (rev 17794)
@@ -1,11 +1,11 @@
-<#if modelItem.default>
+<#if default>
default:
<#else>
- <#list modelItem.values as value>
+ <#list values as value>
case ${value}:
</#list>
</#if>
- <#list modelItem.statements as subStatement>
+ <#list statements as subStatement>
${subStatement.code}
</#list>
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/class.ftl
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/class.ftl 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/class.ftl 2010-07-09
23:05:13 UTC (rev 17794)
@@ -1,24 +1,20 @@
-package ${modelItem.package.name};
+package ${package.name};
-<#list modelItem.imports as import>
+<#list imports as import><#if !import.default >
import ${import.name};
-</#list>
+</#if></#list>
-<@renderCommonJavaElementStuff element=modelItem />class ${modelItem.simpleName}
<#if modelItem.superClass.name != 'java.lang.Object'>extends
${modelItem.superClass.simpleName} </#if>{
- <#list modelItem.fields as field>
- <@renderCommonJavaElementStuff element=field
/>${field.type.simpleName}${field.genericSignature} ${field.name}<#if
field.value??> = ${field.value}</#if>;
+<@renderCommonJavaElementStuff element=.data_model />class ${simpleName} <#if
superClass.name != 'java.lang.Object'>extends ${superClass.simpleName}
</#if>{
+ <#list fields as field>
+ <@renderCommonJavaElementStuff element=field />${field.type} ${field.name}<#if
field.value??> = ${field.value}</#if>;
</#list>
- <#list modelItem.methods as method>
- <@renderCommonJavaElementStuff element=method />${method.returnType.simpleName}
${method.name}(<#list method.arguments as argument>${argument.type.simpleName}
${argument.name}<#if argument_has_next>, </#if></#list>)
+ <#list methods as method>
+ <@renderCommonJavaElementStuff element=method />${method.returnType}
${method.name}(<#list method.arguments as argument>${argument.type}
${argument.name}<#if argument_has_next>, </#if></#list>)
<#if !method.exceptions.empty>
- throws <#list method.exceptions as exception>${exception.simpleName}<#if
exception_has_next>, </#if></#list>
+ throws <#list method.exceptions as exception>${exception}<#if
exception_has_next>, </#if></#list>
</#if> {
- <#if method.methodBody??>
- <#list method.methodBody.statements as methodStatement>
- ${methodStatement.code}
- </#list>
- </#if>
+ ${method.methodBody!}
}
</#list>
}
@@ -33,6 +29,6 @@
*/
</#if>
<#list element.annotations as annotation>
-(a)${annotation.type.simpleName}<#if !annotation.arguments.empty>(<#list
annotation.arguments as argument>${argument}<#if argument_has_next>,
</#if></#list>)</#if>
+(a)${annotation.type}<#if !annotation.arguments.empty>(<#list annotation.arguments
as argument>${argument}<#if argument_has_next>,
</#if></#list>)</#if>
</#list>
<#list element.modifiers as modifier>${modifier} </#list></#macro>
\ No newline at end of file
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/constant-return.ftl
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/constant-return.ftl 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/constant-return.ftl 2010-07-09
23:05:13 UTC (rev 17794)
@@ -1 +1 @@
-return ${modelItem.returnValue};
\ No newline at end of file
+return ${returnValue};
\ No newline at end of file
Added:
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/create-attributes.ftl
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/create-attributes.ftl
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/create-attributes.ftl 2010-07-09
23:05:13 UTC (rev 17794)
@@ -0,0 +1,100 @@
+<(a)util.import "java.util.TreeSet" />
+ return new Attributes();
+ }
+
+ private enum Kind {
+ BOOL,
+ GENERIC,
+ URI
+ }
+
+ private static final class ComponentAttribute implements
Comparable<ComponentAttribute> {
+
+
+ private final String htmlAttributeName;
+
+ private String componentAttributeName;
+
+ private Object defaultValue;
+
+
+ private String[] eventNames = {};
+
+ private Kind kind = Kind.GENERIC;
+
+ public ComponentAttribute(String htmlAttributeName) {
+ super();
+ this.htmlAttributeName = htmlAttributeName;
+ }
+
+ public Kind getKind() {
+ return this.kind;
+ }
+
+
+ public Object getDefaultValue() {
+ return this.defaultValue;
+ }
+
+
+
+ public String getHtmlAttributeName() {
+ return htmlAttributeName;
+ }
+
+ public String getComponentAttributeName() {
+ return componentAttributeName;
+ }
+
+
+ public String[] getEventNames() {
+ return eventNames;
+ }
+
+
+ public int compareTo(ComponentAttribute o) {
+ return getHtmlAttributeName().compareTo(o.getHtmlAttributeName());
+ }
+}
+
+ @SuppressWarnings("serial")
+ public static final class Attributes extends TreeSet<ComponentAttribute> {
+
+ private ComponentAttribute last;
+
+ public void render(FacesContext context, UIComponent component) throws
IOException {
+ renderPassThroughAttributes(context, component, this);
+ }
+
+ public Attributes generic(String name, String componentAttribute, String...
events) {
+ ComponentAttribute attribute = createAttribute(name, componentAttribute);
+ attribute.eventNames = events;
+ attribute.kind=Kind.GENERIC;
+ return this;
+ }
+
+ private ComponentAttribute createAttribute(String name, String
componentAttribute) {
+ ComponentAttribute attribute = new ComponentAttribute(name);
+ attribute.componentAttributeName= componentAttribute;
+ add(attribute);
+ last = attribute;
+ return attribute;
+ }
+
+ public Attributes uri(String name, String componentAttribute) {
+ ComponentAttribute attribute = createAttribute(name, componentAttribute);
+ attribute.kind =Kind.URI;
+ return this;
+ }
+
+ public Attributes bool(String name, String componentAttribute) {
+ ComponentAttribute attribute = createAttribute(name, componentAttribute);
+ attribute.kind = Kind.BOOL;
+ return this;
+ }
+
+ public Attributes defaultValue(Object value){
+ last.defaultValue =value;
+ return this;
+ }
+
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/end-element.ftl
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/end-element.ftl 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/end-element.ftl 2010-07-09
23:05:13 UTC (rev 17794)
@@ -1 +1 @@
-${responseWriterVariable}.endElement("${modelItem.elementName}");
\ No newline at end of file
+${responseWriterVariable}.endElement("${elementName}");
\ No newline at end of file
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/if-else.ftl
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/if-else.ftl 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/if-else.ftl 2010-07-09
23:05:13 UTC (rev 17794)
@@ -1,4 +1,4 @@
-<#list modelItem.statements as statement>
+<#list statements as statement>
<#if statement_index == 0>
if (${statement.test}) {
<#else>
Added:
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/render-attributes-set.ftl
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/render-attributes-set.ftl
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/render-attributes-set.ftl 2010-07-09
23:05:13 UTC (rev 17794)
@@ -0,0 +1,8 @@
+ for (ComponentAttribute knownAttribute : attributes) {
+ renderAttributeAndBehaviors(context, component, knownAttribute);
+ }
+ }
+
+ public static void renderAttributeAndBehaviors(FacesContext facesContext, UIComponent
component,
+ ComponentAttribute componentAttribute) throws IOException {
+
\ No newline at end of file
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/start-element.ftl
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/start-element.ftl 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/start-element.ftl 2010-07-09
23:05:13 UTC (rev 17794)
@@ -1 +1 @@
-${responseWriterVariable}.startElement("${modelItem.elementName}",
${componentVariable});
\ No newline at end of file
+${responseWriterVariable}.startElement("${elementName}", ${componentVariable});
\ No newline at end of file
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/switch.ftl
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/switch.ftl 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/switch.ftl 2010-07-09
23:05:13 UTC (rev 17794)
@@ -1,5 +1,5 @@
-switch (${modelItem.keyExpression}) {
- <#list modelItem.statements as subStatement>
+switch (${keyExpression}) {
+ <#list statements as subStatement>
${subStatement.code}
</#list>
}
\ No newline at end of file
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-attribute.ftl
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-attribute.ftl 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-attribute.ftl 2010-07-09
23:05:13 UTC (rev 17794)
@@ -1,5 +1,5 @@
<#if value.literal>
- ${responseWriterVariable}.writeAttribute(${attributeName},${value},null);
+ ${responseWriterVariable}.writeAttribute("${attributeName}",${value},null);
<#else>
{
${value.type} value = ${value};
@@ -27,10 +27,10 @@
)) {
value="${defaultValue}";
}
- ${responseWriterVariable}.writeAttribute(${attributeName},value,null);
+ ${responseWriterVariable}.writeAttribute("${attributeName}",value,null);
<#else>
) {
- ${responseWriterVariable}.writeAttribute(${attributeName},value,null);
+
${responseWriterVariable}.writeAttribute("${attributeName}",value,null);
}
</#if>
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-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-attributes-set.ftl 2010-07-09
23:05:13 UTC (rev 17794)
@@ -1,6 +1,6 @@
<@util.require "RENDER_ATTRIBUTES_SET"/><(a)util.require
"CREATE_ATTRIBUTES"/>
<@util.constant "Attributes"
"${fieldName}">${CREATE_ATTRIBUTES}()<#list attributes as attribute>
-
.${attribute.builderMethod}(${attribute.name},${attribute.componentAttribute}<#list
attribute.behaviors as behavior>,${behavior}</#list>)
+
.${attribute.builderMethod}("${attribute.name}","${attribute.componentAttribute}"<#list
attribute.behaviors as behavior>,"${behavior}"</#list>)
<#if attribute.defaultValue?exists
>.defaultValue("${attribute.defaultValue}")</#if>
</#list></(a)util.constant>
${RENDER_ATTRIBUTES_SET}(${facesContextVariable}, ${componentVariable},
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-boolean-attribute.ftl
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-boolean-attribute.ftl 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-boolean-attribute.ftl 2010-07-09
23:05:13 UTC (rev 17794)
@@ -1,5 +1,5 @@
<#if value.literal && value == "true">
- ${responseWriterVariable}.writeAttribute(${attributeName},${attributeName},null);
+
${responseWriterVariable}.writeAttribute("${attributeName}","${attributeName}",null);
<#else>
<#if value.type == "boolean" >
if(${value}) {
@@ -8,6 +8,6 @@
<#else>
if(Boolean.valueOf(String.valueOf(${value}))) {
</#if>
-
${responseWriterVariable}.writeAttribute(${attributeName},${attributeName},null);
+
${responseWriterVariable}.writeAttribute("${attributeName}",${attributeName},null);
}
</#if>
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-uri-attribute.ftl
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-uri-attribute.ftl 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/java/write-uri-attribute.ftl 2010-07-09
23:05:13 UTC (rev 17794)
@@ -1,5 +1,5 @@
<#if value.literal>
- ${responseWriterVariable}.writeURIAttribute(${attributeName},${value},null);
+
${responseWriterVariable}.writeURIAttribute("${attributeName}",${value},null);
<#else>
{
${value.type} value = ${value};
@@ -8,7 +8,7 @@
<#else>
if(null != value && value.toString().length()>0) {
</#if>
- ${responseWriterVariable}.writeURIAttribute(${attributeName},value,null);
+
${responseWriterVariable}.writeURIAttribute("${attributeName}",value,null);
}
}
</#if>
Modified:
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateParserTest.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateParserTest.java 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateParserTest.java 2010-07-09
23:05:13 UTC (rev 17794)
@@ -375,14 +375,14 @@
resourceDependency = resourceDependencies.get(0);
assertNotNull(resourceDependency);
assertEquals("jquery.js", resourceDependency.getName());
- assertNull(resourceDependency.getLibrary());
- assertEquals("head", resourceDependency.getTarget());
+ assertEquals("",resourceDependency.getLibrary());
+ assertEquals("", resourceDependency.getTarget());
resourceDependency = resourceDependencies.get(1);
assertNotNull(resourceDependency);
assertEquals("richfaces.css", resourceDependency.getName());
assertEquals("org.richfaces", resourceDependency.getLibrary());
- assertEquals("head", resourceDependency.getTarget());
+ assertEquals("", resourceDependency.getTarget());
resourceDependency = resourceDependencies.get(2);
assertNotNull(resourceDependency);
Modified:
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectTest.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectTest.java 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectTest.java 2010-07-09
23:05:13 UTC (rev 17794)
@@ -1,12 +1,9 @@
package org.richfaces.cdk.templatecompiler.statements;
import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
import java.util.Collections;
-import javax.xml.namespace.QName;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
Modified:
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/ForEachTest.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/ForEachTest.java 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/ForEachTest.java 2010-07-09
23:05:13 UTC (rev 17794)
@@ -1,12 +1,9 @@
package org.richfaces.cdk.templatecompiler.statements;
import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
import java.util.Collections;
-import javax.xml.namespace.QName;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
Added:
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/StartElementTest.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/StartElementTest.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/StartElementTest.java 2010-07-09
23:05:13 UTC (rev 17794)
@@ -0,0 +1,32 @@
+package org.richfaces.cdk.templatecompiler.statements;
+
+import javax.xml.namespace.QName;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+
+import com.google.inject.Inject;
+
+(a)RunWith(CdkTestRunner.class)
+public class StartElementTest extends FreeMarkerTestBase {
+
+ @Mock
+ private TypesFactory typesFactory;
+
+ @Inject
+ private StartElementStatement statement;
+
+
+ @Test
+ public void testStartElement() throws Exception {
+ controller.replay();
+ statement.setElementName(QName.valueOf("div"));
+ String code = statement.getCode();
+ verifyCode(code, "startElement","div");
+ controller.verify();
+ }
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/StartElementTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/WtiteTextTest.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/WtiteTextTest.java 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/statements/WtiteTextTest.java 2010-07-09
23:05:13 UTC (rev 17794)
@@ -1,12 +1,9 @@
package org.richfaces.cdk.templatecompiler.statements;
import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
import java.util.Collections;
-import javax.xml.namespace.QName;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
Modified:
root/cdk/branches/RF8755/plugins/maven-cdk-plugin/src/it/annotated-component/pom.xml
===================================================================
---
root/cdk/branches/RF8755/plugins/maven-cdk-plugin/src/it/annotated-component/pom.xml 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/maven-cdk-plugin/src/it/annotated-component/pom.xml 2010-07-09
23:05:13 UTC (rev 17794)
@@ -21,6 +21,9 @@
</goals>
<inherited>false</inherited>
<configuration>
+ <options>
+ <rendererUtils>#built-in</rendererUtils>
+ </options>
</configuration>
</execution>
</executions>
Modified:
root/cdk/branches/RF8755/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/templates/testComponent.xml
===================================================================
---
root/cdk/branches/RF8755/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/templates/testComponent.xml 2010-07-09
19:36:32 UTC (rev 17793)
+++
root/cdk/branches/RF8755/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/templates/testComponent.xml 2010-07-09
23:05:13 UTC (rev 17794)
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<cdk:root
xmlns="http://www.w3.org/1999/xhtml"
xmlns:cdk="http://richfaces.org/cdk/core"
-
xmlns:c="http://richfaces.org/cdk/jstl/core"
xmlns:cc="http://richfaces.org/cdk/jsf/composite">
+
xmlns:c="http://richfaces.org/cdk/jstl/core"
xmlns:cc="http://richfaces.org/cdk/jsf/composite"
+
xmlns:x="http://richfaces.org/cdk/ext">
<cc:interface>
<cdk:class>org.richfaces.cdk.test.renderkit.rf4_xhtml.TestRenderer
</cdk:class>
@@ -12,7 +13,13 @@
<cdk:renderer-type>org.richfaces.TestRenderer</cdk:renderer-type>
<cdk:renderkit-id>RF4_XHTML</cdk:renderkit-id>
<cdk:renders-children>false</cdk:renders-children>
- <cc:attribute name="onclick" />
+ <cc:attribute name="onclick" >
+ <cc:clientBehavior event="click"/>
+ <cc:clientBehavior event="action" default="true"/>
+ </cc:attribute>
+ <cc:attribute name="onlistclick" >
+ <cc:clientBehavior event="listclick"/>
+ </cc:attribute>
<cc:attribute name="mode" default="ajax" />
<cc:attribute name="action" method-signature="void action()"
/>
<cc:attribute name="changeListener"
@@ -32,7 +39,7 @@
</cc:interface>
<cc:implementation>
- <div id="#{clientId}" style="#{component.style}"
class="#{component.styleClass}">
+ <div id="#{clientId}" cdk:passThroughWithExclusions="id dir
lang">
<c:if test="#{component.attributes['ifTest'] != null}">if
content</c:if>
<c:choose>
<c:when test="#{component.attributes['anotherTest'] !=
null}">when content</c:when>
@@ -41,9 +48,11 @@
</c:when>
<c:otherwise>otherwise content</c:otherwise>
</c:choose>
- <ul>
+ <img src="#{component.attributes['imgAge']}"
alt="#{component.attributes['imgAlt']}"
x:ismap="disabled">
+ </img>
+ <ul x:style="listStyle" x:class="listClass"
cdk:passThrough="id title:listTitle onclick:onlistclick
ondblclick:onlistdblclick">
<c:forEach items="#{component.children}" var="iterationVar">
- <li>forEach content #{iterationVar.encodeAll(facesContext)}</li>
+ <li>forEach content
<cdk:call>iterationVar.encodeAll(facesContext)</cdk:call></li>
</c:forEach>
</ul>
</div>