Author: nbelaevski
Date: 2010-01-31 18:27:26 -0500 (Sun, 31 Jan 2010)
New Revision: 16383
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-composite.xsd
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-jstl-core.xsd
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java
root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/ComponentAttribute.java
root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
Log:
https://jira.jboss.org/jira/browse/RF-7732
https://jira.jboss.org/jira/browse/RF-8309
https://jira.jboss.org/jira/browse/RFPL-364
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java 2010-01-30
00:19:36 UTC (rev 16382)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java 2010-01-31
23:27:26 UTC (rev 16383)
@@ -86,15 +86,17 @@
return result.toString();
}
- public static String getEscapedStringsArray(String... strings) {
+ public static String getEscapedStringsArray(Iterable<String> strings) {
StringBuilder sb = new StringBuilder();
- for (String string : strings) {
- if (sb.length() > 0) {
- sb.append(", ");
+ if (strings != null) {
+ for (String string : strings) {
+ if (sb.length() > 0) {
+ sb.append(", ");
+ }
+
+ sb.append(getEscapedString(string));
}
-
- sb.append(getEscapedString(string));
}
return sb.toString();
@@ -138,4 +140,5 @@
public static boolean isdigit(char c) {
return (c >= '0') && (c <= '9');
}
+
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java 2010-01-30
00:19:36 UTC (rev 16382)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java 2010-01-31
23:27:26 UTC (rev 16383)
@@ -31,10 +31,15 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.faces.application.Application;
import javax.faces.component.UIComponent;
import javax.faces.component.behavior.Behavior;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
+import javax.faces.event.FacesEvent;
+import javax.faces.model.DataModel;
+import javax.faces.render.Renderer;
+import javax.faces.validator.Validator;
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.LoggerFactory;
@@ -95,7 +100,9 @@
private static final String[] GUESS_PACKAGES;
static {
- Class<?>[] guessPackagesClasses = { UIComponent.class, Behavior.class,
Converter.class, FacesContext.class,
+ Class<?>[] guessPackagesClasses = {
+ UIComponent.class, Behavior.class, Converter.class, Validator.class,
+ FacesContext.class, Application.class, FacesEvent.class, DataModel.class,
Renderer.class,
Collection.class, Object.class };
GUESS_PACKAGES = new String[guessPackagesClasses.length];
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-01-30
00:19:36 UTC (rev 16382)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-01-31
23:27:26 UTC (rev 16383)
@@ -26,6 +26,8 @@
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
+import java.util.Collection;
+import java.util.Map;
import org.richfaces.builder.model.JavaClass;
import org.richfaces.cdk.CdkContext;
@@ -33,17 +35,21 @@
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.StandardOutputs;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.templatecompiler.model.Template;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
+import com.google.common.collect.Maps;
+
import freemarker.template.TemplateException;
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
*/
public class RendererClassGenerator implements CdkWriter {
@@ -59,12 +65,26 @@
this.context = context;
}
+ private ComponentModel findComponentByRenderer(RendererModel renderer) {
+ Collection<ComponentModel> components =
context.getLibrary().getComponents();
+ if (components != null) {
+ for (ComponentModel component : components) {
+ Collection<RendererModel> renderers = component.getRenderers();
+ if (renderers != null) {
+ if (renderers.contains(renderer)) {
+ return component;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
/*
* (non-Javadoc)
*
- * @see
- * org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary
- * )
+ * @see org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary
)
*/
@Override
public void render() throws CdkException {
@@ -73,9 +93,18 @@
for (RendererModel renderer : renderKit.getRenderers()) {
Template template = renderer.getTemplate();
if (null != template) {
- RendererClassVisitor visitor = new RendererClassVisitor(
- template.getInterface(), context.getLoader(),
context.getWorker(JAXBBinding.class));
+ Map<String, Property> attributesMap = Maps.newHashMap();
+ ComponentModel component = findComponentByRenderer(renderer);
+ if (component != null) {
+ attributesMap.putAll(component.getAttributes());
+ }
+
+ attributesMap.putAll(renderer.getAttributes());
+
+ RendererClassVisitor visitor = new
RendererClassVisitor(template.getInterface(),
+ attributesMap, context.getLoader(),
context.getWorker(JAXBBinding.class));
+
try {
// TODO - put real parameters.
visitor.preProcess();
@@ -84,13 +113,12 @@
} finally {
RendererClassVisitor.clearCaches();
}
-
+
JavaClass javaClass = visitor.getGeneratedClass();
String fullName = javaClass.getName();
- File outFile = context.createOutputFile(
- StandardOutputs.RENDERER_CLASSES, fullName.replace(
- '.', '/')
- + ".java", library.lastModified());
+ File outFile =
context.createOutputFile(StandardOutputs.RENDERER_CLASSES, fullName
+ .replace('.', '/')
+ + ".java", library.lastModified());
if (null != outFile) {
PrintWriter outputWriter = null;
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-01-30
00:19:36 UTC (rev 16382)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-01-31
23:27:26 UTC (rev 16383)
@@ -53,6 +53,8 @@
import org.richfaces.cdk.attributes.Element;
import org.richfaces.cdk.attributes.Schema;
import org.richfaces.cdk.attributes.SchemaSet;
+import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.parser.el.ELParserUtils;
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
@@ -74,6 +76,8 @@
import org.richfaces.cdk.util.Strings;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
+import com.google.common.base.Function;
+import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
/**
@@ -138,9 +142,12 @@
private Type lastCompiledExpressionType;
private int passThroughCounter;
+ private Map<String, Property> attributes;
- public RendererClassVisitor(CompositeInterface compositeInterface, ClassLoader
classLoader, JAXBBinding jaxbBinding) {
+ public RendererClassVisitor(CompositeInterface compositeInterface, Map<String,
Property> attributes,
+ ClassLoader classLoader, JAXBBinding jaxbBinding) {
this.compositeInterface = compositeInterface;
+ this.attributes = attributes;
this.classLoader = classLoader;
// TODO - cache unmarshalled data (as CDKWorker?)
@@ -260,9 +267,8 @@
return result;
}
- private String createPassThroughAttributeCode(String htmlAttributeName, Attribute
componentAttribute,
- String[] eventNames) {
-
+ private String createPassThroughAttributeCode(String htmlAttributeName, String
componentAttributeName) {
+
generatedClass.addImport("org.richfaces.renderkit.ComponentAttribute");
StringBuilder sb = new StringBuilder();
@@ -272,20 +278,36 @@
sb.append(")");
- String componentAttributeName = componentAttribute.getComponentAttributeName();
+ String attributeName;
if (!StringUtils.isEmpty(componentAttributeName)) {
+ attributeName = componentAttributeName;
+
sb.append(".setComponentAttributeName(");
sb.append(StringUtils.getEscapedString(componentAttributeName));
sb.append(")");
+ } else {
+ attributeName = htmlAttributeName;
}
- if (eventNames != null && eventNames.length != 0) {
- sb.append(".setEventNames(");
- sb.append("new String[] {");
+ Property property = attributes.get(attributeName);
+ if (property != null) {
+ Set<EventName> eventNames = property.getEventNames();
+ if (eventNames != null && !eventNames.isEmpty()) {
+ sb.append(".setEventNames(");
+ sb.append("new String[] {");
- sb.append(StringUtils.getEscapedStringsArray(eventNames));
+ Collection<String> eventNamesStrings =
Collections2.transform(eventNames,
+ new Function<EventName, String>() {
+ @Override
+ public String apply(EventName from) {
+ return from.getName();
+ }
+ });
- sb.append("})");
+ sb.append(StringUtils.getEscapedStringsArray(eventNamesStrings));
+
+ sb.append("})");
+ }
}
return sb.toString();
@@ -322,7 +344,9 @@
}
// TODO behaviors data
- fieldValue.append(createPassThroughAttributeCode(entry.getKey(),
entry.getValue(), null));
+ String htmlAttributeName = entry.getKey();
+ String componentAttributeName =
entry.getValue().getComponentAttributeName();
+ fieldValue.append(createPassThroughAttributeCode(htmlAttributeName,
componentAttributeName));
}
fieldValue.append("))");
@@ -539,7 +563,12 @@
*/
@Override
public void visitElement(CdkCallElement cdkCallElement) throws CdkException {
- currentStatement.addStatement(cdkCallElement.getExpression() + ";");
+ String expression = cdkCallElement.getExpression();
+ if (Strings.isEmpty(expression)) {
+ expression = cdkCallElement.getBodyValue();
+ }
+
+ currentStatement.addStatement(expression + ";");
}
/*
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-01-30
00:19:36 UTC (rev 16382)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-01-31
23:27:26 UTC (rev 16383)
@@ -140,7 +140,6 @@
RenderKitModel renderKit =
library.addRenderKit(compositeInterface.getRenderKitId());
RendererModel renderer = new RendererModel(new
RendererModel.Type(compositeInterface.getRendererType()));
renderKit.getRenderers().add(renderer);
- String componentType = compositeInterface.getComponentType();
// component.getRenderers().add(renderer);
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java 2010-01-30
00:19:36 UTC (rev 16382)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java 2010-01-31
23:27:26 UTC (rev 16383)
@@ -27,6 +27,7 @@
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlValue;
/**
* <p class="changed_added_4_0"></p>
@@ -38,6 +39,9 @@
private String expression;
+ @XmlValue
+ private String bodyValue;
+
public CdkCallElement() {
}
@@ -60,6 +64,24 @@
this.expression = expression;
}
+ /**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @return the bodyValue
+ */
+ public String getBodyValue() {
+ return bodyValue;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @param bodyValue the bodyValue to set
+ */
+ public void setBodyValue(String bodyValue) {
+ this.bodyValue = bodyValue;
+ }
+
@Override
public void visit(TemplateVisitor visitor) throws CdkException {
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java 2010-01-30
00:19:36 UTC (rev 16382)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java 2010-01-31
23:27:26 UTC (rev 16383)
@@ -41,8 +41,6 @@
private static final long serialVersionUID = -5578359507253872500L;
- private String componentType;
-
private String componentFamily;
private List<Attribute> attributes;
@@ -64,25 +62,6 @@
/**
* <p class="changed_added_4_0"></p>
*
- * @return the componentType
- */
- @XmlElement(name = "component-type", namespace = Template.CDK_NAMESPACE)
- public String getComponentType() {
- return this.componentType;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @param componentType the componentType to set
- */
- public void setComponentType(String componentType) {
- this.componentType = componentType;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
* @return the family
*/
@XmlElement(name = "component-family", namespace = Template.CDK_NAMESPACE)
Modified:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-composite.xsd
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-composite.xsd 2010-01-30
00:19:36 UTC (rev 16382)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-composite.xsd 2010-01-31
23:27:26 UTC (rev 16383)
@@ -1,39 +1,32 @@
<?xml version = "1.0" encoding = "UTF-8"?>
-<!--
-JBoss, Home of Professional Open Source
-Copyright ${year}, Red Hat, Inc. and individual contributors
-by the @authors tag. See the copyright.txt in the distribution for a
-full listing of individual contributors.
+ <!--
+ JBoss, Home of Professional Open Source Copyright ${year}, Red Hat,
+ Inc. and individual contributors by the @authors tag. See the
+ copyright.txt in the distribution for a full listing of individual
+ contributors. This is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version. This software is
+ distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details. You should have received a copy of the GNU
+ Lesser General Public License along with this software; if not, write
+ to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ Boston, MA 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ -->
-
-This is free software; you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as
-published by the Free Software Foundation; either version 2.1 of
-the License, or (at your option) any later version.
-
-
-This software is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Lesser General Public License for more details.
-
-
-You should have received a copy of the GNU Lesser General Public
-License along with this software; if not, write to the Free
-Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-02110-1301 USA, or see the FSF site:
http://www.fsf.org.
--->
-
<xs:schema
targetNamespace="http://richfaces.org/cdk/jsf/composite"
xmlns:cc="http://richfaces.org/cdk/jsf/composite"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
-
xmlns:xml="http://www.w3.org/XML/1998/namespace"
elementFormDefault="qualified"
- attributeFormDefault="unqualified">
+
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:cdk="http://richfaces.org/cdk/core"
+ elementFormDefault="qualified"
attributeFormDefault="unqualified">
+ <xs:import schemaLocation="cdk-template.xsd"
namespace="http://richfaces.org/cdk/core" />
+
<xs:annotation>
<xs:documentation>
- NB: this schema covers only subset of elements supported by RichFaces CDK and therefore
it
- shouldn't be used as a reference document for development of composite components.
+ Subset of JSF 2.0 composite tags supported by RichFaces CDK.
</xs:documentation>
</xs:annotation>
@@ -77,14 +70,7 @@
</xs:attributeGroup>
<xs:complexType name="attributeExtensionType">
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:choice>
- <xs:element ref="cc:attribute" />
- <xs:element ref="cc:extension" />
- <xs:element ref="cc:clientBehavior" />
- <xs:any processContents="lax" namespace="##other" />
- </xs:choice>
- </xs:sequence>
+ <xs:group ref="cc:compositeTagsGroup" />
<xs:attribute name="name" use="required">
<xs:annotation>
<xs:documentation>
@@ -103,7 +89,7 @@
present, must be ignored as its value is derived as
described in
retargetMethodExpressions().
- </xs:documentation>
+ </xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="targets">
@@ -111,20 +97,22 @@
<xs:documentation>
If this element has a method-signature attribute, the value of the
targets attribute must be interpreted as a space (not tab)
- separated list of client ids (relative to the top level component)
+ separated list of client ids (relative to the top level
+ component)
of components within the
<composite:implementation> section. Space is used as the delimiter
- for compatibility with the IDREFS and NMTOKENS data types from the
- XML Schema. Each entry in the list must be interpreted as the id
- of an inner component to which the MethodExpression from the
- composite component tag in the using page must be applied. If this
- element has a method-signature attribute, but no targets
- attribute, the value of the name attribute is used as the single
- entry in the list. If the value of the name attribute is not one
- of the special values listed in the description of the name
- attribute, targets (or its derived value) need not correspond to
- the id of an inner component.
- </xs:documentation>
+ for compatibility with the IDREFS and NMTOKENS data types from the
+ XML Schema. Each entry in the list must be interpreted as the id
+ of an inner component to which the MethodExpression from the
+ composite component tag in the using page must be applied. If
+ this
+ element has a method-signature attribute, but no targets
+ attribute, the value of the name attribute is used as the single
+ entry in the list. If the value of the name attribute is not one
+ of the special values listed in the description of the name
+ attribute, targets (or its derived value) need not correspond to
+ the id of an inner component.
+ </xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="default">
@@ -133,15 +121,16 @@
If this attribute is not required, and a value is
not supplied by the
page author, use this as the default value.
- </xs:documentation>
+ </xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="required" type="xs:boolean"
default="false">
+ <xs:attribute name="required" type="xs:boolean"
+ default="false">
<xs:annotation>
<xs:documentation>
True if the page author must supply a value for
this attribute.
- </xs:documentation>
+ </xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="method-signature">
@@ -200,7 +189,7 @@
Example:
java.lang.String nickName(java.lang.String, int)
- </xs:documentation>
+ </xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="type">
@@ -217,7 +206,7 @@
attribute. If both attributes are present, the
"method-signature"
attribute is ignored.
- </xs:documentation>
+ </xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attributeGroup ref="cc:beanDescriptorAttributes" />
@@ -227,7 +216,7 @@
<xs:attribute name="event">
<xs:annotation>
<xs:documentation>
- Names of the logical event supported by the component
+ Names of the logical event supported by the component
</xs:documentation>
</xs:annotation>
</xs:attribute>
@@ -235,7 +224,8 @@
<xs:attribute name="default" type="xs:boolean">
<xs:annotation>
<xs:documentation>
- Boolean attribute defining whether the specified logical event is the default
component event
+ Boolean attribute defining whether the specified logical event is the
+ default component event
</xs:documentation>
</xs:annotation>
</xs:attribute>
@@ -247,12 +237,27 @@
</xs:sequence>
</xs:complexType>
- <xs:complexType name="compositeInterfaceType">
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:choice>
- <xs:any namespace="##any" processContents="lax" />
+ <xs:group name="compositeTagsGroup">
+ <xs:sequence>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="attribute" type="cc:attributeExtensionType"
/>
+ <xs:element name="extension" type="cc:compositeExtensionType"
/>
+ <xs:element name="clientBehavior"
type="cc:clientBehaviorExtensionType" />
</xs:choice>
</xs:sequence>
+ </xs:group>
+
+ <xs:group name="compositeTagsGroupWithAny">
+ <xs:sequence>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:group ref="cc:compositeTagsGroup" />
+ <xs:any processContents="lax" namespace="##other " />
+ </xs:choice>
+ </xs:sequence>
+ </xs:group>
+
+ <xs:complexType name="compositeInterfaceType">
+ <xs:group ref="cc:compositeTagsGroupWithAny" />
<xs:attribute type="xs:string" name="name">
<xs:annotation>
<xs:documentation>
@@ -271,7 +276,8 @@
<xs:documentation>
The component-type of the UIComponent that will
serve as the composite
- component root for this composite component.
+ component root for this composite
+ component.
The declared
component-family for this component must be
javax.faces.NamingContainer.
@@ -290,8 +296,5 @@
<xs:element name="interface" type="cc:compositeInterfaceType"
/>
<xs:element name="implementation"
type="cc:compositeImplementationType" />
- <xs:element name="extension" type="cc:compositeExtensionType"
/>
- <xs:element name="attribute" type="cc:attributeExtensionType"
/>
- <xs:element name="clientBehavior"
type="cc:clientBehaviorExtensionType" />
</xs:schema>
Modified:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-jstl-core.xsd
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-jstl-core.xsd 2010-01-30
00:19:36 UTC (rev 16382)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-jstl-core.xsd 2010-01-31
23:27:26 UTC (rev 16383)
@@ -31,8 +31,7 @@
<xs:annotation>
<xs:documentation>
- NB: this schema covers only subset of elements supported by RichFaces CDK and therefore
it
- shouldn't be used as a reference document for development of application pages.
+ Subset of JSTL core tags supported by RichFaces CDK.
</xs:documentation>
</xs:annotation>
Modified:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd 2010-01-30
00:19:36 UTC (rev 16382)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd 2010-01-31
23:27:26 UTC (rev 16383)
@@ -30,6 +30,12 @@
xmlns:xhtml="http://richfaces.org/cdk/xhtml-el"
xmlns:javaee="http://java.sun.com/xml/ns/javaee"
xmlns:c="http://richfaces.org/cdk/jstl/core"
xmlns:cc="http://richfaces.org/cdk/jsf/composite">
+ <xs:annotation>
+ <xs:documentation>
+ RichFaces CDK core tags and attributes.
+ </xs:documentation>
+ </xs:annotation>
+
<xs:import schemaLocation="web-facesuicomponent_2_0.xsd"
namespace="http://java.sun.com/xml/ns/javaee" />
<xs:import schemaLocation="cdk-composite.xsd"
namespace="http://richfaces.org/cdk/jsf/composite" />
<xs:import schemaLocation="cdk-jstl-core.xsd"
namespace="http://richfaces.org/cdk/jstl/core" />
@@ -57,19 +63,6 @@
<xs:restriction base="xs:string" />
</xs:simpleType>
- <xs:attributeGroup name="core.attrs">
- <xs:attribute name="passThroughWithExclusions"
type="xs:NMTOKENS" form="qualified" />
- </xs:attributeGroup>
-
- <xs:element name="root">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="cc:interface" />
- <xs:element ref="cc:implementation" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
<xs:simpleType name="resourceDependencyTargets">
<xs:restriction base="xs:string">
<xs:enumeration value="body" />
@@ -78,49 +71,301 @@
</xs:restriction>
</xs:simpleType>
- <xs:complexType name="resource-dependenciesComplexType">
+ <xs:complexType name="resourceDependenciesType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="resource-dependency"
type="resourceDependencyType" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="resourceDependencyType">
- <xs:attribute name="name" use="required"
form="unqualified" />
- <xs:attribute name="library" form="unqualified" />
+ <xs:attribute name="name" use="required"
form="unqualified">
+ <xs:annotation>
+ <xs:documentation><p>The resourceName of the resource pointed to by this
ResourceDependency.</p></xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="library" form="unqualified">
+ <xs:annotation>
+ <xs:documentation>
+ <p>The libraryName in which the resource pointed to by this ResourceDependency
resides.
+ If not specified, defaults to the empty string.
+ </p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="target" form="unqualified"
- type="resourceDependencyTargets" />
+ type="resourceDependencyTargets">
+ <xs:annotation>
+ <xs:documentation>
+ <p>The value given for this attribute will be passed as the "target"
argument to
+ <code>javax.faces.component.UIViewRoot.addComponentResource(javax.faces.context.FacesContext,
javax.faces.component.UIComponent, java.lang.String).</code>
+ </p>
+ <p>
+ If this attribute is specified,
<code>javax.faces.component.UIViewRoot.addComponentResource(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)</code>
+ must be called instead, as described above.
+ </p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
- <xs:element name="resource-dependencies">
+
+ <xs:attribute name="passThroughWithExclusions">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Enables pass-through rendering of attributes. Allows to define
whitespace-separated list of attributes
+ to exclude from pass-through encoding or empty string "" if all attributes
should be encoded.</p>
+ <p>
+ Examples:
+
+ <ul>
+ <li><code><![CDATA[<div cdk:passThroughWithExclusions="title
style"></code>]]></code></li>
+ <li><code><![CDATA[<div
cdk:passThroughWithExclusions="">]]></code></li>
+ </ul>
+
+ <span class="usage">
+ Attributes already defined on the tag are automatically excluded from pass-through
+ rendering.
+ </span>
+ </p>
+ </xs:documentation>
+ </xs:annotation>
+ <xs:simpleType>
+ <xs:restriction>
+ <xs:simpleType>
+ <xs:list>
+ <xs:simpleType>
+ <xs:restriction base="xs:NMTOKEN" />
+ </xs:simpleType>
+ </xs:list>
+ </xs:simpleType>
+ <xs:minLength value="0" />
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+
+ <xs:attributeGroup name="core.attrs">
+ <xs:attribute ref="passThroughWithExclusions" />
+ </xs:attributeGroup>
+
+ <xs:element name="root">
+ <xs:annotation>
+ <xs:documentation><p>Root template tag containing cc:interface &
cc:implementation tags.</p></xs:documentation>
+ </xs:annotation>
<xs:complexType>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:choice>
- <xs:element name="resource-dependency"
type="resourceDependencyType" />
- </xs:choice>
+ <xs:sequence>
+ <xs:element ref="cc:interface" />
+ <xs:element ref="cc:implementation" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="class" type="javaee:fully-qualified-classType"
/>
- <xs:element name="superclass"
type="javaee:fully-qualified-classType" />
- <xs:element name="component-class"
type="javaee:fully-qualified-classType" />
+ <xs:element name="resource-dependencies"
type="resource-dependenciesComplexType">
+ <xs:annotation>
+ <xs:documentation>
+ <p>
+ Container tag to specify multiple
<code><![CDATA[<resource-dependency>]]></code> tags
+ on a single class.
+ </p>
+ <p><span class="usage">Should be used within cc:interface
element.</span></p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
- <xs:element name="component-type" />
+ <xs:element name="class"
type="javaee:fully-qualified-classType">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Fully-qualified name of the generated renderer class.</p>
+ <p><span class="usage">Should be used within cc:interface
element.</span></p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
- <xs:element name="renderkit-id" />
- <xs:element name="component-family" />
- <xs:element name="renderer-type" />
- <xs:element name="renders-children" type="xs:boolean" />
+ <xs:element name="superclass"
type="javaee:fully-qualified-classType">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Fully-qualified name of the renderer superclass.</p>
+ <p><span class="usage">Should be used within cc:interface
element.</span></p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+
+ <xs:element name="renderkit-id">
+ <xs:annotation>
+ <xs:documentation>
+ <p>ID of the renderkit to include this renderer to. Defaults to
'HTML_BASIC'.</p>
+ <p><span class="usage">Should be used within cc:interface
element.</span></p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="component-family">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Family of the component to be rendered by this renderer.</p>
+ <p><span class="usage">Should be used within cc:interface
element.</span></p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="renderer-type">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Renderer type identifier for this renderer.</p>
+ <p><span class="usage">Should be used within cc:interface
element.</span></p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="renders-children" type="xs:boolean">
+ <xs:annotation>
+ <xs:documentation>
+ <p><span class="usage">Should be used within cc:interface
element.</span></p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
<xs:element name="import-attributes">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Defines fragment of faces configuration file to import attributes
from.</p>
+ <p><span class="usage">Should be used within cc:interface
element.</span></p></xs:documentation>
+ </xs:annotation>
<xs:complexType>
- <xs:attribute use="required" name="src"
type="xs:anyURI" form="unqualified" />
+ <xs:attribute use="required" name="src"
type="xs:anyURI" form="unqualified">
+ <xs:annotation>
+ <xs:documentation>
+ URI of the file to import. Any URI supported by CDK is allowed to be used here.
+ Imported file should have
<code><![CDATA[<cdk:properties>]]></code> tag as root element.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
<xs:group name="structural">
<xs:choice>
<xs:element name="body">
+ <xs:annotation>
+ <xs:documentation>
+ <p>
+ Template body marker tag. <span class="usage">Should be used only
once in template document.</span>
+ Component renderers in JSF define three methods for content rendering, so the
following
+ rules are applied for
<code><![CDATA[<cc:implementation>]]></code> part of template
document:
+
+ <ul>
+ <li>
+ all content declared before
<code><![CDATA[<cdk:body>]]></code> tag is compiled into
+ statements of <code>encodeBegin(...)</code> method
+ </li>
+ <li>
+ all content declared inside
<code><![CDATA[<cdk:body>]]></code> tag is compiled into
+ statements of <code>encodeChildren(...)</code> method.
+ </li>
+ <li>
+ all content declared before
<code><![CDATA[<cdk:body>]]></code> tag is compiled into
+ statements of <code>encodeEnd(...)</code> method
+ </li>
+ </ul>
+
+ If there are no compiled statements for one of the aforementioned methods, then
definition
+ for this method is not created in the generated file.<br />
+ If template document doesn't declare
<code><![CDATA[<cdk:body>]]></code> tag, then contents
+ of <code><![CDATA[<cc:implementation>]]></code> part is
compiled into statements of
+ <code>encodeEnd(...)</code> method.
+ </p>
+ <p>
+ Examples:<br /><br />
+
+ The following code snippet:
+ <pre><![CDATA[
+ ...
+ <cc:implementation>
+ <div id="myId">
+ <cdk:body>
+ <span>Component content</span>
+ </cdk:body>
+ </div>
+ </cc:implementation>
+ ...
+ ]]></pre>
+ produces the following code (unsignificant details are ommitted):
+ <pre><![CDATA[
+ ...
+
+ encodeBegin(...) {
+ ...
+ writer.startElement("div", cc);
+ writer.writeAttribute("id", "myId", null);
+ }
+
+ encodeChildren(...) {
+ ...
+ writer.startElement("span", cc);
+ writer.writeText("Component content", null);
+ writer.endlement("span");
+ }
+
+ encodeEnd(...) {
+ ...
+ writer.endElement("div");
+ }
+
+ ...
+ ]]></pre>
+
+ <br /><br />
+ The following code snippet:
+ <pre><![CDATA[
+ ...
+ <cc:implementation>
+ <div id="myId">
+ <cdk:body />
+ </div>
+ </cc:implementation>
+ ...
+ ]]></pre>
+ produces the following code (unsignificant details are ommitted):
+ <pre><![CDATA[
+ ...
+
+ encodeBegin(...) {
+ ...
+ writer.startElement("div", cc);
+ writer.writeAttribute("id", "myId", null);
+ }
+
+ encodeEnd(...) {
+ ...
+ writer.endElement("div");
+ }
+
+ ...
+ ]]></pre>
+
+ <br /><br />
+ The following code snippet:
+ <pre><![CDATA[
+ ...
+ <cc:implementation>
+ <div id="myId">
+ Some text
+ </div>
+ </cc:implementation>
+ ...
+ ]]></pre>
+ produces the following code (unsignificant details are ommitted):
+ <pre><![CDATA[
+ ...
+
+ encodeEnd(...) {
+ ...
+ writer.startElement("div", cc);
+ writer.writeText("Some text", null);
+ writer.endElement("div");
+ }
+
+ ...
+ ]]></pre>
+ </p>
+ </xs:documentation>
+ </xs:annotation>
<xs:complexType mixed="true">
<xs:choice>
<xs:any minOccurs="0" maxOccurs="unbounded" />
@@ -134,27 +379,139 @@
</xs:group>
<xs:element name="call">
- <xs:complexType>
- <xs:attribute name="expression" form="unqualified" />
+ <xs:annotation>
+ <xs:documentation>
+ <p>Arbitrary method invocation statement. Should be used within
cc:implementation element.</p>
+ <p><span class="usage">Note: method return value is
ignored.</span></p>
+ </xs:documentation>
+ </xs:annotation>
+ <xs:complexType mixed="true">
+ <xs:attribute name="expression" form="unqualified">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Method invocation expression. If this attribute is ommitted, body of the
tag is used instead.</p>
+ <p>Examples:
+
+ <ul>
+ <li><code><![CDATA[<cdk:call
expression="responseWriter.writeAttribute("id", clientId,
"id")" ...>]]></code></li>
+ <li><code><![CDATA[<cdk:call>responseWriter.writeAttribute("id",
clientId, "id")</cdk:call>]]></code></li>
+ </ul>
+ </p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
+
<xs:element name="object">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Introduces new variable. Variable's scope is limited to the context of
the current method,
+ i.e. variables defined before <cdk:body> are not available after
it.</p>
+
+ <p><span class="usage">Should be used within cc:implementation
element.</span></p>
+ <p>Usage example:
+ <ul>
+ <li>
+ <code><![CDATA[<cdk:object name="children"
type="List" type-arguments="UIComponent"
value="#{cc.children}" />]]></code>
+ </li>
+ </ul>
+ </p>
+ </xs:documentation>
+ </xs:annotation>
<xs:complexType mixed="true">
<xs:simpleContent>
<xs:extension base="xs:string">
- <xs:attribute name="name" form="unqualified"
type="literalExpression" use="required" />
- <xs:attribute name="value" form="unqualified" />
- <xs:attribute name="type" form="unqualified" />
- <xs:attribute name="type-arguments" form="unqualified" />
+ <xs:attribute name="name" form="unqualified"
type="literalExpression" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Name of the variable, corresponding to Java identifier
syntax.</p>
+ <p>Examples:
+ <ul>
+ <li><code><![CDATA[<cdk:object name="children"
...>]]></code></li>
+ <li><code><![CDATA[<cdk:object name="myVariable"
...>]]></code></li>
+ <li><code><![CDATA[<cdk:object name="_children0"
...>]]></code></li>
+ </ul>
+ </p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="value" form="unqualified">
+ <xs:annotation>
+ <xs:documentation>
+ <p>EL-expression specifying initial value of the variable. If this
attribute
+ is ommitted, body of the tag is used instead.</p>
+
+ <p>Examples:
+ <ul>
+ <li><code><![CDATA[<cdk:object
value="#{cc.rendered}" ...>]]></code></li>
+ <li><code><![CDATA[<cdk:object value="#{myObject}
...>]]></code></li>
+ <li><code><![CDATA[<cdk:object
value="#{getSubmittedValue(facesContext, cc)} ...>]]></code></li>
+ <li><code><![CDATA[<cdk:object
...>#{cc.getClientId(facesContext)}</cdk:object>]]></code></li>
+ </ul>
+ </p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="type" form="unqualified">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Variable type name. CDK automatically resolves simple names for
primitive types,
+ JSF API classes and objects from java.lang.* or java.util.*.</p>
+ <p>Examples:
+ <ul>
+ <li><code><![CDATA[<cdk:object
type="java.lang.String" ...>]]></code></li>
+ <li><code><![CDATA[<cdk:object type="float"
...>]]></code></li>
+ <li><code><![CDATA[<cdk:object type="List"
...>]]></code></li>
+ <li><code><![CDATA[<cdk:object type="UIComponent"
...>]]></code></li>
+ </ul>
+ </p>
+ <p>If type is not defined explicitly, CDK will try to infer variable type
+ from its value.</p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="type-arguments" form="unqualified">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Comma-separated list of generic type arguments for usage with types like
+ java.util.List or java.util.Map.</p>
+ <p>Examples:
+ <ul>
+ <li>
+ <code><![CDATA[<cdk:object name="map"
type="Map" type-arguments="String, Object" />]]></code>
+ </li>
+ <li>
+ <code><![CDATA[<cdk:object name="list"
type="List" type-arguments="UIComponent" />]]></code>
+ </li>
+ </ul>
+ </p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
- <xs:element name="clientId">
- <xs:complexType>
- <xs:attribute name="var" type="literalExpression"
default="clientId" />
- </xs:complexType>
- </xs:element>
-
+ <xs:complexType name="resource-dependenciesComplexType">
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:choice>
+ <xs:element name="resource-dependency"
+ type="resourceDependencyType">
+
+ <xs:annotation>
+ <xs:documentation>
+ <p>Resource dependency tag. Defines dependent resource for the renderer
+ (see documentation for @ResourceDependency annotation for more information).
+ </p>
+ <p>
+ <span class="warning">Support for this tag is not currently
implemented.</span>
+ </p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:choice>
+ </xs:sequence>
+ </xs:complexType>
</xs:schema>
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java 2010-01-30
00:19:36 UTC (rev 16382)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java 2010-01-31
23:27:26 UTC (rev 16383)
@@ -160,7 +160,6 @@
"<cdk:class>org.richfaces.renderkit.html.TreeRenderer</cdk:class>"
+
"<cdk:superclass>org.richfaces.renderkit.TreeRendererBase</cdk:superclass>"
+
"<cdk:component-family>org.richfaces.TreeFamily</cdk:component-family>"
+
-
"<cdk:component-type>org.richfaces.Tree</cdk:component-type>" +
"<cdk:renderer-type>org.richfaces.TreeRenderer</cdk:renderer-type>"
+
"<cdk:renderkit-id>RF4_XHTML</cdk:renderkit-id>" +
"<cdk:renders-children>false</cdk:renders-children>" +
@@ -172,7 +171,6 @@
assertEquals("org.richfaces.renderkit.html.TreeRenderer",
interfaceSection.getJavaClass());
assertEquals("org.richfaces.renderkit.TreeRendererBase",
interfaceSection.getBaseClass());
assertEquals("org.richfaces.TreeFamily",
interfaceSection.getComponentFamily());
- assertEquals("org.richfaces.Tree", interfaceSection.getComponentType());
assertEquals("org.richfaces.TreeRenderer",
interfaceSection.getRendererType());
assertEquals("RF4_XHTML", interfaceSection.getRenderKitId());
assertFalse(interfaceSection.isRendersChildren());
Modified:
root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/ComponentAttribute.java
===================================================================
---
root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/ComponentAttribute.java 2010-01-30
00:19:36 UTC (rev 16382)
+++
root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/ComponentAttribute.java 2010-01-31
23:27:26 UTC (rev 16383)
@@ -47,7 +47,7 @@
Map<String,ComponentAttribute> result = new TreeMap<String,
ComponentAttribute>();
for (ComponentAttribute componentAttribute : attributes) {
- result.put(componentAttribute.getHtmlAttributeName(), componentAttribute);
+ result.put(componentAttribute.getComponentAttributeName(),
componentAttribute);
}
return result;
Modified:
root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
===================================================================
---
root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-01-30
00:19:36 UTC (rev 16382)
+++
root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-01-31
23:27:26 UTC (rev 16383)
@@ -287,7 +287,7 @@
ComponentAttribute knownAttribute =
knownAttributesMap.get(attributeName);
if (knownAttribute != null) {
- handledAttributes.add(attributeName);
+ handledAttributes.add(knownAttribute.getHtmlAttributeName());
// TODO check for disabled component
renderAttributeAndBehaviors(context, component, knownAttribute);
@@ -295,8 +295,7 @@
}
// render attributes that haven't been processed yet - there can be
behaviors
- for (Map.Entry<String, ComponentAttribute> knownAttributesMapEntry :
knownAttributesMap.entrySet()) {
- ComponentAttribute knownAttribute = knownAttributesMapEntry.getValue();
+ for (ComponentAttribute knownAttribute : knownAttributesMap.values()) {
if (handledAttributes.contains(knownAttribute.getHtmlAttributeName())) {
continue;