JBoss Rich Faces SVN: r15864 - in root/cdk/trunk/plugins/generator/src: main/java/org/richfaces/cdk/templatecompiler/model and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-11-11 15:48:15 -0500 (Wed, 11 Nov 2009)
New Revision: 15864
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkChooseElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkConditionalJstlElementBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkIfElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkObjectElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkOtherwiseElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkWhenElement.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
Removed:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/faces-composite.xsd
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/model/ModelElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/TemplateVisitor.java
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
Log:
https://jira.jboss.org/jira/browse/RF-7732
Added support for JSTL core if/choose/when/otherwise elements
Added support for cdk:object
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 2009-11-11 18:14:51 UTC (rev 15863)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2009-11-11 20:48:15 UTC (rev 15864)
@@ -29,16 +29,19 @@
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
-import java.util.Stack;
import java.util.regex.Pattern;
import org.richfaces.builder.model.JavaClass;
import org.richfaces.builder.model.MethodBodyStatement;
-import org.richfaces.builder.templates.BaseTemplateConsumer;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.templatecompiler.model.AnyElement;
import org.richfaces.cdk.templatecompiler.model.CdkBodyElement;
import org.richfaces.cdk.templatecompiler.model.CdkCallElement;
+import org.richfaces.cdk.templatecompiler.model.CdkChooseElement;
+import org.richfaces.cdk.templatecompiler.model.CdkIfElement;
+import org.richfaces.cdk.templatecompiler.model.CdkObjectElement;
+import org.richfaces.cdk.templatecompiler.model.CdkOtherwiseElement;
+import org.richfaces.cdk.templatecompiler.model.CdkWhenElement;
import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
import org.richfaces.cdk.templatecompiler.model.TemplateVisitor;
@@ -146,5 +149,77 @@
// TODO Auto-generated method stub
}
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor#endElement(org.richfaces.cdk.templatecompiler.model.CdkIfElement)
+ */
+ @Override
+ public void endElement(CdkIfElement cdkIfElement) {
+ // TODO Auto-generated method stub
+
+ }
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor#startElement(org.richfaces.cdk.templatecompiler.model.CdkIfElement)
+ */
+ @Override
+ public void startElement(CdkIfElement cdkIfElement) {
+ // TODO Auto-generated method stub
+
+ }
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor#endElement(org.richfaces.cdk.templatecompiler.model.CdkWhenElement)
+ */
+ @Override
+ public void endElement(CdkWhenElement cdkWhenElement) {
+ // TODO Auto-generated method stub
+
+ }
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor#endElement(org.richfaces.cdk.templatecompiler.model.CdkChooseElement)
+ */
+ @Override
+ public void endElement(CdkChooseElement cdkChooseElement) {
+ // TODO Auto-generated method stub
+
+ }
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor#endElement(org.richfaces.cdk.templatecompiler.model.CdkOtherwiseElement)
+ */
+ @Override
+ public void endElement(CdkOtherwiseElement cdkOtherwiseElement) {
+ // TODO Auto-generated method stub
+
+ }
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor#startElement(org.richfaces.cdk.templatecompiler.model.CdkWhenElement)
+ */
+ @Override
+ public void startElement(CdkWhenElement cdkWhenElement) {
+ // TODO Auto-generated method stub
+
+ }
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor#startElement(org.richfaces.cdk.templatecompiler.model.CdkChooseElement)
+ */
+ @Override
+ public void startElement(CdkChooseElement cdkChooseElement) {
+ // TODO Auto-generated method stub
+
+ }
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor#startElement(org.richfaces.cdk.templatecompiler.model.CdkOtherwiseElement)
+ */
+ @Override
+ public void startElement(CdkOtherwiseElement cdkOtherwiseElement) {
+ // TODO Auto-generated method stub
+
+ }
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor#visitElement(org.richfaces.cdk.templatecompiler.model.CdkObjectElement)
+ */
+ @Override
+ public void visitElement(CdkObjectElement cdkObjectElement) {
+ // TODO Auto-generated method stub
+
+ }
}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkChooseElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkChooseElement.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkChooseElement.java 2009-11-11 20:48:15 UTC (rev 15864)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.
+ */
+package org.richfaces.cdk.templatecompiler.model;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.richfaces.cdk.CdkException;
+
+/**
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+@XmlRootElement(name="choose", namespace=Template.JSTL_CORE_NAMESPACE)
+public class CdkChooseElement extends ModelFragment {
+
+ @XmlElements({
+ @XmlElement(name="when", namespace=Template.JSTL_CORE_NAMESPACE, type = CdkWhenElement.class),
+ @XmlElement(name="otherwise", namespace=Template.JSTL_CORE_NAMESPACE, type = CdkOtherwiseElement.class)
+ })
+ @Override
+ public List<Object> getChildren() {
+ return super.getChildren();
+ }
+
+ @Override
+ public void setChildren(List<Object> body) {
+ super.setChildren(body);
+ }
+
+ @Override
+ public void beforeVisit(TemplateVisitor visitor) throws CdkException {
+ visitor.startElement(this);
+ }
+
+ @Override
+ public void afterVisit(TemplateVisitor visitor) throws CdkException {
+ visitor.endElement(this);
+ }
+}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkConditionalJstlElementBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkConditionalJstlElementBase.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkConditionalJstlElementBase.java 2009-11-11 20:48:15 UTC (rev 15864)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.
+ */
+package org.richfaces.cdk.templatecompiler.model;
+
+import javax.xml.bind.annotation.XmlAttribute;
+
+/**
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+public abstract class CdkConditionalJstlElementBase extends ModelFragment {
+
+ @XmlAttribute(required = true)
+ private String test;
+
+ /**
+ * @return the test
+ */
+ public String getTest() {
+ return test;
+ }
+
+ /**
+ * @param test the test to set
+ */
+ public void setTest(String test) {
+ this.test = test;
+ }
+
+}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkIfElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkIfElement.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkIfElement.java 2009-11-11 20:48:15 UTC (rev 15864)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.
+ */
+package org.richfaces.cdk.templatecompiler.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.richfaces.cdk.CdkException;
+
+/**
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+@XmlRootElement(name="if", namespace=Template.JSTL_CORE_NAMESPACE)
+public class CdkIfElement extends CdkConditionalJstlElementBase {
+
+ @Override
+ public void beforeVisit(TemplateVisitor visitor) throws CdkException {
+ visitor.startElement(this);
+ }
+
+ @Override
+ public void afterVisit(TemplateVisitor visitor) throws CdkException {
+ visitor.endElement(this);
+ }
+}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkObjectElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkObjectElement.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkObjectElement.java 2009-11-11 20:48:15 UTC (rev 15864)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.
+ */
+package org.richfaces.cdk.templatecompiler.model;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlValue;
+
+import org.richfaces.cdk.CdkException;
+
+/**
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+@XmlRootElement(name = "object", namespace = Template.CDK_NAMESPACE)
+public class CdkObjectElement implements ModelElement {
+
+ @XmlAttribute(required = true)
+ private String name;
+
+ /**
+ * @return the bodyValue
+ */
+ public String getBodyValue() {
+ return bodyValue;
+ }
+
+ /**
+ * @param bodyValue the bodyValue to set
+ */
+ public void setBodyValue(String bodyValue) {
+ this.bodyValue = bodyValue;
+ }
+
+ @XmlAttribute
+ private String value;
+
+ @XmlValue
+ private String bodyValue;
+
+ @XmlAttribute(required = true)
+ private String type;
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the value
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * @param value the value to set
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * @param type the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ @Override
+ public void visit(TemplateVisitor visitor) throws CdkException {
+ visitor.visitElement(this);
+ }
+
+}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkOtherwiseElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkOtherwiseElement.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkOtherwiseElement.java 2009-11-11 20:48:15 UTC (rev 15864)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.
+ */
+package org.richfaces.cdk.templatecompiler.model;
+
+import org.richfaces.cdk.CdkException;
+
+/**
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+public class CdkOtherwiseElement extends ModelFragment {
+
+ @Override
+ public void beforeVisit(TemplateVisitor visitor) throws CdkException {
+ visitor.startElement(this);
+ }
+
+ @Override
+ public void afterVisit(TemplateVisitor visitor) throws CdkException {
+ visitor.endElement(this);
+ }
+}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkWhenElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkWhenElement.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkWhenElement.java 2009-11-11 20:48:15 UTC (rev 15864)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.
+ */
+package org.richfaces.cdk.templatecompiler.model;
+
+import org.richfaces.cdk.CdkException;
+
+/**
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+public class CdkWhenElement extends CdkConditionalJstlElementBase {
+
+ @Override
+ public void beforeVisit(TemplateVisitor visitor) throws CdkException {
+ visitor.startElement(this);
+ }
+
+ @Override
+ public void afterVisit(TemplateVisitor visitor) throws CdkException {
+ visitor.endElement(this);
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelElement.java 2009-11-11 18:14:51 UTC (rev 15863)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelElement.java 2009-11-11 20:48:15 UTC (rev 15864)
@@ -1,12 +1,6 @@
package org.richfaces.cdk.templatecompiler.model;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAnyElement;
-import javax.xml.bind.annotation.XmlMixed;
-
import org.richfaces.cdk.CdkException;
-import org.w3c.dom.Element;
public interface ModelElement {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java 2009-11-11 18:14:51 UTC (rev 15863)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java 2009-11-11 20:48:15 UTC (rev 15864)
@@ -14,13 +14,20 @@
* @author asmirnov(a)exadel.com
*
*/
-(a)XmlSeeAlso({CdkCallElement.class,CdkBodyElement.class})
+@XmlSeeAlso({
+ CdkCallElement.class,
+ CdkBodyElement.class,
+ CdkIfElement.class,
+ CdkChooseElement.class,
+ CdkObjectElement.class
+})
public class ModelFragment implements LeafModelElement {
private List<Object> children;
- @XmlAnyElement(lax=true,value=ElementsHandler.class)
+ //TODO filter unhandled elements from known namespaces
+ @XmlAnyElement(lax=true, value=ElementsHandler.class)
@XmlMixed
public List<Object> getChildren() {
return this.children;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java 2009-11-11 18:14:51 UTC (rev 15863)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java 2009-11-11 20:48:15 UTC (rev 15864)
@@ -34,7 +34,8 @@
@XmlRootElement(name="root",namespace=Template.CDK_NAMESPACE)
public class Template {
-
+ public static final String JSTL_CORE_NAMESPACE = "http://java.sun.com/jsp/jstl/core";
+
public static final String CDK_NAMESPACE="http://richfaces.org/cdk";
public static final String COMPOSITE_NAMESPACE="http://java.sun.com/jsf/composite";
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/TemplateVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/TemplateVisitor.java 2009-11-11 18:14:51 UTC (rev 15863)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/TemplateVisitor.java 2009-11-11 20:48:15 UTC (rev 15864)
@@ -44,4 +44,22 @@
void endElement(CdkBodyElement cdkBodyElement) throws CdkException;
+ void startElement(CdkIfElement cdkIfElement);
+
+ void endElement(CdkIfElement cdkIfElement);
+
+ void startElement(CdkWhenElement cdkWhenElement);
+
+ void endElement(CdkWhenElement cdkWhenElement);
+
+ void startElement(CdkChooseElement cdkChooseElement);
+
+ void endElement(CdkChooseElement cdkChooseElement);
+
+ void startElement(CdkOtherwiseElement cdkOtherwiseElement);
+
+ void endElement(CdkOtherwiseElement cdkOtherwiseElement);
+
+ void visitElement(CdkObjectElement cdkObjectElement);
+
}
Copied: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-composite.xsd (from rev 15863, root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/faces-composite.xsd)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-composite.xsd (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-composite.xsd 2009-11-11 20:48:15 UTC (rev 15864)
@@ -0,0 +1,247 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+
+<xs:schema targetNamespace="http://java.sun.com/jsf/composite"
+ xmlns:cc="http://java.sun.com/jsf/composite" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:xml="http://www.w3.org/XML/1998/namespace" elementFormDefault="qualified"
+ attributeFormDefault="unqualified">
+
+ <xs:attributeGroup name="beanDescriptorAttributes">
+ <xs:attribute name="displayName">
+ <xs:annotation>
+ <xs:documentation>
+ The name to display in a tool palette containing
+ this component. The
+ value of this attribute will be set as the value
+ for this property
+ on the composite component bean descriptor.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="preferred" type="xs:boolean" default="false">
+ <xs:annotation>
+ <xs:documentation>Is this a "preferred" component. The value of this
+ attribute will be set as the value for this property on the
+ composite component bean descriptor.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="expert" type="xs:boolean" default="false">
+ <xs:annotation>
+ <xs:documentation>Is this component only for expert users? The value
+ of this attribute will be set as the value for this property on the
+ composite component bean descriptor.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="shortDescription">
+ <xs:annotation>
+ <xs:documentation>
+ A short description of the purpose of this
+ component. The value of
+ this attribute will be set as the value for
+ this property on the
+ composite component bean descriptor.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </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:any processContents="lax" namespace="##other" />
+ </xs:choice>
+ </xs:sequence>
+ <xs:attribute name="name" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ The name of the attribute as it must appear on the
+ composite component
+ tag in the using page. If the value of the name
+ attribute is equal
+ to (without the quotes) "action",
+ "actionListener", "validator", or
+ "valueChangeListener", the action
+ described in
+ ViewHandler.retargetMethodExpressions() must be taken
+ to handle the
+ attribute. In these cases, the method-sigature
+ attribute, if
+ present, must be ignored as its value is derived as
+ described in
+ retargetMethodExpressions().
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="targets">
+ <xs:annotation>
+ <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)
+ 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>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="default">
+ <xs:annotation>
+ <xs:documentation>
+ 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:annotation>
+ </xs:attribute>
+ <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:annotation>
+ </xs:attribute>
+ <xs:attribute name="method-signature">
+ <xs:annotation>
+ <xs:documentation>
+ Declares that this attribute must be a
+ MethodExpression whose method
+ signature is described by the value of
+ this attribute. The
+ signature must be described using fully
+ qualified class names
+ wherever a type is required. This attribute is
+ mutually exclusive
+ with the "type" attribute. If both attributes are
+ present, the
+ "method-signature" attribute is ignored.
+
+ PENDING: when
+ this file is generated from the web-facesuicomponent_2_0.xsd,
+ we
+ will not need to copy the content here manually.
+
+ Provides the
+ signature of the Java method. The syntax of the
+ method-signature
+ element is as follows (taken from
+ function-signature in
+ web-jsptaglibrary_2_1.xsd):
+
+ MethodSignature ::= ReturnType S
+ MethodName S? '(' S? Parameters? S? ')'
+
+ ReturnType ::= Type
+
+ MethodName ::= Identifier
+
+ Parameters ::= Parameter | ( Parameter S?
+ ',' S? Parameters )
+
+ Parameter ::= Type
+
+ Where:
+
+ Type is a basic type or
+ a fully qualified Java class name (including
+ package name), as per
+ the 'Type' production in the Java Language
+ Specification, Second
+ Edition, Chapter 18.
+
+ Identifier is a Java identifier, as per the
+ 'Identifier' production in the
+ Java Language Specification, Second
+ Edition, Chapter 18.
+
+ Example:
+
+ java.lang.String nickName(java.lang.String, int)
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="type">
+ <xs:annotation>
+ <xs:documentation>
+ <xs:annotation name="type">
+ </xs:annotation>
+ Declares that this attribute must be a ValueExpression whose
+ expected type
+ is given by the value of this attribute. If not
+ specified, and no
+ "method-signature" attribute is present,
+ java.lang.Object is
+ assumed. This attribute is mutually exclusive
+ with the "type"
+ attribute. If both attributes are present, the
+ "method-signature"
+ attribute is ignored.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attributeGroup ref="cc:beanDescriptorAttributes" />
+ </xs:complexType>
+
+ <xs:complexType name="compositeExtensionType">
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:any processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="compositeInterfaceType">
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:choice>
+ <xs:any namespace="##any" processContents="lax" />
+ </xs:choice>
+ </xs:sequence>
+ <xs:attribute type="xs:string" name="name">
+ <xs:annotation>
+ <xs:documentation>
+ The name of this composite component. Advisory
+ only. The real name is
+ taken from the filename. The value of this
+ attribute will be set as
+ the value for this property on the
+ composite component bean
+ descriptor.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="componentType">
+ <xs:annotation>
+ <xs:documentation>
+ The component-type of the UIComponent that will
+ serve as the composite
+ component root for this composite component.
+ The declared
+ component-family for this component must be
+ javax.faces.NamingContainer.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attributeGroup ref="cc:beanDescriptorAttributes" />
+ </xs:complexType>
+
+ <xs:complexType name="compositeImplementationType"
+ mixed="true">
+ <xs:choice>
+ <xs:any minOccurs="0" maxOccurs="unbounded" processContents="lax" />
+ </xs:choice>
+ </xs:complexType>
+
+ <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:schema>
Added: 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 (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-jstl-core.xsd 2009-11-11 20:48:15 UTC (rev 15864)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://java.sun.com/jsp/jstl/core" xmlns="http://java.sun.com/jsp/jstl/core"
+ xmlns:cdk="http://richfaces.org/cdk"
+ elementFormDefault="qualified" attributeFormDefault="unqualified">
+
+ <xs:import schemaLocation="cdk-template.xsd" namespace="http://richfaces.org/cdk" />
+
+ <xs:attributeGroup name="testGroup">
+ <xs:attribute name="test" form="unqualified" use="required"
+ type="cdk:elStrictExpression" />
+ </xs:attributeGroup>
+
+ <xs:complexType name="arbitraryContent" mixed="true">
+ <xs:choice>
+ <xs:any minOccurs="0" maxOccurs="unbounded" />
+ </xs:choice>
+ </xs:complexType>
+
+ <xs:complexType name="arbitraryConditionalContent">
+ <xs:complexContent>
+ <xs:extension base="arbitraryContent">
+ <xs:attributeGroup ref="testGroup" />
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <xs:element name="if" type="arbitraryConditionalContent" />
+ <xs:element name="choose">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" name="when"
+ type="arbitraryConditionalContent" />
+ <xs:element minOccurs="0" name="otherwise" type="arbitraryContent" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
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 2009-11-11 18:14:51 UTC (rev 15863)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd 2009-11-11 20:48:15 UTC (rev 15864)
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://richfaces.org/cdk" xmlns="http://richfaces.org/cdk"
- elementFormDefault="qualified" attributeFormDefault="qualified"
- xmlns:xhtml="http://richfaces.org/xhtml-el"
- xmlns:javaee="http://java.sun.com/xml/ns/javaee"
+ elementFormDefault="qualified" attributeFormDefault="unqualified"
+ xmlns:xhtml="http://richfaces.org/xhtml-el" xmlns:javaee="http://java.sun.com/xml/ns/javaee"
+ xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:cc="http://java.sun.com/jsf/composite">
-
- <xs:import schemaLocation="web-facesuicomponent_2_0.xsd" namespace="http://java.sun.com/xml/ns/javaee" />
- <xs:import schemaLocation="faces-composite.xsd" namespace="http://java.sun.com/jsf/composite" />
+ <xs:import schemaLocation="web-facesuicomponent_2_0.xsd" namespace="http://java.sun.com/xml/ns/javaee" />
+ <xs:import schemaLocation="cdk-composite.xsd" namespace="http://java.sun.com/jsf/composite" />
+ <xs:import schemaLocation="cdk-jstl-core.xsd" namespace="http://java.sun.com/jsp/jstl/core" />
+
<xs:simpleType name="elStrictExpression">
<xs:restriction base="xs:string">
<xs:pattern value="#\{[^\}]+\}" />
@@ -29,10 +30,6 @@
<xs:attribute name="passThroughWithExclusions" type="xs:NMTOKENS" />
</xs:attributeGroup>
- <xs:attributeGroup name="testGroup">
- <xs:attribute name="test" form="unqualified" use="required" type="elStrictExpression" />
- </xs:attributeGroup>
-
<xs:element name="root">
<xs:complexType>
<xs:sequence>
@@ -50,16 +47,17 @@
</xs:restriction>
</xs:simpleType>
- <xs:complexType name="resource-dependenciesComplexType">
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element name="resource-dependency" type="resourceDependencyType" />
- </xs:sequence>
- </xs:complexType>
+ <xs:complexType name="resource-dependenciesComplexType">
+ <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="target" form="unqualified" type="resourceDependencyTargets" />
+ <xs:attribute name="target" form="unqualified"
+ type="resourceDependencyTargets" />
</xs:complexType>
<xs:element name="resource-dependencies">
@@ -91,48 +89,26 @@
</xs:choice>
</xs:complexType>
</xs:element>
- <xs:element ref="if" />
- <xs:element ref="choose" />
+ <xs:element ref="c:if" />
+ <xs:element ref="c:choose" />
<xs:element ref="call" />
</xs:choice>
</xs:group>
- <xs:element name="if">
- <xs:complexType mixed="true">
- <xs:choice>
- <xs:any minOccurs="0" maxOccurs="unbounded" />
- </xs:choice>
- <xs:attributeGroup ref="testGroup" />
- </xs:complexType>
- </xs:element>
- <xs:element name="choose">
- <xs:complexType>
- <xs:sequence>
- <xs:element maxOccurs="unbounded" name="when">
- <xs:complexType>
- <xs:choice>
- <xs:any minOccurs="0"
- maxOccurs="unbounded">
- </xs:any>
- </xs:choice>
- <xs:attributeGroup ref="testGroup" />
- </xs:complexType>
- </xs:element>
- <xs:element minOccurs="0" name="otherwise">
- <xs:complexType>
- <xs:choice>
- <xs:any minOccurs="0"
- maxOccurs="unbounded">
- </xs:any>
- </xs:choice>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
<xs:element name="call">
<xs:complexType>
<xs:attribute name="expression" form="unqualified" />
</xs:complexType>
</xs:element>
+ <xs:element name="object">
+ <xs:complexType mixed="true">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="name" form="unqualified" use="required" />
+ <xs:attribute name="value" form="unqualified" />
+ <xs:attribute name="type" form="unqualified" />
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
</xs:schema>
Deleted: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/faces-composite.xsd
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/faces-composite.xsd 2009-11-11 18:14:51 UTC (rev 15863)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/faces-composite.xsd 2009-11-11 20:48:15 UTC (rev 15864)
@@ -1,247 +0,0 @@
-<?xml version = "1.0" encoding = "UTF-8"?>
-
-<xs:schema targetNamespace="http://java.sun.com/jsf/composite"
- xmlns:cc="http://java.sun.com/jsf/composite" xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:xml="http://www.w3.org/XML/1998/namespace" elementFormDefault="qualified"
- attributeFormDefault="unqualified">
-
- <xs:attributeGroup name="beanDescriptorAttributes">
- <xs:attribute name="displayName">
- <xs:annotation>
- <xs:documentation>
- The name to display in a tool palette containing
- this component. The
- value of this attribute will be set as the value
- for this property
- on the composite component bean descriptor.
- </xs:documentation>
- </xs:annotation>
- </xs:attribute>
- <xs:attribute name="preferred" type="xs:boolean" default="false">
- <xs:annotation>
- <xs:documentation>Is this a "preferred" component. The value of this
- attribute will be set as the value for this property on the
- composite component bean descriptor.</xs:documentation>
- </xs:annotation>
- </xs:attribute>
- <xs:attribute name="expert" type="xs:boolean" default="false">
- <xs:annotation>
- <xs:documentation>Is this component only for expert users? The value
- of this attribute will be set as the value for this property on the
- composite component bean descriptor.</xs:documentation>
- </xs:annotation>
- </xs:attribute>
- <xs:attribute name="shortDescription">
- <xs:annotation>
- <xs:documentation>
- A short description of the purpose of this
- component. The value of
- this attribute will be set as the value for
- this property on the
- composite component bean descriptor.
- </xs:documentation>
- </xs:annotation>
- </xs:attribute>
- </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:any processContents="lax" namespace="##other" />
- </xs:choice>
- </xs:sequence>
- <xs:attribute name="name" use="required">
- <xs:annotation>
- <xs:documentation>
- The name of the attribute as it must appear on the
- composite component
- tag in the using page. If the value of the name
- attribute is equal
- to (without the quotes) "action",
- "actionListener", "validator", or
- "valueChangeListener", the action
- described in
- ViewHandler.retargetMethodExpressions() must be taken
- to handle the
- attribute. In these cases, the method-sigature
- attribute, if
- present, must be ignored as its value is derived as
- described in
- retargetMethodExpressions().
- </xs:documentation>
- </xs:annotation>
- </xs:attribute>
- <xs:attribute name="targets">
- <xs:annotation>
- <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)
- 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>
- </xs:annotation>
- </xs:attribute>
- <xs:attribute name="default">
- <xs:annotation>
- <xs:documentation>
- 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:annotation>
- </xs:attribute>
- <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:annotation>
- </xs:attribute>
- <xs:attribute name="method-signature">
- <xs:annotation>
- <xs:documentation>
- Declares that this attribute must be a
- MethodExpression whose method
- signature is described by the value of
- this attribute. The
- signature must be described using fully
- qualified class names
- wherever a type is required. This attribute is
- mutually exclusive
- with the "type" attribute. If both attributes are
- present, the
- "method-signature" attribute is ignored.
-
- PENDING: when
- this file is generated from the web-facesuicomponent_2_0.xsd,
- we
- will not need to copy the content here manually.
-
- Provides the
- signature of the Java method. The syntax of the
- method-signature
- element is as follows (taken from
- function-signature in
- web-jsptaglibrary_2_1.xsd):
-
- MethodSignature ::= ReturnType S
- MethodName S? '(' S? Parameters? S? ')'
-
- ReturnType ::= Type
-
- MethodName ::= Identifier
-
- Parameters ::= Parameter | ( Parameter S?
- ',' S? Parameters )
-
- Parameter ::= Type
-
- Where:
-
- Type is a basic type or
- a fully qualified Java class name (including
- package name), as per
- the 'Type' production in the Java Language
- Specification, Second
- Edition, Chapter 18.
-
- Identifier is a Java identifier, as per the
- 'Identifier' production in the
- Java Language Specification, Second
- Edition, Chapter 18.
-
- Example:
-
- java.lang.String nickName(java.lang.String, int)
- </xs:documentation>
- </xs:annotation>
- </xs:attribute>
- <xs:attribute name="type">
- <xs:annotation>
- <xs:documentation>
- <xs:annotation name="type">
- </xs:annotation>
- Declares that this attribute must be a ValueExpression whose
- expected type
- is given by the value of this attribute. If not
- specified, and no
- "method-signature" attribute is present,
- java.lang.Object is
- assumed. This attribute is mutually exclusive
- with the "type"
- attribute. If both attributes are present, the
- "method-signature"
- attribute is ignored.
- </xs:documentation>
- </xs:annotation>
- </xs:attribute>
- <xs:attributeGroup ref="cc:beanDescriptorAttributes" />
- </xs:complexType>
-
- <xs:complexType name="compositeExtensionType">
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:any processContents="lax" />
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="compositeInterfaceType">
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:choice>
- <xs:any namespace="##any" processContents="lax" />
- </xs:choice>
- </xs:sequence>
- <xs:attribute type="xs:string" name="name">
- <xs:annotation>
- <xs:documentation>
- The name of this composite component. Advisory
- only. The real name is
- taken from the filename. The value of this
- attribute will be set as
- the value for this property on the
- composite component bean
- descriptor.
- </xs:documentation>
- </xs:annotation>
- </xs:attribute>
- <xs:attribute type="xs:string" name="componentType">
- <xs:annotation>
- <xs:documentation>
- The component-type of the UIComponent that will
- serve as the composite
- component root for this composite component.
- The declared
- component-family for this component must be
- javax.faces.NamingContainer.
- </xs:documentation>
- </xs:annotation>
- </xs:attribute>
- <xs:attributeGroup ref="cc:beanDescriptorAttributes" />
- </xs:complexType>
-
- <xs:complexType name="compositeImplementationType"
- mixed="true">
- <xs:choice>
- <xs:any minOccurs="0" maxOccurs="unbounded" processContents="lax" />
- </xs:choice>
- </xs:complexType>
-
- <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: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 2009-11-11 18:14:51 UTC (rev 15863)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java 2009-11-11 20:48:15 UTC (rev 15864)
@@ -45,7 +45,7 @@
private static final String TEMPLATE_EPILOG = "</cc:implementation></cdk:root>";
private static final String TEMPLATE_MIDDLE = "</cc:interface><cc:implementation>";
- public static final String TEMPLATE_PROLOG = "<cdk:root xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:cdk=\"http://richfaces.org/cdk\" xmlns:cc=\"http://java.sun.com/jsf/composite\"><cc:interface>";
+ public static final String TEMPLATE_PROLOG = "<cdk:root xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:cdk=\"http://richfaces.org/cdk\" xmlns:c=\"http://java.sun.com/jsp/jstl/core\" xmlns:cc=\"http://java.sun.com/jsf/composite\"><cc:interface>";
private static final Object DEFAULT_ATTRIBUTE_TYPE = Object.class.getName();
@Test
@@ -71,15 +71,86 @@
}
@Test
+ public void testJstlCoreElements() throws Exception {
+ Template template = unmarshal(Template.class, TEMPLATE_PROLOG
+ + TEMPLATE_MIDDLE +
+ "start" +
+ "<c:if test=\"#{someTest}\">if content</c:if>" +
+ "<c:choose>" +
+ "<c:when test=\"#{anotherTest}\">when content</c:when>" +
+ "<c:when test=\"#{coolTest}\">" +
+ "<c:if test=\"#{nestedIfTest}\">nested if content</c:if>" +
+ "</c:when>" +
+ "<c:otherwise>otherwise content</c:otherwise>" +
+ "</c:choose>" +
+ "finish" +
+ TEMPLATE_EPILOG);
+
+ CompositeImplementation implementation = template.getImplementation();
+ assertNotNull(implementation);
+
+ List<Object> children = implementation.getChildren();
+ assertNotNull(children);
+ assertEquals(4, children.size());
+ assertEquals("start", children.get(0));
+ assertEquals(CdkIfElement.class, children.get(1).getClass());
+ CdkIfElement ifElement = (CdkIfElement) children.get(1);
+ assertEquals("#{someTest}", ifElement.getTest());
+ List<Object> ifChildren = ifElement.getChildren();
+ assertNotNull(ifChildren);
+ assertEquals(1, ifChildren.size());
+ assertEquals("if content", ifChildren.get(0));
+
+ assertEquals(CdkChooseElement.class, children.get(2).getClass());
+ CdkChooseElement chooseElement = (CdkChooseElement) children.get(2);
+ List<Object> chooseChildren = chooseElement.getChildren();
+ assertNotNull(chooseChildren);
+ assertEquals(3, chooseChildren.size());
+
+ assertEquals(CdkWhenElement.class, chooseChildren.get(0).getClass());
+ CdkWhenElement firstWhen = (CdkWhenElement) chooseChildren.get(0);
+ assertEquals("#{anotherTest}", firstWhen.getTest());
+ List<Object> childrenOfFirstWhen = firstWhen.getChildren();
+ assertNotNull(childrenOfFirstWhen);
+ assertEquals(1, childrenOfFirstWhen.size());
+ assertEquals("when content", childrenOfFirstWhen.get(0));
+
+ assertEquals(CdkWhenElement.class, chooseChildren.get(1).getClass());
+ CdkWhenElement secondWhen = (CdkWhenElement) chooseChildren.get(1);
+ assertEquals("#{coolTest}", secondWhen.getTest());
+
+ List<Object> childrenOfSecondWhen = secondWhen.getChildren();
+ assertNotNull(childrenOfSecondWhen);
+ assertEquals(1, childrenOfSecondWhen.size());
+
+ assertEquals(CdkIfElement.class, childrenOfSecondWhen.get(0).getClass());
+ CdkIfElement nestedIf = (CdkIfElement) childrenOfSecondWhen.get(0);
+ assertEquals("#{nestedIfTest}", nestedIf.getTest());
+ List<Object> childrenOfNestedIf = nestedIf.getChildren();
+ assertNotNull(childrenOfNestedIf);
+ assertEquals(1, childrenOfNestedIf.size());
+ assertEquals("nested if content", childrenOfNestedIf.get(0));
+
+ assertEquals(CdkOtherwiseElement.class, chooseChildren.get(2).getClass());
+ CdkOtherwiseElement otherwiseElement = (CdkOtherwiseElement) chooseChildren.get(2);
+ List<Object> childrenOfOtherwiseElement = otherwiseElement.getChildren();
+ assertNotNull(childrenOfOtherwiseElement);
+ assertEquals(1, childrenOfOtherwiseElement.size());
+ assertEquals("otherwise content", childrenOfOtherwiseElement.get(0));
+
+ assertEquals("finish", children.get(3));
+ }
+
+ @Test
public void testInterface() throws Exception {
Template template = unmarshal(Template.class, TEMPLATE_PROLOG +
- " <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>" +
+ "<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>" +
TEMPLATE_MIDDLE + TEMPLATE_EPILOG);
CompositeInterface interfaceSection = template.getInterface();
@@ -224,11 +295,11 @@
@Test
public void testResourceDependencies() throws Exception {
Template template = unmarshal(Template.class, TEMPLATE_PROLOG +
- " <cdk:resource-dependencies>" +
- " <cdk:resource-dependency name=\"jquery.js\" />" +
- " <cdk:resource-dependency name=\"richfaces.css\" library=\"org.richfaces\" />" +
- " <cdk:resource-dependency name=\"richfaces.js\" library=\"org.richfaces\" target=\"body\" /> " +
- " </cdk:resource-dependencies> " +
+ "<cdk:resource-dependencies>" +
+ "<cdk:resource-dependency name=\"jquery.js\" />" +
+ "<cdk:resource-dependency name=\"richfaces.css\" library=\"org.richfaces\" />" +
+ "<cdk:resource-dependency name=\"richfaces.js\" library=\"org.richfaces\" target=\"body\" /> " +
+ "</cdk:resource-dependencies> " +
TEMPLATE_MIDDLE + TEMPLATE_EPILOG);
@@ -259,7 +330,38 @@
assertEquals("org.richfaces", resourceDependency.getLibrary());
assertEquals("body", resourceDependency.getTarget());
}
-
+
+ @Test
+ public void testObject() throws Exception {
+ Template template = unmarshal(Template.class, TEMPLATE_PROLOG + TEMPLATE_MIDDLE +
+ "<cdk:object name=\"rowCount\" type=\"int\" value=\"#{getRowCount(context)}\" />" +
+ "<cdk:object name=\"bodyExpression\" type=\"java.lang.String\">" +
+ "\"test expression\" +\n\"second line\"" +
+ "</cdk:object>" +
+
+ TEMPLATE_EPILOG);
+
+ CompositeImplementation implementation = template.getImplementation();
+ assertNotNull(implementation);
+
+ List<Object> children = implementation.getChildren();
+ assertNotNull(children);
+ assertEquals(2, children.size());
+
+ assertEquals(CdkObjectElement.class, children.get(0).getClass());
+ CdkObjectElement firstObject = (CdkObjectElement) children.get(0);
+ assertNotNull(firstObject);
+ assertEquals("rowCount", firstObject.getName());
+ assertEquals("int", firstObject.getType());
+ assertEquals("#{getRowCount(context)}", firstObject.getValue());
+
+ assertEquals(CdkObjectElement.class, children.get(1).getClass());
+ CdkObjectElement secondObject = (CdkObjectElement) children.get(1);
+ assertNotNull(secondObject);
+ assertEquals("bodyExpression", secondObject.getName());
+ assertEquals("java.lang.String", secondObject.getType());
+ assertEquals("\"test expression\" +\n\"second line\"", secondObject.getBodyValue());
+ }
}
15 years, 1 month
JBoss Rich Faces SVN: r15863 - in root/cdk/trunk/plugins/generator/src: main/java/org/richfaces/cdk/templatecompiler/model and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-11-11 13:14:51 -0500 (Wed, 11 Nov 2009)
New Revision: 15863
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ResourceDependency.java
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/model/Attribute.java
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/Template.java
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/faces-composite.xsd
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java
Log:
https://jira.jboss.org/jira/browse/RF-7732
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 2009-11-11 01:29:38 UTC (rev 15862)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2009-11-11 18:14:51 UTC (rev 15863)
@@ -25,21 +25,21 @@
package org.richfaces.cdk.templatecompiler;
+import java.io.File;
+
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.ModelBuilder;
import org.richfaces.cdk.StandardSources;
-import org.richfaces.cdk.model.*;
+import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.Component;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.RenderKit;
+import org.richfaces.cdk.model.Renderer;
import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
import org.richfaces.cdk.templatecompiler.model.Template;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
-import javax.xml.stream.XMLStreamException;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -72,11 +72,12 @@
component.getRenderers().add(renderer);
}
- String family = compositeInterface.getFamily();
+ String family = compositeInterface.getComponentFamily();
if (null != family) {
renderer.setFamily(family);
}
+
renderer.setRendererClass(new ClassDescription(compositeInterface.getJavaClass()));
renderer.setTemplate(template);
// } catch (FileNotFoundException e) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java 2009-11-11 01:29:38 UTC (rev 15862)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java 2009-11-11 18:14:51 UTC (rev 15863)
@@ -50,17 +50,20 @@
private String methodSignature;
@XmlAttribute
- private String applyTo;
+ private String targets;
@XmlAttribute
private boolean required;
@XmlAttribute
- private boolean preffered;
+ private boolean preferred;
@XmlAttribute
private boolean expert;
+ @XmlAttribute
+ private String type = Object.class.getName();
+
/**
* <p class="changed_added_4_0"></p>
* @return the name
@@ -143,18 +146,18 @@
/**
* <p class="changed_added_4_0"></p>
- * @return the applyTo
+ * @return the targets
*/
- public String getApplyTo() {
- return this.applyTo;
+ public String getTargets() {
+ return this.targets;
}
/**
* <p class="changed_added_4_0"></p>
- * @param applyTo the applyTo to set
+ * @param targets the targets to set
*/
- public void setApplyTo(String applyTo) {
- this.applyTo = applyTo;
+ public void setTargets(String applyTo) {
+ this.targets = applyTo;
}
/**
@@ -177,16 +180,16 @@
* <p class="changed_added_4_0"></p>
* @return the preffered
*/
- public boolean isPreffered() {
- return this.preffered;
+ public boolean isPreferred() {
+ return this.preferred;
}
/**
* <p class="changed_added_4_0"></p>
* @param preffered the preffered to set
*/
- public void setPreffered(boolean preffered) {
- this.preffered = preffered;
+ public void setPreferred(boolean preffered) {
+ this.preferred = preffered;
}
/**
@@ -205,4 +208,20 @@
this.expert = expert;
}
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ //TODO: add handling
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
}
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 2009-11-11 01:29:38 UTC (rev 15862)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java 2009-11-11 18:14:51 UTC (rev 15863)
@@ -27,6 +27,7 @@
import javax.faces.render.RenderKitFactory;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlType;
/**
@@ -39,10 +40,12 @@
private String componentType;
- private String family;
+ private String componentFamily;
private List<Attribute> attributes;
+ private List<ResourceDependency> resourceDependencies;
+
private String renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
private String javaClass;
@@ -50,6 +53,9 @@
private String baseClass;
private String rendererType;
+
+ private boolean rendersChildren = true;
+
/**
* <p class="changed_added_4_0"></p>
* @return the componentType
@@ -71,17 +77,17 @@
* <p class="changed_added_4_0"></p>
* @return the family
*/
- @XmlElement(name="family",namespace=Template.CDK_NAMESPACE)
- public String getFamily() {
- return this.family;
+ @XmlElement(name="component-family",namespace=Template.CDK_NAMESPACE)
+ public String getComponentFamily() {
+ return this.componentFamily;
}
/**
* <p class="changed_added_4_0"></p>
* @param family the family to set
*/
- public void setFamily(String family) {
- this.family = family;
+ public void setComponentFamily(String family) {
+ this.componentFamily = family;
}
/**
@@ -103,9 +109,28 @@
/**
* <p class="changed_added_4_0"></p>
+ * @return the resourceDependencies
+ */
+ @XmlElementWrapper(name = "resource-dependencies", namespace = Template.CDK_NAMESPACE)
+ @XmlElement(name="resource-dependency", namespace=Template.CDK_NAMESPACE)
+ public List<ResourceDependency> getResourceDependencies() {
+ return resourceDependencies;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param resourceDependencies the resourceDependencies to set
+ */
+ public void setResourceDependencies(
+ List<ResourceDependency> resourceDependencies) {
+ this.resourceDependencies = resourceDependencies;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
* @return the renderKitId
*/
- @XmlElement(name="render-kit",namespace=Template.CDK_NAMESPACE)
+ @XmlElement(name="renderkit-id",namespace=Template.CDK_NAMESPACE)
public String getRenderKitId() {
return this.renderKitId;
}
@@ -168,5 +193,21 @@
public void setBaseClass(String baseClass) {
this.baseClass = baseClass;
}
-
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the rendersChildren
+ */
+ //TODO: add handling
+ @XmlElement(name="renders-children",namespace=Template.CDK_NAMESPACE)
+ public boolean isRendersChildren() {
+ return rendersChildren;
+ }
+
+ /**
+ * @param rendersChildren the rendersChildren to set
+ */
+ public void setRendersChildren(boolean rendersChildren) {
+ this.rendersChildren = rendersChildren;
+ }
}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ResourceDependency.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ResourceDependency.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ResourceDependency.java 2009-11-11 18:14:51 UTC (rev 15863)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.
+ */
+package org.richfaces.cdk.templatecompiler.model;
+
+import java.text.MessageFormat;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+@XmlType(name = "resourceDependencyType", namespace = Template.CDK_NAMESPACE)
+public class ResourceDependency {
+
+ private String name;
+
+ private String library;
+
+ private String target = "head";
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ @XmlAttribute(name = "name", required = true)
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the libraryName
+ */
+ @XmlAttribute(name = "library")
+ public String getLibrary() {
+ return library;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param library the libraryName to set
+ */
+ public void setLibrary(String library) {
+ this.library = library;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the target
+ */
+ @XmlAttribute(name = "target")
+ public String getTarget() {
+ return target;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param target the target to set
+ */
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ @Override
+ public String toString() {
+ return MessageFormat.format("ResourceDependency[name={0}, library={1}, target={2}]", getName(), getLibrary(), getTarget());
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java 2009-11-11 01:29:38 UTC (rev 15862)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java 2009-11-11 18:14:51 UTC (rev 15863)
@@ -25,7 +25,6 @@
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlSeeAlso;
/**
* <p class="changed_added_4_0"></p>
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 2009-11-11 01:29:38 UTC (rev 15862)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd 2009-11-11 18:14:51 UTC (rev 15863)
@@ -6,8 +6,8 @@
xmlns:javaee="http://java.sun.com/xml/ns/javaee"
xmlns:cc="http://java.sun.com/jsf/composite">
- <xs:import schemaLocation="web-facesuicomponent_2_0.xsd" namespace="http://java.sun.com/xml/ns/javaee"/>
- <xs:import schemaLocation="faces-composite.xsd" namespace="http://java.sun.com/jsf/composite"/>
+ <xs:import schemaLocation="web-facesuicomponent_2_0.xsd" namespace="http://java.sun.com/xml/ns/javaee" />
+ <xs:import schemaLocation="faces-composite.xsd" namespace="http://java.sun.com/jsf/composite" />
<xs:simpleType name="elStrictExpression">
<xs:restriction base="xs:string">
@@ -42,19 +42,46 @@
</xs:complexType>
</xs:element>
- <xs:element name="metadata">
+ <xs:simpleType name="resourceDependencyTargets">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="body" />
+ <xs:enumeration value="form" />
+ <xs:enumeration value="head" />
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:complexType name="resource-dependenciesComplexType">
+ <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="target" form="unqualified" type="resourceDependencyTargets" />
+ </xs:complexType>
+
+ <xs:element name="resource-dependencies">
<xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="0" name="class" type="javaee:fully-qualified-classType" default="javax.faces.render.Renderer" />
- <xs:element minOccurs="0" name="base-class" type="javaee:fully-qualified-classType" />
- <xs:element minOccurs="0" name="component-class" type="javaee:fully-qualified-classType" default="javax.faces.component.UIComponent" />
- <xs:element minOccurs="0" name="render-kit-id" />
- <xs:element minOccurs="0" name="component-family" />
- <xs:element minOccurs="0" name="renderer-type" />
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:choice>
+ <xs:element name="resource-dependency" type="resourceDependencyType" />
+ </xs:choice>
</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-type" />
+
+ <xs:element name="renderkit-id" />
+ <xs:element name="component-family" />
+ <xs:element name="renderer-type" />
+ <xs:element name="renders-children" type="xs:boolean" />
+
<xs:group name="structural">
<xs:choice>
<xs:element name="body">
@@ -70,7 +97,6 @@
</xs:choice>
</xs:group>
-
<xs:element name="if">
<xs:complexType mixed="true">
<xs:choice>
Modified: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/faces-composite.xsd
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/faces-composite.xsd 2009-11-11 01:29:38 UTC (rev 15862)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/faces-composite.xsd 2009-11-11 18:14:51 UTC (rev 15863)
@@ -17,14 +17,14 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="preferred" type="xs:boolean">
+ <xs:attribute name="preferred" type="xs:boolean" default="false">
<xs:annotation>
<xs:documentation>Is this a "preferred" component. The value of this
attribute will be set as the value for this property on the
composite component bean descriptor.</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="expert" type="xs:boolean">
+ <xs:attribute name="expert" type="xs:boolean" default="false">
<xs:annotation>
<xs:documentation>Is this component only for expert users? The value
of this attribute will be set as the value for this property on the
@@ -73,7 +73,7 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="targets" use="required">
+ <xs:attribute name="targets">
<xs:annotation>
<xs:documentation>
If this element has a method-signature attribute, the value of the
@@ -103,7 +103,7 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="required" type="xs:boolean">
+ <xs:attribute name="required" type="xs:boolean" default="false">
<xs:annotation>
<xs:documentation>
True if the page author must supply a value for
@@ -166,8 +166,7 @@
Example:
- java.lang.String nickName(
- java.lang.String, int )
+ java.lang.String nickName(java.lang.String, int)
</xs:documentation>
</xs:annotation>
</xs:attribute>
@@ -202,8 +201,7 @@
<xs:complexType name="compositeInterfaceType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:choice>
- <xs:element ref="cc:extension" />
- <xs:element ref="cc:attribute" />
+ <xs:any namespace="##any" processContents="lax" />
</xs:choice>
</xs:sequence>
<xs:attribute type="xs:string" name="name">
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 2009-11-11 01:29:38 UTC (rev 15862)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java 2009-11-11 18:14:51 UTC (rev 15863)
@@ -23,7 +23,11 @@
package org.richfaces.cdk.templatecompiler.model;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import java.util.List;
@@ -42,6 +46,7 @@
private static final String TEMPLATE_EPILOG = "</cc:implementation></cdk:root>";
private static final String TEMPLATE_MIDDLE = "</cc:interface><cc:implementation>";
public static final String TEMPLATE_PROLOG = "<cdk:root xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:cdk=\"http://richfaces.org/cdk\" xmlns:cc=\"http://java.sun.com/jsf/composite\"><cc:interface>";
+ private static final Object DEFAULT_ATTRIBUTE_TYPE = Object.class.getName();
@Test
public void testTemplate() throws Exception {
@@ -64,4 +69,197 @@
assertEquals(AnyElement.class, children.get(1).getClass());
assertEquals(String.class, children.get(2).getClass());
}
+
+ @Test
+ public void testInterface() throws Exception {
+ Template template = unmarshal(Template.class, TEMPLATE_PROLOG +
+ " <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>" +
+ TEMPLATE_MIDDLE + TEMPLATE_EPILOG);
+
+ CompositeInterface interfaceSection = template.getInterface();
+ assertNotNull(interfaceSection);
+
+ 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());
+
+ }
+
+ @Test
+ public void testAttributes() throws Exception {
+ Template template = unmarshal(Template.class, TEMPLATE_PROLOG +
+ "<cc:attribute name=\"onclick\" />" +
+ "<cc:attribute name=\"mode\" default=\"ajax\" />" +
+ "<cc:attribute name=\"action\" method-signature=\"void action()\" />" +
+ "<cc:attribute name=\"changeListener\" method-signature=\"void changeListener(ValueChangeEvent)\" targets=\"changes changes1\" />" +
+ "<cc:attribute name=\"disabled\" type=\"boolean\" />" +
+ "<cc:attribute name=\"delay\" type=\"java.lang.Integer\" />" +
+ "<cc:attribute name=\"id\" required=\"true\" />" +
+ "<cc:attribute name=\"experts\" shortDescription=\"For use by experts\" displayName=\"Expert attribute\" expert=\"true\" />" +
+ "<cc:attribute name=\"preferred\" shortDescription=\"It's a preferred attribute\" displayName=\"Preferred attribute\" preferred=\"true\" />" +
+ TEMPLATE_MIDDLE + TEMPLATE_EPILOG);
+
+ CompositeInterface interfaceSection = template.getInterface();
+ assertNotNull(interfaceSection);
+
+ List<Attribute> attributes = interfaceSection.getAttributes();
+ assertNotNull(attributes);
+ assertEquals(9, attributes.size());
+
+ Attribute attribute;
+
+ attribute = attributes.get(0);
+ assertNotNull(attribute);
+ assertEquals("onclick", attribute.getName());
+ assertNull(attribute.getDefaultValue());
+ assertNull(attribute.getMethodSignature());
+ assertEquals(DEFAULT_ATTRIBUTE_TYPE, attribute.getType());
+ assertNull(attribute.getTargets());
+ assertFalse(attribute.isRequired());
+ assertFalse(attribute.isExpert());
+ assertFalse(attribute.isPreferred());
+
+ attribute = attributes.get(1);
+ assertNotNull(attribute);
+ assertEquals("mode", attribute.getName());
+ assertEquals("ajax", attribute.getDefaultValue());
+ assertNull(attribute.getMethodSignature());
+ assertEquals(DEFAULT_ATTRIBUTE_TYPE, attribute.getType());
+ assertNull(attribute.getTargets());
+ assertFalse(attribute.isRequired());
+ assertFalse(attribute.isExpert());
+ assertFalse(attribute.isPreferred());
+
+ attribute = attributes.get(2);
+ assertNotNull(attribute);
+ assertEquals("action", attribute.getName());
+ assertNull(attribute.getDefaultValue());
+ assertEquals("void action()", attribute.getMethodSignature());
+ assertEquals(DEFAULT_ATTRIBUTE_TYPE, attribute.getType());
+ assertNull(attribute.getTargets());
+ assertFalse(attribute.isRequired());
+ assertFalse(attribute.isExpert());
+ assertFalse(attribute.isPreferred());
+
+ attribute = attributes.get(3);
+ assertNotNull(attribute);
+ assertEquals("changeListener", attribute.getName());
+ assertNull(attribute.getDefaultValue());
+ assertEquals("void changeListener(ValueChangeEvent)", attribute.getMethodSignature());
+ assertEquals(DEFAULT_ATTRIBUTE_TYPE, attribute.getType());
+ assertEquals("changes changes1", attribute.getTargets());
+ assertFalse(attribute.isRequired());
+ assertFalse(attribute.isExpert());
+ assertFalse(attribute.isPreferred());
+
+ attribute = attributes.get(4);
+ assertNotNull(attribute);
+ assertEquals("disabled", attribute.getName());
+ assertNull(attribute.getDefaultValue());
+ assertNull(attribute.getMethodSignature());
+ assertEquals("boolean", attribute.getType());
+ assertNull(attribute.getTargets());
+ assertFalse(attribute.isRequired());
+ assertFalse(attribute.isExpert());
+ assertFalse(attribute.isPreferred());
+
+ attribute = attributes.get(5);
+ assertNotNull(attribute);
+ assertEquals("delay", attribute.getName());
+ assertNull(attribute.getDefaultValue());
+ assertNull(attribute.getMethodSignature());
+ assertEquals("java.lang.Integer", attribute.getType());
+ assertNull(attribute.getTargets());
+ assertFalse(attribute.isRequired());
+ assertFalse(attribute.isExpert());
+ assertFalse(attribute.isPreferred());
+
+ attribute = attributes.get(6);
+ assertNotNull(attribute);
+ assertEquals("id", attribute.getName());
+ assertNull(attribute.getDefaultValue());
+ assertNull(attribute.getMethodSignature());
+ assertEquals(DEFAULT_ATTRIBUTE_TYPE, attribute.getType());
+ assertNull(attribute.getTargets());
+ assertTrue(attribute.isRequired());
+ assertFalse(attribute.isExpert());
+ assertFalse(attribute.isPreferred());
+
+ attribute = attributes.get(7);
+ assertNotNull(attribute);
+ assertFalse(attribute.isRequired());
+ assertEquals("experts", attribute.getName());
+ assertNull(attribute.getDefaultValue());
+ assertNull(attribute.getMethodSignature());
+ assertEquals(DEFAULT_ATTRIBUTE_TYPE, attribute.getType());
+ assertNull(attribute.getTargets());
+ assertEquals("For use by experts", attribute.getShortDescription());
+ assertEquals("Expert attribute", attribute.getDisplayName());
+ assertTrue(attribute.isExpert());
+ assertFalse(attribute.isPreferred());
+
+ attribute = attributes.get(8);
+ assertNotNull(attribute);
+ assertFalse(attribute.isRequired());
+ assertFalse(attribute.isExpert());
+ assertEquals("preferred", attribute.getName());
+ assertNull(attribute.getDefaultValue());
+ assertNull(attribute.getMethodSignature());
+ assertEquals(DEFAULT_ATTRIBUTE_TYPE, attribute.getType());
+ assertEquals("It's a preferred attribute", attribute.getShortDescription());
+ assertEquals("Preferred attribute", attribute.getDisplayName());
+ assertTrue(attribute.isPreferred());
+ }
+
+ @Test
+ public void testResourceDependencies() throws Exception {
+ Template template = unmarshal(Template.class, TEMPLATE_PROLOG +
+ " <cdk:resource-dependencies>" +
+ " <cdk:resource-dependency name=\"jquery.js\" />" +
+ " <cdk:resource-dependency name=\"richfaces.css\" library=\"org.richfaces\" />" +
+ " <cdk:resource-dependency name=\"richfaces.js\" library=\"org.richfaces\" target=\"body\" /> " +
+ " </cdk:resource-dependencies> " +
+
+ TEMPLATE_MIDDLE + TEMPLATE_EPILOG);
+
+ CompositeInterface interfaceSection = template.getInterface();
+ assertNotNull(interfaceSection);
+
+ List<ResourceDependency> resourceDependencies = interfaceSection.getResourceDependencies();
+ assertNotNull(resourceDependencies);
+ assertEquals(3, resourceDependencies.size());
+
+ ResourceDependency resourceDependency;
+
+ resourceDependency = resourceDependencies.get(0);
+ assertNotNull(resourceDependency);
+ assertEquals("jquery.js", resourceDependency.getName());
+ assertNull(resourceDependency.getLibrary());
+ assertEquals("head", resourceDependency.getTarget());
+
+ resourceDependency = resourceDependencies.get(1);
+ assertNotNull(resourceDependency);
+ assertEquals("richfaces.css", resourceDependency.getName());
+ assertEquals("org.richfaces", resourceDependency.getLibrary());
+ assertEquals("head", resourceDependency.getTarget());
+
+ resourceDependency = resourceDependencies.get(2);
+ assertNotNull(resourceDependency);
+ assertEquals("richfaces.js", resourceDependency.getName());
+ assertEquals("org.richfaces", resourceDependency.getLibrary());
+ assertEquals("body", resourceDependency.getTarget());
+ }
+
}
+
+
15 years, 1 month
JBoss Rich Faces SVN: r15862 - root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2009-11-10 20:29:38 -0500 (Tue, 10 Nov 2009)
New Revision: 15862
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
Log:
Switch to new template parser.
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 2009-11-11 01:28:26 UTC (rev 15861)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2009-11-11 01:29:38 UTC (rev 15862)
@@ -21,8 +21,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.cdk.templatecompiler;
import java.io.File;
@@ -43,16 +41,16 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class RendererClassGenerator implements CdkWriter {
private CdkContext context;
/*
* (non-Javadoc)
- *
+ *
* @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
*/
@Override
@@ -62,7 +60,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see
* org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary
* )
@@ -72,20 +70,27 @@
for (RenderKit renderKit : library.getRenderKits()) {
for (Renderer renderer : renderKit.getRenderers()) {
Template template = renderer.getTemplate();
- // TODO - put real parameters.
- RendererClassVisitor visitor = new RendererClassVisitor(template.getInterface());
- template.getImplementation().visit(visitor);
- JavaClass javaClass = visitor.getRendererClass();
- String fullName = javaClass.getFullName();
- File outFile = context.createOutputFile(StandardOutputs.RENDERER_CLASSES,
- fullName.replace('.', '/') + ".java", library.lastModified());
+ if (null != template) {
+ // TODO - put real parameters.
+ RendererClassVisitor visitor = new RendererClassVisitor(
+ template.getInterface());
+ template.getImplementation().visit(visitor);
+ JavaClass javaClass = visitor.getRendererClass();
+ String fullName = javaClass.getFullName();
+ File outFile = context.createOutputFile(
+ StandardOutputs.RENDERER_CLASSES, fullName.replace(
+ '.', '/')
+ + ".java", library.lastModified());
- if (null != outFile) {
- try {
- new JavaClassRenderer().render(javaClass, new PrintWriter(outFile));
- } catch (FileNotFoundException e) {
- throw new CdkException(e);
+ if (null != outFile) {
+ try {
+ new JavaClassRenderer().render(javaClass,
+ new PrintWriter(outFile));
+ } catch (FileNotFoundException e) {
+ throw new CdkException(e);
+ }
}
+
}
}
}
15 years, 1 month
JBoss Rich Faces SVN: r15861 - in root/cdk/trunk/plugins/generator/src/main/java/org/richfaces: cdk and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2009-11-10 20:28:26 -0500 (Tue, 10 Nov 2009)
New Revision: 15861
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererTemplateParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.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
Log:
Switch to new template parser.
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererClassGenerator.java 2009-11-10 18:04:00 UTC (rev 15860)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererClassGenerator.java 2009-11-11 01:28:26 UTC (rev 15861)
@@ -70,6 +70,7 @@
public void render(ComponentLibrary library) throws CdkException {
for (RenderKit renderKit : library.getRenderKits()) {
for (Renderer renderer : renderKit.getRenderers()) {
+ /* TODO - make model compatible with old parser ?
JavaClass javaClass = renderer.getTemplate();
String fullName = javaClass.getFullName();
File outFile = context.createOutputFile(StandardOutputs.RENDERER_CLASSES,
@@ -82,6 +83,7 @@
throw new CdkException(e);
}
}
+ */
}
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererTemplateParser.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererTemplateParser.java 2009-11-10 18:04:00 UTC (rev 15860)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererTemplateParser.java 2009-11-11 01:28:26 UTC (rev 15861)
@@ -58,9 +58,9 @@
RootElementConsumer template = TemplateReader.parseTemplate(new FileInputStream(file));
RenderKit renderKit = library.findOrCreateRenderKit(template.getRenderKitId());
Renderer renderer = renderKit.findOrCreateRenderer(template.getRendererType());
+ // TODO - make model compatible with that parser ?
+// renderer.setTemplate(template.getJavaClass());
- renderer.setTemplate(template.getJavaClass());
-
String componentType = template.getComponentType();
if (null != componentType) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2009-11-10 18:04:00 UTC (rev 15860)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2009-11-11 01:28:26 UTC (rev 15861)
@@ -27,8 +27,8 @@
import com.google.common.collect.ImmutableMap;
-import org.richfaces.builder.templates.RendererClassGenerator;
-import org.richfaces.builder.templates.RendererTemplateParser;
+import org.richfaces.cdk.templatecompiler.RendererClassGenerator;
+import org.richfaces.cdk.templatecompiler.RendererTemplateParser;
import org.richfaces.cdk.CdkContext.SourceType;
import org.richfaces.cdk.CdkWriter.OutputType;
import org.richfaces.cdk.apt.AptBuilder;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java 2009-11-10 18:04:00 UTC (rev 15860)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java 2009-11-11 01:28:26 UTC (rev 15861)
@@ -27,6 +27,7 @@
import org.richfaces.builder.model.JavaClass;
import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.templatecompiler.model.Template;
/**
* <p class="changed_added_4_0"></p>
@@ -37,7 +38,7 @@
public class Renderer extends ModelElementBase implements ModelElement<Renderer, Renderer.Type> {
private String family;
private ClassDescription rendererClass;
- private JavaClass template;
+ private Template template;
private Type type;
public Renderer() {}
@@ -71,7 +72,7 @@
* @return the template
*/
@Merge
- public JavaClass getTemplate() {
+ public Template getTemplate() {
return template;
}
@@ -79,7 +80,7 @@
* <p class="changed_added_4_0"></p>
* @param template the template to set
*/
- public void setTemplate(JavaClass template) {
+ public void setTemplate(Template template) {
this.template = template;
}
Added: 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 (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2009-11-11 01:28:26 UTC (rev 15861)
@@ -0,0 +1,93 @@
+/*
+ * $Id: RendererClassGenerator.java 15789 2009-11-01 16:17:29Z Alex.Kolonitsky $
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+
+package org.richfaces.cdk.templatecompiler;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
+
+import org.richfaces.builder.model.JavaClass;
+import org.richfaces.builder.render.JavaClassRenderer;
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.StandardOutputs;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.Renderer;
+import org.richfaces.cdk.model.RenderKit;
+import org.richfaces.cdk.templatecompiler.model.Template;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class RendererClassGenerator implements CdkWriter {
+ private CdkContext context;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary
+ * )
+ */
+ @Override
+ public void render(ComponentLibrary library) throws CdkException {
+ for (RenderKit renderKit : library.getRenderKits()) {
+ for (Renderer renderer : renderKit.getRenderers()) {
+ Template template = renderer.getTemplate();
+ // TODO - put real parameters.
+ RendererClassVisitor visitor = new RendererClassVisitor(template.getInterface());
+ template.getImplementation().visit(visitor);
+ JavaClass javaClass = visitor.getRendererClass();
+ String fullName = javaClass.getFullName();
+ File outFile = context.createOutputFile(StandardOutputs.RENDERER_CLASSES,
+ fullName.replace('.', '/') + ".java", library.lastModified());
+
+ if (null != outFile) {
+ try {
+ new JavaClassRenderer().render(javaClass, new PrintWriter(outFile));
+ } catch (FileNotFoundException e) {
+ throw new CdkException(e);
+ }
+ }
+ }
+ }
+ }
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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 2009-11-10 18:04:00 UTC (rev 15860)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2009-11-11 01:28:26 UTC (rev 15861)
@@ -56,7 +56,7 @@
Pattern.compile("^component\\.attributes\\[(?:'|\")?([^'\"]+)(?:'|\")?\\]$");
private static final Map<String, Set<String>> ELEMENTS_ATTRIBUTES;
private final LinkedList<MethodBodyStatement> statements = Lists.newLinkedList();
- private final JavaClass renderer;
+ private final JavaClass rendererClass;
private final CompositeInterface compositeInterface;
protected MethodBodyStatement currentStatement;
@@ -84,8 +84,15 @@
public RendererClassVisitor(CompositeInterface compositeInterface) {
this.compositeInterface = compositeInterface;
- renderer = new JavaClass();
+ rendererClass = new JavaClass();
}
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the rendererClass
+ */
+ public JavaClass getRendererClass() {
+ return this.rendererClass;
+ }
/* (non-Javadoc)
* @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor#endElement(org.richfaces.cdk.templatecompiler.model.AnyElement)
*/
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 2009-11-10 18:04:00 UTC (rev 15860)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2009-11-11 01:28:26 UTC (rev 15861)
@@ -30,6 +30,7 @@
import org.richfaces.cdk.ModelBuilder;
import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.model.*;
+import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
import org.richfaces.cdk.templatecompiler.model.Template;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
@@ -59,6 +60,25 @@
for (File file : getContext().getSources(StandardSources.RENDERER_TEMPLATES)) {
try {
Template template = parseTemplate(file);
+ CompositeInterface compositeInterface = template.getInterface();
+ // TODO - infer values ?
+ RenderKit renderKit = library.findOrCreateRenderKit(compositeInterface.getRenderKitId());
+ Renderer renderer = renderKit.findOrCreateRenderer(compositeInterface.getRendererType());
+ String componentType = compositeInterface.getComponentType();
+
+ if (null != componentType) {
+ Component component = library.findOrCreateComponent(componentType);
+
+ component.getRenderers().add(renderer);
+ }
+
+ String family = compositeInterface.getFamily();
+
+ if (null != family) {
+ renderer.setFamily(family);
+ }
+ renderer.setRendererClass(new ClassDescription(compositeInterface.getJavaClass()));
+ renderer.setTemplate(template);
// } catch (FileNotFoundException e) {
// throw new CdkException(e);
// } catch (XMLStreamException e) {
15 years, 1 month
JBoss Rich Faces SVN: r15860 - root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-11-10 13:04:00 -0500 (Tue, 10 Nov 2009)
New Revision: 15860
Added:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/faces-composite.xsd
Modified:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd
Log:
Latest updates for CDK schema check-in
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 2009-11-10 12:50:05 UTC (rev 15859)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd 2009-11-10 18:04:00 UTC (rev 15860)
@@ -4,11 +4,12 @@
elementFormDefault="qualified" attributeFormDefault="qualified"
xmlns:xhtml="http://richfaces.org/xhtml-el"
xmlns:javaee="http://java.sun.com/xml/ns/javaee"
- >
- <xs:import schemaLocation="web-facesuicomponent_2_0.xsd" namespace="http://java.sun.com/xml/ns/javaee"/><!--
- <xs:include schemaLocation="xhtml-el.xsd"/>
+ xmlns:cc="http://java.sun.com/jsf/composite">
+
+ <xs:import schemaLocation="web-facesuicomponent_2_0.xsd" namespace="http://java.sun.com/xml/ns/javaee"/>
+ <xs:import schemaLocation="faces-composite.xsd" namespace="http://java.sun.com/jsf/composite"/>
- --><xs:simpleType name="elStrictExpression">
+ <xs:simpleType name="elStrictExpression">
<xs:restriction base="xs:string">
<xs:pattern value="#\{[^\}]+\}" />
</xs:restriction>
@@ -33,16 +34,27 @@
</xs:attributeGroup>
<xs:element name="root">
- <xs:complexType mixed="true">
- <xs:choice>
- <xs:any minOccurs="0" maxOccurs="unbounded" />
- </xs:choice>
- <xs:attribute name="class" type="xs:string" form="unqualified" use="required" />
- <xs:attribute name="superclass" type="xs:string" form="unqualified"/>
- <xs:attribute name="componentclass" type="xs:string" form="unqualified" use="required" />
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="cc:interface" />
+ <xs:element ref="cc:implementation" />
+ </xs:sequence>
</xs:complexType>
</xs:element>
+ <xs:element name="metadata">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="class" type="javaee:fully-qualified-classType" default="javax.faces.render.Renderer" />
+ <xs:element minOccurs="0" name="base-class" type="javaee:fully-qualified-classType" />
+ <xs:element minOccurs="0" name="component-class" type="javaee:fully-qualified-classType" default="javax.faces.component.UIComponent" />
+ <xs:element minOccurs="0" name="render-kit-id" />
+ <xs:element minOccurs="0" name="component-family" />
+ <xs:element minOccurs="0" name="renderer-type" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
<xs:group name="structural">
<xs:choice>
<xs:element name="body">
Added: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/faces-composite.xsd
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/faces-composite.xsd (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/faces-composite.xsd 2009-11-10 18:04:00 UTC (rev 15860)
@@ -0,0 +1,249 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+
+<xs:schema targetNamespace="http://java.sun.com/jsf/composite"
+ xmlns:cc="http://java.sun.com/jsf/composite" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:xml="http://www.w3.org/XML/1998/namespace" elementFormDefault="qualified"
+ attributeFormDefault="unqualified">
+
+ <xs:attributeGroup name="beanDescriptorAttributes">
+ <xs:attribute name="displayName">
+ <xs:annotation>
+ <xs:documentation>
+ The name to display in a tool palette containing
+ this component. The
+ value of this attribute will be set as the value
+ for this property
+ on the composite component bean descriptor.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="preferred" type="xs:boolean">
+ <xs:annotation>
+ <xs:documentation>Is this a "preferred" component. The value of this
+ attribute will be set as the value for this property on the
+ composite component bean descriptor.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="expert" type="xs:boolean">
+ <xs:annotation>
+ <xs:documentation>Is this component only for expert users? The value
+ of this attribute will be set as the value for this property on the
+ composite component bean descriptor.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="shortDescription">
+ <xs:annotation>
+ <xs:documentation>
+ A short description of the purpose of this
+ component. The value of
+ this attribute will be set as the value for
+ this property on the
+ composite component bean descriptor.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </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:any processContents="lax" namespace="##other" />
+ </xs:choice>
+ </xs:sequence>
+ <xs:attribute name="name" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ The name of the attribute as it must appear on the
+ composite component
+ tag in the using page. If the value of the name
+ attribute is equal
+ to (without the quotes) "action",
+ "actionListener", "validator", or
+ "valueChangeListener", the action
+ described in
+ ViewHandler.retargetMethodExpressions() must be taken
+ to handle the
+ attribute. In these cases, the method-sigature
+ attribute, if
+ present, must be ignored as its value is derived as
+ described in
+ retargetMethodExpressions().
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="targets" use="required">
+ <xs:annotation>
+ <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)
+ 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>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="default">
+ <xs:annotation>
+ <xs:documentation>
+ 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:annotation>
+ </xs:attribute>
+ <xs:attribute name="required" type="xs:boolean">
+ <xs:annotation>
+ <xs:documentation>
+ True if the page author must supply a value for
+ this attribute.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="method-signature">
+ <xs:annotation>
+ <xs:documentation>
+ Declares that this attribute must be a
+ MethodExpression whose method
+ signature is described by the value of
+ this attribute. The
+ signature must be described using fully
+ qualified class names
+ wherever a type is required. This attribute is
+ mutually exclusive
+ with the "type" attribute. If both attributes are
+ present, the
+ "method-signature" attribute is ignored.
+
+ PENDING: when
+ this file is generated from the web-facesuicomponent_2_0.xsd,
+ we
+ will not need to copy the content here manually.
+
+ Provides the
+ signature of the Java method. The syntax of the
+ method-signature
+ element is as follows (taken from
+ function-signature in
+ web-jsptaglibrary_2_1.xsd):
+
+ MethodSignature ::= ReturnType S
+ MethodName S? '(' S? Parameters? S? ')'
+
+ ReturnType ::= Type
+
+ MethodName ::= Identifier
+
+ Parameters ::= Parameter | ( Parameter S?
+ ',' S? Parameters )
+
+ Parameter ::= Type
+
+ Where:
+
+ Type is a basic type or
+ a fully qualified Java class name (including
+ package name), as per
+ the 'Type' production in the Java Language
+ Specification, Second
+ Edition, Chapter 18.
+
+ Identifier is a Java identifier, as per the
+ 'Identifier' production in the
+ Java Language Specification, Second
+ Edition, Chapter 18.
+
+ Example:
+
+ java.lang.String nickName(
+ java.lang.String, int )
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="type">
+ <xs:annotation>
+ <xs:documentation>
+ <xs:annotation name="type">
+ </xs:annotation>
+ Declares that this attribute must be a ValueExpression whose
+ expected type
+ is given by the value of this attribute. If not
+ specified, and no
+ "method-signature" attribute is present,
+ java.lang.Object is
+ assumed. This attribute is mutually exclusive
+ with the "type"
+ attribute. If both attributes are present, the
+ "method-signature"
+ attribute is ignored.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attributeGroup ref="cc:beanDescriptorAttributes" />
+ </xs:complexType>
+
+ <xs:complexType name="compositeExtensionType">
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:any processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="compositeInterfaceType">
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:choice>
+ <xs:element ref="cc:extension" />
+ <xs:element ref="cc:attribute" />
+ </xs:choice>
+ </xs:sequence>
+ <xs:attribute type="xs:string" name="name">
+ <xs:annotation>
+ <xs:documentation>
+ The name of this composite component. Advisory
+ only. The real name is
+ taken from the filename. The value of this
+ attribute will be set as
+ the value for this property on the
+ composite component bean
+ descriptor.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="componentType">
+ <xs:annotation>
+ <xs:documentation>
+ The component-type of the UIComponent that will
+ serve as the composite
+ component root for this composite component.
+ The declared
+ component-family for this component must be
+ javax.faces.NamingContainer.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attributeGroup ref="cc:beanDescriptorAttributes" />
+ </xs:complexType>
+
+ <xs:complexType name="compositeImplementationType"
+ mixed="true">
+ <xs:choice>
+ <xs:any minOccurs="0" maxOccurs="unbounded" processContents="lax" />
+ </xs:choice>
+ </xs:complexType>
+
+ <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:schema>
15 years, 1 month
JBoss Rich Faces SVN: r15859 - branches/sandbox/3.3.X_JSF2/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-11-10 07:50:05 -0500 (Tue, 10 Nov 2009)
New Revision: 15859
Modified:
branches/sandbox/3.3.X_JSF2/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
Log:
RF-8069 - extendedDataTable: using table menu in IE8 causes JS error
Modified: branches/sandbox/3.3.X_JSF2/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
===================================================================
--- branches/sandbox/3.3.X_JSF2/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2009-11-09 18:36:19 UTC (rev 15858)
+++ branches/sandbox/3.3.X_JSF2/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2009-11-10 12:50:05 UTC (rev 15859)
@@ -19,14 +19,14 @@
}
//layer.style.height = dims.height + "px";
} // if
-}
+};
RichFaces.Menu.removePx = function(e) {
if ((e+"").indexOf("px")!=-1)
return (e+"").substring(0,e.length-2);
else
return e;
-}
+};
RichFaces.Menu.Layers = {
listl: new Array(),
@@ -113,7 +113,7 @@
},
isVisible: function(layer) {
- return ($(layer).style.display != 'none');
+ return $(layer).style.display != 'none';
},
/**
@@ -121,11 +121,11 @@
* @param visibleFlag
*/
LMPopUpL: function(menuName, visibleFlag, event) {
- if (!this.loaded) {
+ var menu = $(menuName);
+ if (!this.loaded || !menu) {
return;
}
this.detectWidth();
- var menu = $(menuName);
var eventResult = true;
RichFaces.Menu.fitLayerToContent(menu);
@@ -1313,7 +1313,7 @@
var label = typeof element.getLabel == 'fuction' ? element.getLabel() : RichFaces.Menu.Utils.getLabel(element);
Element.removeClassName(label, 'rich-menu-item-label-selected');
-}
+};
RichFaces.Menu.Utils.itemMouseOver = function(event, element, parentClasses, itemClasses) {
@@ -1328,15 +1328,15 @@
var label = typeof element.getLabel == 'fuction' ? element.getLabel() : RichFaces.Menu.Utils.getLabel(element);
Element.addClassName(label, 'rich-menu-item-label-selected');
-}
+};
RichFaces.Menu.Utils.getIcon = function (element) {
return $(element.id + ':icon');
-}
+};
RichFaces.Menu.Utils.getLabel = function (element) {
return $(element.id + ':anchor');
-}
+};
RichFaces.Menu.Item = Class.create({
initialize: function(id, menu, options) {
@@ -1532,7 +1532,7 @@
if (menuItem) break;
}
return menuItem;
-}
+};
RichFaces.Menu.updateItem = function (event, element, attr) {
var menuItem = RichFaces.Menu.findMenuItem(element.id);
@@ -1546,7 +1546,7 @@
element.className = classes;
if (attr.onselect) attr.onselect(event);
}
-}
+};
RichFaces.Menu.submitForm = function (event, element, options) {
if (!options) {
@@ -1562,7 +1562,7 @@
params[element.id+':hidden'] = element.id;
Richfaces.jsFormSubmit(element.id, form.id, target, params);
return false;
-}
+};
RichFaces.Menu.groupMouseOut = function(event, element, menuGroupClass, menuGroupStyle) {
if (RichFaces.Menu.isWithin(event, element)) {
@@ -1571,7 +1571,8 @@
element.className = 'rich-menu-group rich-menu-group-enabled ' + (menuGroupClass ? menuGroupClass : '');
element.style.cssText = menuGroupStyle;
-}
+};
+
RichFaces.Menu.groupMouseOver = function(event, element, menuGroupHoverClass, menuGroupStyle) {
if (RichFaces.Menu.isWithin(event, element)) {
return;
@@ -1579,5 +1580,5 @@
element.className = 'rich-menu-group rich-menu-group-enabled ' + (menuGroupHoverClass ? menuGroupHoverClass : '');
element.style.cssText = menuGroupStyle;
-}
+};
15 years, 1 month
JBoss Rich Faces SVN: r15858 - in branches/sandbox/3.3.X_JSF2/samples/dropdownmenu-sample/src/main/webapp: pages and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-11-09 13:36:19 -0500 (Mon, 09 Nov 2009)
New Revision: 15858
Added:
branches/sandbox/3.3.X_JSF2/samples/dropdownmenu-sample/src/main/webapp/images/home.png
branches/sandbox/3.3.X_JSF2/samples/dropdownmenu-sample/src/main/webapp/pages/RF-7990.jsp
Log:
RF-7990 JS error when style attribute is set to rich:menuItem
Added: branches/sandbox/3.3.X_JSF2/samples/dropdownmenu-sample/src/main/webapp/images/home.png
===================================================================
(Binary files differ)
Property changes on: branches/sandbox/3.3.X_JSF2/samples/dropdownmenu-sample/src/main/webapp/images/home.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/sandbox/3.3.X_JSF2/samples/dropdownmenu-sample/src/main/webapp/pages/RF-7990.jsp
===================================================================
--- branches/sandbox/3.3.X_JSF2/samples/dropdownmenu-sample/src/main/webapp/pages/RF-7990.jsp (rev 0)
+++ branches/sandbox/3.3.X_JSF2/samples/dropdownmenu-sample/src/main/webapp/pages/RF-7990.jsp 2009-11-09 18:36:19 UTC (rev 15858)
@@ -0,0 +1,30 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib uri="http://labs.jboss.com/jbossrichfaces/ui/menu-components" prefix="mc" %>
+<%@ taglib uri="http://labs.jboss.com/jbossrichfaces/ui/toolBar" prefix="tb" %>
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+ <title>RF-7990 Test Page </title>
+</head>
+<body>
+<f:view>
+ <h:form id="f">
+ <tb:toolBar id="t">
+ <mc:menuItem
+ id="item"
+ submitMode="server"
+ action="internalIndex"
+ style="color: red;"
+ styleClass="first">
+ <h:graphicImage value="/images/home.png" styleClass="menuIcon"/>
+ <h:panelGroup styleClass="menuLabel">
+ <h:outputText value="Hello"/>
+ </h:panelGroup>
+ </mc:menuItem>
+ </tb:toolBar>
+ </h:form>
+</f:view>
+</body>
+</html>
\ No newline at end of file
15 years, 1 month
JBoss Rich Faces SVN: r15857 - in root: framework/trunk/api/src/main/java/org/richfaces and 12 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-11-09 13:21:57 -0500 (Mon, 09 Nov 2009)
New Revision: 15857
Added:
root/framework/trunk/api/src/main/java/org/richfaces/application/
root/framework/trunk/api/src/main/java/org/richfaces/application/ServiceTracker.java
root/framework/trunk/impl/src/main/java/org/richfaces/application/
root/framework/trunk/impl/src/main/java/org/richfaces/application/InitializationListener.java
root/framework/trunk/impl/src/main/resources/META-INF/initialization-listener.faces-config.xml
Removed:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/event/CacheInitializationListener.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/event/InitializationListener.java
root/framework/trunk/impl/src/main/resources/META-INF/cache.faces-config.xml
Modified:
root/framework/trunk/api/src/main/java/org/ajax4jsf/component/AjaxClientBehavior.java
root/framework/trunk/api/src/main/java/org/richfaces/skin/SkinFactory.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AJAXDataSerializer.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/util/ServicesUtils.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java
root/framework/trunk/impl/src/test/java/org/richfaces/skin/SkinTestCase.java
root/framework/trunk/impl/src/test/resources/javascript/4_0_0.html
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
Log:
https://jira.jboss.org/jira/browse/RF-7823
https://jira.jboss.org/jira/browse/RFPL-12
Modified: root/framework/trunk/api/src/main/java/org/ajax4jsf/component/AjaxClientBehavior.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/ajax4jsf/component/AjaxClientBehavior.java 2009-11-09 14:56:04 UTC (rev 15856)
+++ root/framework/trunk/api/src/main/java/org/ajax4jsf/component/AjaxClientBehavior.java 2009-11-09 18:21:57 UTC (rev 15857)
@@ -57,4 +57,8 @@
public String getOnbeforedomupdate();
public void setOnbeforedomupdate(String onbeforedomupdate);
+
+ public Object getData();
+
+ public void setData(Object data);
}
Added: root/framework/trunk/api/src/main/java/org/richfaces/application/ServiceTracker.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/application/ServiceTracker.java (rev 0)
+++ root/framework/trunk/api/src/main/java/org/richfaces/application/ServiceTracker.java 2009-11-09 18:21:57 UTC (rev 15857)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.
+ */
+package org.richfaces.application;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * <p>Tracker class to provide access to various framework implementation services.
+ * Examples of such services are: {@link SkinFactory}, TBD</p>
+ *
+ * <p><b>Note:</b> this class is not synchronized and presumes that all modification operations
+ * should be done in a single-thread (e.g. in initialization listener)</p>
+ *
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+public final class ServiceTracker {
+
+ private static final String SERVICES_MAP_ATTRIBUTE = ServiceTracker.class.getName();
+
+ private ServiceTracker() {
+ //utility class private constructor
+ }
+
+ public static Collection<Class<?>> getRegisteredServiceClasses(FacesContext context) {
+ Map<Class<?>, Object> servicesMap = getServicesMap(context, false);
+ if (servicesMap != null) {
+ return Collections.unmodifiableCollection(servicesMap.keySet());
+ } else {
+ return Collections.emptySet();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T> T getService(FacesContext context, Class<T> serviceInterfaceClass) {
+ if (context == null) {
+ throw new NullPointerException("context");
+ }
+
+ if (serviceInterfaceClass == null) {
+ throw new NullPointerException("serviceInterfaceClass");
+ }
+
+ T serviceImplementation = null;
+
+ Map<Class<?>, Object> servicesMap = getServicesMap(context, false);
+ if (servicesMap != null) {
+ serviceImplementation = (T) servicesMap.get(serviceInterfaceClass);
+ }
+
+ //TODO - null?
+ return serviceImplementation;
+ }
+
+ public static <T> void setService(FacesContext context,
+ Class<T> serviceInterfaceClass,
+ T serviceImplementation) {
+
+ if (context == null) {
+ throw new NullPointerException("context");
+ }
+
+ if (serviceInterfaceClass == null) {
+ throw new NullPointerException("serviceInterfaceClass");
+ }
+
+ if (serviceImplementation == null) {
+ throw new NullPointerException("serviceImplementation");
+ }
+
+ Map<Class<?>, Object> servicesMap = getServicesMap(context, true);
+ servicesMap.put(serviceInterfaceClass, serviceImplementation);
+ }
+
+ public static void release(FacesContext context) {
+ clearServicesMap(context);
+ }
+
+ private static Map<Class<?>, Object> getServicesMap(FacesContext facesContext, boolean createIfNull) {
+ Map<String, Object> applicationMap = facesContext.getExternalContext().getApplicationMap();
+ @SuppressWarnings("unchecked")
+ Map<Class<?>, Object> servicesMap = (Map<Class<?>, Object>) applicationMap.get(SERVICES_MAP_ATTRIBUTE);
+ if (servicesMap == null && createIfNull) {
+ servicesMap = new HashMap<Class<?>, Object>();
+ applicationMap.put(SERVICES_MAP_ATTRIBUTE, servicesMap);
+ }
+
+ return servicesMap;
+ }
+
+ private static void clearServicesMap(FacesContext facesContext) {
+ Map<String, Object> applicationMap = facesContext.getExternalContext().getApplicationMap();
+ applicationMap.remove(SERVICES_MAP_ATTRIBUTE);
+ }
+}
Modified: root/framework/trunk/api/src/main/java/org/richfaces/skin/SkinFactory.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/skin/SkinFactory.java 2009-11-09 14:56:04 UTC (rev 15856)
+++ root/framework/trunk/api/src/main/java/org/richfaces/skin/SkinFactory.java 2009-11-09 18:21:57 UTC (rev 15857)
@@ -23,28 +23,10 @@
package org.richfaces.skin;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.FacesException;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.util.URLToStreamHelper;
+import org.richfaces.application.ServiceTracker;
-import org.richfaces.log.RichfacesLogger;
-
-import org.slf4j.Logger;
-
/**
* Base factory class ( implement Singleton design pattern ). Produce self
* instance to build current skin configuration. At present, realised as lazy
@@ -55,12 +37,8 @@
*
*/
public abstract class SkinFactory {
- public static final String BASE_SKIN_PARAMETER = "org.richfaces.BASE_SKIN";
- /**
- * Full class name of default implementation of the SkinFactory class
- */
- public static final String DEFAULT_SKIN_FACTORY_IMPL_CLASS = "org.richfaces.skin.SkinFactoryImpl";
+ public static final String BASE_SKIN_PARAMETER = "org.richfaces.BASE_SKIN";
/**
* Name of web application init parameter for current skin . Can be simple
@@ -72,24 +50,6 @@
public static final String SKIN_PARAMETER = "org.richfaces.SKIN";
/**
- * Resource Uri for file with name of class for application-wide SkinFactory same as SPI definitions for
- * common Java SAX, Jsf etc. factories
- */
- public static final String SERVICE_RESOURCE = "META-INF/services/" + SkinFactory.class.getName();
-
- /**
- * static instance variable.
- */
- private static Map<ClassLoader, SkinFactory> instances = Collections.synchronizedMap(new HashMap<ClassLoader,
- SkinFactory>());
- private static final Logger LOG = RichfacesLogger.APPLICATION.getLogger();
-
-// public abstract SkinConfiguration getSkinConfiguration(FacesContext context);
- public static void reset() {
- instances = Collections.synchronizedMap(new HashMap<ClassLoader, SkinFactory>());
- }
-
- /**
* Initialize skin factory. TODO - make call from init() method of any
* servlet or custom faces element method ??? If exist resource
* META-INF/services/org.richfaces.skin.SkinFactory , create
@@ -99,102 +59,10 @@
* instantiate custom factory, return default.
*/
public static final SkinFactory getInstance() {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- SkinFactory instance = (SkinFactory) instances.get(loader);
-
- if (instance == null) {
-
- // Pluggable factories.
- InputStream input = null; // loader.getResourceAsStream(SERVICE_RESOURCE);
-
- input = URLToStreamHelper.urlToStreamSafe(loader.getResource(SERVICE_RESOURCE));
-
- // have services file.
- if (input != null) {
- try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(input));
- String factoryClassName = reader.readLine();
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(Messages.getMessage(Messages.SET_SKIN_FACTORY_INFO, factoryClassName));
- }
-
- instance = instantiateSkinFactory(factoryClassName, loader);
- } catch (Exception e) {
- LOG.warn(Messages.getMessage(Messages.CREATING_SKIN_FACTORY_ERROR), e);
- } finally {
- try {
- input.close();
- } catch (IOException e) {
-
- // can be ignored
- }
- }
- }
-
- if (instance == null) {
-
- // instantiate default implementation of SkinFactory - org.richfaces.skin.SkinFactoryImpl,
- // placed in the richfaces-impl.jar
- instance = instantiateSkinFactory(DEFAULT_SKIN_FACTORY_IMPL_CLASS, loader);
- }
-
- instances.put(loader, instance);
- }
-
- return instance;
+ return ServiceTracker.getService(FacesContext.getCurrentInstance(), SkinFactory.class);
}
/**
- * Create new instance of class with given name with the help of given <code>ClassLoader</code>.
- * Instantiated class should extend <code>SkinFactory</code> base class.
- * @param factoryClassName - class name of SkinFactory
- * @param classLoader - class loader
- * @return - instantiated <code>SkinFactory</code>
- * @throws FacesException - FacesException is thrown when instantiation fails;
- * causing exception is wrapped into <code>FacesException</code>
- */
- private static SkinFactory instantiateSkinFactory(String factoryClassName, ClassLoader classLoader)
- throws FacesException {
-
- SkinFactory instance = null;
-
- try {
- Class<?> clazz = Class.forName(factoryClassName, false, classLoader);
-
- try {
-
- // try construct factory chain.
- Constructor<?> factoryConstructor = clazz.getConstructor(new Class[] {SkinFactory.class});
-
- instance = (SkinFactory) factoryConstructor.newInstance(new Object[] {instance});
- } catch (NoSuchMethodException e) {
-
- // no chain constructor - attempt default.
- instance = (SkinFactory) clazz.newInstance();
- }
- } catch (InvocationTargetException ite) {
- LOG.error(Messages.getMessage(Messages.CREATING_SKIN_FACTORY_ERROR), ite);
-
- throw new FacesException("Exception when creating instance of [" + SkinFactory.class.getName() + "]", ite);
- } catch (InstantiationException ie) {
- LOG.error(Messages.getMessage(Messages.CREATING_SKIN_FACTORY_ERROR), ie);
-
- throw new FacesException("Exception when creating instance of [" + SkinFactory.class.getName() + "]", ie);
- } catch (IllegalAccessException iae) {
- LOG.error(Messages.getMessage(Messages.CREATING_SKIN_FACTORY_ERROR), iae);
-
- throw new FacesException("Exception when creating instance of [" + SkinFactory.class.getName() + "]", iae);
- } catch (ClassNotFoundException cnfe) {
- LOG.error(Messages.getMessage(Messages.CREATING_SKIN_FACTORY_ERROR), cnfe);
-
- throw new FacesException("Exception when creating instance of [" + SkinFactory.class.getName() + "]", cnfe);
- }
-
- return instance;
- }
-
- /**
* Get default {@link Skin} implementation.
*
* @param context
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/event/CacheInitializationListener.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/event/CacheInitializationListener.java 2009-11-09 14:56:04 UTC (rev 15856)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/event/CacheInitializationListener.java 2009-11-09 18:21:57 UTC (rev 15857)
@@ -1,26 +0,0 @@
-package org.ajax4jsf.event;
-
-import org.ajax4jsf.cache.CacheManager;
-
-import javax.faces.event.SystemEvent;
-
-/**
- * @author Anton Belevich
- *
- */
-public class CacheInitializationListener extends InitializationListener {
- @Override
- public void init(SystemEvent event) {
-
- // TODO read configuration ??
- }
-
- @Override
- public void destroy(SystemEvent event) {
- try {
- CacheManager.getInstance().destroy();
- } catch (Exception e) {
- LOG.error("Error during stop caches.", e);
- }
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/event/InitializationListener.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/event/InitializationListener.java 2009-11-09 14:56:04 UTC (rev 15856)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/event/InitializationListener.java 2009-11-09 18:21:57 UTC (rev 15857)
@@ -1,36 +0,0 @@
-package org.ajax4jsf.event;
-
-import org.richfaces.log.RichfacesLogger;
-
-import org.slf4j.Logger;
-
-import javax.faces.application.Application;
-import javax.faces.event.PostConstructApplicationEvent;
-import javax.faces.event.PreDestroyApplicationEvent;
-import javax.faces.event.SystemEvent;
-import javax.faces.event.SystemEventListener;
-
-/**
- * framework initialization listener
- * @author Anton Belevich
- *
- */
-public abstract class InitializationListener implements SystemEventListener {
- protected static final Logger LOG = RichfacesLogger.CACHE.getLogger();
-
- public boolean isListenerForSource(Object source) {
- return source instanceof Application;
- }
-
- public void processEvent(SystemEvent event) {
- if (event instanceof PostConstructApplicationEvent) {
- init(event);
- } else if (event instanceof PreDestroyApplicationEvent) {
- destroy(event);
- }
- }
-
- public abstract void init(SystemEvent event);
-
- public abstract void destroy(SystemEvent event);
-}
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AJAXDataSerializer.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AJAXDataSerializer.java 2009-11-09 14:56:04 UTC (rev 15856)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AJAXDataSerializer.java 2009-11-09 18:21:57 UTC (rev 15857)
@@ -30,17 +30,8 @@
*
*/
public class AJAXDataSerializer {
- public static final String SERVICE = AJAXDataSerializer.class.getName();
public String asString(Object data) {
- StringBuffer result = new StringBuffer();
-
- if (null != data) {
- result.append("<![CDATA[ ");
- result.append(ScriptUtils.toScript(data));
- result.append(" ]]>");
- }
-
- return result.toString();
+ return ScriptUtils.toScript(data);
}
}
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2009-11-09 14:56:04 UTC (rev 15856)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2009-11-09 18:21:57 UTC (rev 15857)
@@ -53,9 +53,8 @@
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
-import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.ajax4jsf.util.ServicesUtils;
+import org.richfaces.application.ServiceTracker;
import org.richfaces.log.RichfacesLogger;
import org.slf4j.Logger;
@@ -110,6 +109,8 @@
*/
public static final String ONCOMPLETE_ATTR_NAME = "oncomplete";
+ public static final String DATA_ATTR_NAME = "data";
+
/**
* Attribute for keep JavaScript function name for call after complete
* request.
@@ -781,7 +782,20 @@
return (String) component.getAttributes().get(ONBEGIN_ATTR_NAME);
}
+
+ /**
+ * @param component
+ * @return
+ * @since 4.0
+ */
+ public static Object getAjaxData(UIComponent component) {
+ if (component instanceof AjaxComponent) {
+ return ((AjaxComponent) component).getData();
+ }
+ return component.getAttributes().get(DATA_ATTR_NAME);
+ }
+
/**
* Calculate, must be component render only given areas, or all sended from
* server.
@@ -969,8 +983,7 @@
Map<String, Object> responseDataMap = ajaxContext.getResponseDataMap();
// Get data serializer instance
- AJAXDataSerializer serializer =
- (AJAXDataSerializer) ServicesUtils.getServiceInstance(AJAXDataSerializer.SERVICE);
+ AJAXDataSerializer serializer = ServiceTracker.getService(context, AJAXDataSerializer.class);
// Put data to JavaScript handlers, inside <span> elements.
for (Map.Entry<String, Object> entry : responseDataMap.entrySet()) {
@@ -1179,7 +1192,11 @@
if (responseData != null) {
startExtensionElementIfNecessary(writer, attributes, writingState);
writer.startElement(DATA_ELEMENT_NAME, component);
- writer.writeText(ScriptUtils.toScript(responseData), null);
+
+ //TODO - encode response data map
+ AJAXDataSerializer serializer = ServiceTracker.getService(facesContext, AJAXDataSerializer.class);
+ writer.writeText(serializer.asString(responseData), null);
+
writer.endElement(DATA_ELEMENT_NAME);
}
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/util/ServicesUtils.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/util/ServicesUtils.java 2009-11-09 14:56:04 UTC (rev 15856)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/util/ServicesUtils.java 2009-11-09 18:21:57 UTC (rev 15857)
@@ -43,6 +43,7 @@
* @author shura
*
*/
+@Deprecated
public final class ServicesUtils {
private static final Logger LOG = RichfacesLogger.APPLICATION.getLogger();
private static Map<String, Map<ClassLoader, Class<?>>> services = Collections.synchronizedMap(new HashMap<String,
Added: root/framework/trunk/impl/src/main/java/org/richfaces/application/InitializationListener.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/application/InitializationListener.java (rev 0)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/application/InitializationListener.java 2009-11-09 18:21:57 UTC (rev 15857)
@@ -0,0 +1,176 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.
+ */
+package org.richfaces.application;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.text.MessageFormat;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.PostConstructApplicationEvent;
+import javax.faces.event.PreDestroyApplicationEvent;
+import javax.faces.event.SystemEvent;
+import javax.faces.event.SystemEventListener;
+
+import org.ajax4jsf.cache.CacheManager;
+import org.ajax4jsf.renderkit.AJAXDataSerializer;
+import org.ajax4jsf.resource.util.URLToStreamHelper;
+import org.richfaces.log.RichfacesLogger;
+import org.richfaces.skin.SkinFactory;
+import org.richfaces.skin.SkinFactoryImpl;
+import org.slf4j.Logger;
+
+/**
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+public class InitializationListener implements SystemEventListener {
+
+ private static final String META_INF_SERVICES = "META-INF/services/";
+
+ private static final Logger LOG = RichfacesLogger.APPLICATION.getLogger();
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.SystemEventListener#isListenerForSource(java.lang.Object)
+ */
+ public boolean isListenerForSource(Object source) {
+ return true;
+ }
+
+ private static <T> T instantiate(Class<T> interfaceClass,
+ Class<? extends T> implementationClass,
+ Class<? extends T> defaultImplementationClass) {
+
+ Constructor<? extends T> constructor = null;
+ Object[] constructorArguments = null;
+
+ if (implementationClass != null) {
+ if (defaultImplementationClass != null && !defaultImplementationClass.equals(implementationClass)) {
+ try {
+ constructor = implementationClass.getConstructor(interfaceClass);
+ T defaultImplementation = instantiate(interfaceClass, defaultImplementationClass, null);
+ constructorArguments = new Object[]{defaultImplementation};
+ } catch (NoSuchMethodException e) {
+ /* ignore */
+ }
+ }
+
+ if (constructor == null) {
+ try {
+ constructor = implementationClass.getConstructor();
+ } catch (NoSuchMethodException e) {
+ throw new FacesException(MessageFormat.format("Class {0} has no public no-arg constructor", implementationClass.getName()), e);
+ }
+ }
+
+ } else {
+ try {
+ constructor = defaultImplementationClass.getConstructor();
+ } catch (NoSuchMethodException e) {
+ throw new FacesException(MessageFormat.format("Class {0} has no public no-arg constructor",
+ defaultImplementationClass.getName()), e);
+ }
+ }
+
+ try {
+ return constructor.newInstance(constructorArguments);
+ } catch (IllegalArgumentException e) {
+ throw new FacesException(MessageFormat.format("Cannot instantiate {0} class, error was: {1}", constructor.getDeclaringClass(), e.getMessage()), e);
+ } catch (InstantiationException e) {
+ throw new FacesException(MessageFormat.format("Cannot instantiate {0} class, error was: {1}", constructor.getDeclaringClass(), e.getMessage()), e);
+ } catch (IllegalAccessException e) {
+ throw new FacesException(MessageFormat.format("Cannot instantiate {0} class, error was: {1}", constructor.getDeclaringClass(), e.getMessage()), e);
+ } catch (InvocationTargetException e) {
+ Throwable cause = e.getCause();
+ if (cause == null) {
+ cause = e;
+ }
+ throw new FacesException(MessageFormat.format("Cannot instantiate {0} class, error was: {1}", constructor.getDeclaringClass(), cause.getMessage()), cause);
+ }
+ }
+
+ private static final <T> T createServiceInstance(Class<T> interfaceClass, Class<? extends T> defaultImplementationClass) {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ InputStream input = URLToStreamHelper.urlToStreamSafe(loader.getResource(META_INF_SERVICES + interfaceClass.getName()));
+
+ Class<? extends T> implementationClass = null;
+
+ // have services file.
+ if (input != null) {
+ try {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(input));
+ String factoryClassName = reader.readLine();
+
+ implementationClass = Class.forName(factoryClassName, false, loader).asSubclass(interfaceClass);
+ } catch (Exception e) {
+ LOG.warn(MessageFormat.format("Error loading class for {0} service: {1} ",
+ interfaceClass.getName(), e.getMessage()), e);
+ } finally {
+ try {
+ input.close();
+ } catch (IOException e) {
+ // can be ignored
+ }
+ }
+ }
+
+ return instantiate(interfaceClass, implementationClass, defaultImplementationClass);
+ }
+
+ protected void onStart() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ SkinFactory skinFactory = createServiceInstance(SkinFactory.class, SkinFactoryImpl.class);
+ ServiceTracker.setService(facesContext, SkinFactory.class, skinFactory);
+
+ AJAXDataSerializer dataSerializer = createServiceInstance(AJAXDataSerializer.class, AJAXDataSerializer.class);
+ ServiceTracker.setService(facesContext, AJAXDataSerializer.class, dataSerializer);
+ }
+
+ protected void onStop() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ ServiceTracker.release(facesContext);
+ CacheManager.getInstance().destroy();
+ }
+
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.SystemEventListener#processEvent(javax.faces.event.SystemEvent)
+ */
+ public void processEvent(SystemEvent event) throws AbortProcessingException {
+ if (event instanceof PostConstructApplicationEvent) {
+ onStart();
+ } else if (event instanceof PreDestroyApplicationEvent) {
+ onStop();
+ } else {
+ throw new IllegalArgumentException(MessageFormat.format("Event {0} is not supported!", event));
+ }
+ }
+
+}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2009-11-09 14:56:04 UTC (rev 15856)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2009-11-09 18:21:57 UTC (rev 15857)
@@ -47,6 +47,7 @@
import javax.faces.event.PhaseId;
import org.ajax4jsf.component.AjaxOutput;
+import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.richfaces.log.RichfacesLogger;
import org.slf4j.Logger;
@@ -288,6 +289,12 @@
if (!Boolean.TRUE.equals(renderAll) && !ids.contains(ALL)) {
addImplicitRenderIds(ids, callback.isLimitRender());
+
+ //TODO - review
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
+ ajaxContext.setOnbeforedomupdate(callback.getOnbeforedomupdate());
+ ajaxContext.setOncomplete(callback.getOncomplete());
+ ajaxContext.setResponseData(callback.getData());
}
} else {
//TODO - the same as for "execute"
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java 2009-11-09 14:56:04 UTC (rev 15856)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java 2009-11-09 18:21:57 UTC (rev 15857)
@@ -37,7 +37,13 @@
private boolean limitRender = false;
- RenderComponentCallback(String behaviorEvent) {
+ private String oncomplete;
+
+ private String onbeforedomupdate;
+
+ private Object data;
+
+ RenderComponentCallback(String behaviorEvent) {
super(behaviorEvent, null);
}
@@ -45,13 +51,32 @@
return limitRender;
}
- @Override
+ public String getOnbeforedomupdate() {
+ return onbeforedomupdate;
+ }
+
+ public String getOncomplete() {
+ return oncomplete;
+ }
+
+ public Object getData() {
+ return data;
+ }
+
+ @Override
protected void doVisit(FacesContext context, UIComponent target, AjaxClientBehavior behavior) {
super.doVisit(context, target, behavior);
+
limitRender = AjaxRendererUtils.isAjaxLimitRender(target);
-
+ onbeforedomupdate = AjaxRendererUtils.getAjaxOnBeforeDomUpdate(target);
+ oncomplete = AjaxRendererUtils.getAjaxOncomplete(target);
+ data = AjaxRendererUtils.getAjaxData(target);
+
if (behavior != null) {
limitRender = behavior.isLimitRender();
+ onbeforedomupdate = behavior.getOnbeforedomupdate();
+ oncomplete = behavior.getOncomplete();
+ data = behavior.getData();
}
}
@@ -64,4 +89,5 @@
protected Object getBehaviorAttributeValue(AjaxClientBehavior behavior) {
return behavior.getRender();
}
+
}
Deleted: root/framework/trunk/impl/src/main/resources/META-INF/cache.faces-config.xml
===================================================================
--- root/framework/trunk/impl/src/main/resources/META-INF/cache.faces-config.xml 2009-11-09 14:56:04 UTC (rev 15856)
+++ root/framework/trunk/impl/src/main/resources/META-INF/cache.faces-config.xml 2009-11-09 18:21:57 UTC (rev 15857)
@@ -1,14 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<faces-config xmlns="http://java.sun.com/xml/ns/javaee" version="2.0">
- <application>
- <system-event-listener>
- <system-event-listener-class>org.ajax4jsf.event.CacheInitializationListener</system-event-listener-class>
- <system-event-class>javax.faces.event.PreDestroyApplicationEvent</system-event-class>
- </system-event-listener>
- <system-event-listener>
- <system-event-listener-class>org.ajax4jsf.event.CacheInitializationListener</system-event-listener-class>
- <system-event-class>javax.faces.event.PostConstructApplicationEvent</system-event-class>
- </system-event-listener>
- </application>
-
-</faces-config>
\ No newline at end of file
Added: root/framework/trunk/impl/src/main/resources/META-INF/initialization-listener.faces-config.xml
===================================================================
--- root/framework/trunk/impl/src/main/resources/META-INF/initialization-listener.faces-config.xml (rev 0)
+++ root/framework/trunk/impl/src/main/resources/META-INF/initialization-listener.faces-config.xml 2009-11-09 18:21:57 UTC (rev 15857)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee" version="2.0">
+ <name>richfaces</name>
+ <application>
+ <system-event-listener>
+ <system-event-listener-class>org.richfaces.application.InitializationListener</system-event-listener-class>
+ <system-event-class>javax.faces.event.PreDestroyApplicationEvent</system-event-class>
+ </system-event-listener>
+ <system-event-listener>
+ <system-event-listener-class>org.richfaces.application.InitializationListener</system-event-listener-class>
+ <system-event-class>javax.faces.event.PostConstructApplicationEvent</system-event-class>
+ </system-event-listener>
+ </application>
+
+</faces-config>
\ No newline at end of file
Modified: root/framework/trunk/impl/src/test/java/org/richfaces/skin/SkinTestCase.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/skin/SkinTestCase.java 2009-11-09 14:56:04 UTC (rev 15856)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/skin/SkinTestCase.java 2009-11-09 18:21:57 UTC (rev 15857)
@@ -49,7 +49,6 @@
@Override
public void tearDown() throws Exception {
- SkinFactory.reset();
super.tearDown();
}
Modified: root/framework/trunk/impl/src/test/resources/javascript/4_0_0.html
===================================================================
--- root/framework/trunk/impl/src/test/resources/javascript/4_0_0.html 2009-11-09 14:56:04 UTC (rev 15856)
+++ root/framework/trunk/impl/src/test/resources/javascript/4_0_0.html 2009-11-09 18:21:57 UTC (rev 15857)
@@ -138,7 +138,7 @@
});
test("RichFaces.ajax test", function() {
- expect(3);
+ expect(7);
var ajaxSource = "source";
var ajaxEvent = "event";
var ajaxOptions = {parameters: {'param': 'value'}};
@@ -146,13 +146,11 @@
request : function(source, event, options) {
equals(source, ajaxSource);
equals(event, ajaxEvent);
- same(options, {
- 'execute': '@component',
- 'render': '@component',
- 'param': 'value',
- 'org.richfaces.ajax.component': 'source',
- 'source': 'source'
- });
+ equals(options['execute'], '@component');
+ equals(options['render'], '@component');
+ equals(options['param'], 'value');
+ equals(options['org.richfaces.ajax.component'], 'source');
+ equals(options['source'], 'source');
}
}
RichFaces.ajax(ajaxSource, ajaxEvent, ajaxOptions);
Modified: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2009-11-09 14:56:04 UTC (rev 15856)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2009-11-09 18:21:57 UTC (rev 15857)
@@ -6,6 +6,7 @@
import javax.el.ELContext;
import javax.el.ValueExpression;
+import javax.faces.component.UIComponentBase;
import javax.faces.component.behavior.FacesBehavior;
import javax.faces.context.FacesContext;
@@ -23,6 +24,7 @@
private String onbeforedomupdate;
private String onbegin;
private String oncomplete;
+ private Object data;
private String queueId;
private Set<String> render;
private String similarityGroupingId;
@@ -30,7 +32,7 @@
private static enum Attributes {
limitRender, queueId, status, render, execute, similarityGroupingId, oncomplete, onbegin, onbeforedomupdate,
- other;
+ other, data;
public static Attributes toAttribute(String name) {
try {
@@ -108,6 +110,27 @@
return this.oncomplete;
}
+ public void setData(Object data) {
+ this.data = data;
+ clearInitialState();
+ }
+
+ public Object getData() {
+ if (this.data != null) {
+ return this.data;
+ }
+
+ ValueExpression ve = getValueExpression(Attributes.data.toString());
+
+ if (ve != null) {
+ ELContext elContext = FacesContext.getCurrentInstance().getELContext();
+
+ return ve.getValue(elContext);
+ }
+
+ return this.data;
+ }
+
@Override
public void setRender(Collection<String> render) {
this.render = asSet(render);
@@ -288,6 +311,11 @@
break;
+ case data:
+ this.data = value != null ? value : null;
+
+ break;
+
default :
break;
}
@@ -312,7 +340,7 @@
values = new Object[] {superState};
}
} else {
- values = new Object[10];
+ values = new Object[11];
values[0] = superState;
values[1] = limitRender;
values[2] = execute;
@@ -323,6 +351,7 @@
values[7] = onbeforedomupdate;
values[8] = onbegin;
values[9] = oncomplete;
+ values[10] = UIComponentBase.saveAttachedState(context, data);
}
return values;
@@ -345,6 +374,7 @@
this.onbeforedomupdate = (String) values[7];
this.onbegin = (String) values[8];
this.oncomplete = (String) values[9];
+ this.data = UIComponentBase.restoreAttachedState(context, values[10]);
clearInitialState();
}
}
15 years, 1 month
JBoss Rich Faces SVN: r15856 - in branches/sandbox/3.3.X_JSF2: ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-11-09 09:56:04 -0500 (Mon, 09 Nov 2009)
New Revision: 15856
Added:
branches/sandbox/3.3.X_JSF2/samples/calendar-sample/src/main/webapp/pages/RF-8071.jsp
Modified:
branches/sandbox/3.3.X_JSF2/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
Log:
RF-8071 - Calendar: "NaN" is displayed for selected date
Added: branches/sandbox/3.3.X_JSF2/samples/calendar-sample/src/main/webapp/pages/RF-8071.jsp
===================================================================
--- branches/sandbox/3.3.X_JSF2/samples/calendar-sample/src/main/webapp/pages/RF-8071.jsp (rev 0)
+++ branches/sandbox/3.3.X_JSF2/samples/calendar-sample/src/main/webapp/pages/RF-8071.jsp 2009-11-09 14:56:04 UTC (rev 15856)
@@ -0,0 +1,21 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib uri="http://labs.jboss.com/jbossrichfaces/ui/calendar" prefix="rich" %>
+<html>
+<head>
+ <title>RF-8071 Calendar: "NaN" is displayed for selected date</title>
+</head>
+<body>
+<f:view>
+ <h:form id="f">
+ <rich:calendar
+ id="inputValidFrom"
+ datePattern="dd-MMM-yyyy"
+ showFooter="false"
+ required="true"
+ requiredMessage="msg.error_validFromNotEmpty"
+ enableManualInput="true" />
+ </h:form>
+</f:view>
+</body>
+</html>
\ No newline at end of file
Modified: branches/sandbox/3.3.X_JSF2/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
--- branches/sandbox/3.3.X_JSF2/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2009-11-09 13:36:23 UTC (rev 15855)
+++ branches/sandbox/3.3.X_JSF2/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2009-11-09 14:56:04 UTC (rev 15856)
@@ -288,10 +288,16 @@
return value;
};
-Richfaces.Calendar.getMonthByLabel = function (monthLabel, monthNames)
-{
- var i=0;
- while (i<monthNames.length) if (monthNames[i]==monthLabel) return i; else i++;
+Richfaces.Calendar.getMonthByLabel = function (monthLabel, monthNames) {
+ var i = 0;
+ while (i < monthNames.length) {
+ var toLowerMonthLabel = monthLabel.toLowerCase();
+ if (monthNames[i].toLowerCase() == toLowerMonthLabel) {
+ return i;
+ }
+
+ i++;
+ }
};
Object.extend(Event, {
@@ -351,22 +357,17 @@
var re = /([.*+?^<>=!:${}()[\]\/\\])/g;
var monthNamesStr
var monthNamesShortStr;
- if (!monthNames)
- {
+ if (!monthNames) {
monthNames = Richfaces.Calendar.getDefaultMonthNames();
monthNamesStr = monthNames.join('|');
- }
- else
- {
+ } else {
monthNamesStr = monthNames.join('|').replace(re, '\\$1');
}
- if (!monthNamesShort)
- {
+
+ if (!monthNamesShort) {
monthNamesShort = Richfaces.Calendar.getDefaultMonthNames(true);
monthNamesShortStr = monthNamesShort.join('|');
- }
- else
- {
+ } else {
monthNamesShortStr = monthNamesShort.join('|').replace(re, '\\$1');
}
15 years, 1 month
JBoss Rich Faces SVN: r15855 - root/examples-sandbox/trunk/components/tables/src/main/webapp.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-11-09 08:36:23 -0500 (Mon, 09 Nov 2009)
New Revision: 15855
Modified:
root/examples-sandbox/trunk/components/tables/src/main/webapp/home.xhtml
Log:
add footer facet
Modified: root/examples-sandbox/trunk/components/tables/src/main/webapp/home.xhtml
===================================================================
--- root/examples-sandbox/trunk/components/tables/src/main/webapp/home.xhtml 2009-11-09 13:20:18 UTC (rev 15854)
+++ root/examples-sandbox/trunk/components/tables/src/main/webapp/home.xhtml 2009-11-09 13:36:23 UTC (rev 15855)
@@ -50,6 +50,10 @@
</rich:colGroup>
</f:facet>
+ <f:facet name="footer">
+ <h:outputText value="SubTable Footer facet" />
+ </f:facet>
+
<rich:column id="column_company_name">
<h:outputText value="#{company.name}" />
</rich:column>
15 years, 1 month