You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2008/04/10 09:37:41 UTC
svn commit: r646669 [2/2] - in /myfaces/tobago/trunk:
core/src/main/java/org/apache/myfaces/tobago/event/
core/src/main/java/org/apache/myfaces/tobago/taglib/component/
core/src/main/java/org/apache/myfaces/tobago/taglib/decl/
core/src/test/java/org/ap...
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java?rev=646669&r1=646668&r2=646669&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java Thu Apr 10 00:37:25 2008
@@ -29,6 +29,8 @@
import org.apache.myfaces.tobago.apt.annotation.Tag;
import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
import org.apache.myfaces.tobago.apt.annotation.DynamicExpression;
+import org.apache.myfaces.tobago.apt.annotation.TagGeneration;
+import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
import org.apache.commons.io.IOUtils;
import java.io.InputStream;
@@ -54,6 +56,7 @@
import com.sun.mirror.declaration.InterfaceDeclaration;
import com.sun.mirror.declaration.TypeDeclaration;
import com.sun.mirror.declaration.MethodDeclaration;
+import com.sun.mirror.declaration.ClassDeclaration;
import com.sun.mirror.type.InterfaceType;
/*
@@ -64,6 +67,7 @@
private StringTemplateGroup rendererStringTemplateGroup;
private StringTemplateGroup tagStringTemplateGroup;
+ private StringTemplateGroup tagAbstractStringTemplateGroup;
private StringTemplateGroup componentStringTemplateGroup;
private Set<String> renderer = new HashSet<String>();
private Set<String> ignoredProperties;
@@ -86,6 +90,10 @@
stream = getClass().getClassLoader().getResourceAsStream("org/apache/myfaces/tobago/apt/tag" + jsfVersion + ".stg");
reader = new InputStreamReader(stream);
tagStringTemplateGroup = new StringTemplateGroup(reader);
+ stream = getClass().getClassLoader().getResourceAsStream("org/apache/myfaces/tobago/apt/tagAbstract" + jsfVersion + ".stg");
+ reader = new InputStreamReader(stream);
+ tagAbstractStringTemplateGroup = new StringTemplateGroup(reader);
+
stream = getClass().getClassLoader().getResourceAsStream("org/apache/myfaces/tobago/apt/component"
+ jsfVersion + ".stg");
reader = new InputStreamReader(stream);
@@ -104,6 +112,27 @@
createTagOrComponent(decl);
}
}
+ for (ClassDeclaration decl : getCollectedClassDeclarations()) {
+ if (decl.getAnnotation(Tag.class) != null && decl.getAnnotation(TagGeneration.class) != null) {
+ createTag(decl);
+ }
+ }
+ }
+
+ private void createTag(ClassDeclaration decl) {
+ List<PropertyInfo> properties = new ArrayList<PropertyInfo>();
+ addPropertiesForTagOnly(decl, properties);
+ Tag tag = decl.getAnnotation(Tag.class);
+ TagGeneration tagGeneration = decl.getAnnotation(TagGeneration.class);
+
+ TagInfo tagInfo = new TagInfo(tagGeneration.className());
+ tagInfo.setSuperClass(decl.getQualifiedName());
+ StringTemplate stringTemplate = tagAbstractStringTemplateGroup.getInstanceOf("tag");
+ stringTemplate.setAttribute("tagInfo", tagInfo);
+ tagInfo.getProperties().addAll(properties);
+ tagInfo.addImport("org.apache.commons.logging.Log");
+ tagInfo.addImport("org.apache.commons.logging.LogFactory");
+ writeFile(tagInfo, stringTemplate);
}
private void createTagOrComponent(InterfaceDeclaration decl) {
@@ -291,6 +320,14 @@
}
}
+ protected void addPropertiesForTagOnly(ClassDeclaration type, List<PropertyInfo> properties) {
+ for (MethodDeclaration decl : getCollectedMethodDeclarations()) {
+ if (decl.getDeclaringType().equals(type)) {
+ addPropertyForTagOnly(decl, properties);
+ }
+ }
+ }
+
protected void addProperties(InterfaceDeclaration type, List<PropertyInfo> properties) {
addProperties(type.getSuperinterfaces(), properties);
for (MethodDeclaration decl : getCollectedMethodDeclarations()) {
@@ -311,7 +348,7 @@
UIComponentTagAttribute uiComponentTagAttribute = decl.getAnnotation(UIComponentTagAttribute.class);
if (uiComponentTagAttribute != null) {
String simpleName = decl.getSimpleName();
- if (simpleName.startsWith("set")) {
+ if (simpleName.startsWith("set") || simpleName.startsWith("get")) {
String attributeStr = simpleName.substring(3, 4).toLowerCase(Locale.ENGLISH) + simpleName.substring(4);
if (ignoredProperties.contains(attributeStr)) {
return;
@@ -346,6 +383,22 @@
?uiComponentTagAttribute.defaultCode():null);
propertyInfo.setMethodSignature(uiComponentTagAttribute.methodSignature());
propertyInfo.setDeprecated(decl.getAnnotation(Deprecated.class) != null);
+ properties.add(propertyInfo);
+ }
+ }
+ }
+
+ protected void addPropertyForTagOnly(MethodDeclaration decl, List<PropertyInfo> properties) {
+ TagAttribute tagAttribute = decl.getAnnotation(TagAttribute.class);
+ if (tagAttribute != null) {
+ String simpleName = decl.getSimpleName();
+ if (simpleName.startsWith("set") || simpleName.startsWith("get")) {
+ String attributeStr = simpleName.substring(3, 4).toLowerCase(Locale.ENGLISH) + simpleName.substring(4);
+ if (tagAttribute.name().length() > 0) {
+ attributeStr = tagAttribute.name();
+ }
+ PropertyInfo propertyInfo = new PropertyInfo(attributeStr);
+ propertyInfo.setType(tagAttribute.type());
properties.add(propertyInfo);
}
}
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/TaglibAnnotationVisitor.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/TaglibAnnotationVisitor.java?rev=646669&r1=646668&r2=646669&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/TaglibAnnotationVisitor.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/TaglibAnnotationVisitor.java Thu Apr 10 00:37:25 2008
@@ -37,6 +37,7 @@
import org.apache.myfaces.tobago.apt.annotation.Facet;
import org.apache.myfaces.tobago.apt.annotation.ExtensionTag;
import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
+import org.apache.myfaces.tobago.apt.annotation.TagGeneration;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -176,6 +177,10 @@
checkDuplicates(annotationTag.name());
resetAttributeDuplicateList();
String className = decl.getQualifiedName();
+ TagGeneration tagGeneration = decl.getAnnotation(TagGeneration.class);
+ if (tagGeneration != null) {
+ className = tagGeneration.className();
+ }
Element tag = createTag(decl, annotationTag, className, document, false);
addAttributes(decl, tag, document);
parent.appendChild(tag);
@@ -407,41 +412,52 @@
TagAttribute tagAttribute = d.getAnnotation(TagAttribute.class);
if (tagAttribute != null) {
String simpleName = d.getSimpleName();
- if (simpleName.startsWith("set")) {
+ if (simpleName.startsWith("set") || simpleName.startsWith("get")) {
Element attribute = document.createElement("attribute");
String attributeStr = simpleName.substring(3, 4).toLowerCase(Locale.ENGLISH) + simpleName.substring(4);
+ if (tagAttribute.name().length() > 0) {
+ attributeStr = tagAttribute.name();
+ }
checkAttributeDuplicates(attributeStr);
addLeafTextElement(attributeStr, "name", attribute, document);
addLeafTextElement(Boolean.toString(tagAttribute.required()), "required", attribute, document);
UIComponentTagAttribute componentTagAttribute = d.getAnnotation(UIComponentTagAttribute.class);
- if (is12() && componentTagAttribute != null && !tagAttribute.rtexprvalue()) {
- if (componentTagAttribute.expression().isMethodExpression()) {
- Element deferredMethod = document.createElement("deferred-method");
- StringBuilder signature = new StringBuilder();
- signature.append(componentTagAttribute.methodReturnType());
- signature.append(" ");
- signature.append(attributeStr);
- signature.append("(");
- signature.append(StringUtils.join(componentTagAttribute.methodSignature(), ", "));
- signature.append(")");
- addLeafTextElement(signature.toString(), "method-signature", deferredMethod, document);
- attribute.appendChild(deferredMethod);
- } else if (componentTagAttribute.expression().isValueExpression()) {
- Element deferredValue = document.createElement("deferred-value");
- String type = "java.lang.Object";
- if (componentTagAttribute.expression().isValueExpression()) {
- if (componentTagAttribute.type().length == 1) {
+ if (is12() && !tagAttribute.rtexprvalue()) {
+ if (componentTagAttribute != null) {
+ if (componentTagAttribute.expression().isMethodExpression()) {
+ Element deferredMethod = document.createElement("deferred-method");
+ StringBuilder signature = new StringBuilder();
+ signature.append(componentTagAttribute.methodReturnType());
+ signature.append(" ");
+ signature.append(attributeStr);
+ signature.append("(");
+ signature.append(StringUtils.join(componentTagAttribute.methodSignature(), ", "));
+ signature.append(")");
+ addLeafTextElement(signature.toString(), "method-signature", deferredMethod, document);
+ attribute.appendChild(deferredMethod);
+ } else if (componentTagAttribute != null && componentTagAttribute.expression().isValueExpression()) {
+ Element deferredValue = document.createElement("deferred-value");
+ String type = "java.lang.Object";
+ if (componentTagAttribute.expression().isValueExpression()) {
+ if (componentTagAttribute.type().length == 1) {
+ type = componentTagAttribute.type()[0];
+ }
+ } else {
type = componentTagAttribute.type()[0];
}
- } else {
- type = componentTagAttribute.type()[0];
- }
- addLeafTextElement(type, "type", deferredValue, document);
+ addLeafTextElement(type, "type", deferredValue, document);
+ attribute.appendChild(deferredValue);
+ }
+ } else {
+ Element deferredValue = document.createElement("deferred-value");
+ addLeafTextElement(tagAttribute.type(), "type", deferredValue, document);
attribute.appendChild(deferredValue);
}
}
- addLeafTextElement(Boolean.toString(tagAttribute.rtexprvalue()), "rtexprvalue", attribute, document);
+ if (tagAttribute.rtexprvalue()) {
+ addLeafTextElement(Boolean.toString(tagAttribute.rtexprvalue()), "rtexprvalue", attribute, document);
+ }
addDescription(d, attribute, document, false);
tagElement.appendChild(attribute);
} else {
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/RendererInfo.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/RendererInfo.java?rev=646669&r1=646668&r2=646669&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/RendererInfo.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/RendererInfo.java Thu Apr 10 00:37:25 2008
@@ -20,6 +20,10 @@
public class RendererInfo extends ClassInfo {
private String rendererName;
+ public RendererInfo(String qualifiedName) {
+ super(qualifiedName);
+ }
+
public RendererInfo(String qualifiedName, String rendererName) {
super(qualifiedName);
this.rendererName = rendererName;
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/TagInfo.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/TagInfo.java?rev=646669&r1=646668&r2=646669&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/TagInfo.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/TagInfo.java Thu Apr 10 00:37:25 2008
@@ -31,6 +31,10 @@
super(qualifiedName, rendererName);
}
+ public TagInfo(String qualifiedName) {
+ super(qualifiedName);
+ }
+
public List<PropertyInfo> getProperties() {
return properties;
}
Added: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/tagAbstract1.1.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/tagAbstract1.1.stg?rev=646669&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/tagAbstract1.1.stg (added)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/tagAbstract1.1.stg Thu Apr 10 00:37:25 2008
@@ -0,0 +1,268 @@
+group tags;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+tag(tagInfo) ::= <<
+//------------------ GENERATED CODE BEGIN (do not modify!) --------------------
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package <tagInfo.packageName>;
+
+<tagInfo.imports:import(); separator="\n">
+
+public class <tagInfo.className> extends <tagInfo.superClassName> {
+ private static final Log LOG = LogFactory.getLog(<tagInfo.className>.class);
+ <tagInfo.properties:field(); separator="\n">
+
+ <tagInfo.properties:property(); separator="\n">
+
+ <if(tagInfo.properties)>
+ @Override
+ public void release() {
+ super.release();
+ <tagInfo.properties:release(); separator="\n">
+ }
+ <endif>
+}
+>>
+
+import() ::= <<
+import <it>;
+>>
+
+release() ::= <<
+<it.propertyName> = null;
+>>
+
+property() ::= <<
+public <it.type> get<it.upperCamelCaseName>Value() {
+ if (<it.propertyName> != null && javax.faces.webapp.UIComponentTag.isValueReference(<it.propertyName>)) {
+ return (<it.type>) javax.faces.context.FacesContext.getCurrentInstance().getApplication().createValueBinding(<it.propertyName>).getValue(javax.faces.context.FacesContext.getCurrentInstance());
+ }
+ return <it.propertyName>;
+}
+
+public boolean is<it.upperCamelCaseName>Literal() {
+ return !javax.faces.webapp.UIComponentTag.isValueReference(<it.propertyName>);
+}
+
+public boolean is<it.upperCamelCaseName>Set() {
+ return <it.propertyName> != null;
+}
+
+public void set<it.upperCamelCaseName>(<it.type> <it.propertyName>) {
+ this.<it.propertyName> = <it.propertyName>;
+}
+
+public Object get<it.upperCamelCaseName>AsBindingOrExpression() {
+ return javax.faces.context.FacesContext.getCurrentInstance().getApplication().createValueBinding(<it.propertyName>);
+}
+
+public String get<it.upperCamelCaseName>Expression() {
+ return <it.propertyName>;
+}
+>>
+
+field() ::= <<
+private <it.type> <it.propertyName>;
+>>
+
+ValueExpression() ::= <<
+if (<it.propertyName> != null && isValueReference(<it.propertyName>)) {
+ <createValueBinding(it)>
+}
+>>
+
+String() ::= <<
+<createStringProperty(it)>
+>>
+
+Severity() ::= <<
+if (<it.propertyName> != null) {
+ if (isValueReference(<it.propertyName>)) {
+ <createValueBinding(it)>
+ } else {
+ component.getAttributes().put("<it.name>", <it.propertyName>);
+ }
+}
+>>
+
+Object() ::= <<
+<createStringProperty(it)>
+>>
+
+Character() ::= <<
+if (<it.propertyName> != null) {
+ if (isValueReference(<it.propertyName>)) {
+ <createValueBinding(it)>
+ } else {
+ component.set<it.upperCamelCaseName>(<it.propertyName>.charAt(0));
+ }
+}
+>>
+
+Boolean() ::= <<
+if (<it.propertyName> != null) {
+ if (isValueReference(<it.propertyName>)) {
+ <createValueBinding(it)>
+ } else {
+ component.set<it.upperCamelCaseName>(Boolean.valueOf(<it.propertyName>));
+ }
+}
+>>
+
+Integer() ::= <<
+if (<it.propertyName> != null) {
+ if (isValueReference(<it.propertyName>)) {
+ <createValueBinding(it)>
+ } else {
+ <if(it.widthOrHeight)>
+ if (<it.propertyName>.endsWith("px")) {
+ <it.propertyName> = <it.propertyName>.substring(0, <it.propertyName>.length() - 2);
+ }
+ <endif>
+ component.set<it.upperCamelCaseName>(Integer.parseInt(<it.propertyName>));
+ }
+}
+>>
+
+OrderBy() ::= <<
+if (<it.propertyName> != null) {
+ if (isValueReference(<it.propertyName>)) {
+ <createValueBinding(it)>
+ } else {
+ component.set<it.upperCamelCaseName>(org.apache.myfaces.tobago.component.AbstractUIMessages.OrderBy.parse(<it.propertyName>));
+ }
+}
+>>
+
+StringArray() ::= <<
+if (<it.propertyName> != null) {
+ if (isValueReference(<it.propertyName>)) {
+ <createValueBinding(it)>
+ } else {
+ component.set<it.upperCamelCaseName>(splitList(<it.propertyName>));
+ }
+}
+>>
+
+TabChangeListener() ::= <<
+if (<it.propertyName> != null && isValueReference(<it.propertyName>)) {
+ <createMethodBinding(it)>
+ component.set<it.template>(methodBinding);
+}
+>>
+
+ActionListener() ::= <<
+if (<it.propertyName> != null && isValueReference(<it.propertyName>)) {
+ <createMethodBinding(it)>
+ component.set<it.template>(methodBinding);
+}
+>>
+
+ValueChangeListener() ::= <<
+if (<it.propertyName> != null && isValueReference(<it.propertyName>)) {
+ <createMethodBinding(it)>
+ component.set<it.template>(methodBinding);
+}
+>>
+
+StateChangeListener() ::= <<
+if (<it.propertyName> != null && isValueReference(<it.propertyName>)) {
+ <createMethodBinding(it)>
+ component.set<it.template>(methodBinding);
+}
+>>
+
+SortActionListener() ::= <<
+if (<it.propertyName> != null && isValueReference(<it.propertyName>)) {
+ <createMethodBinding(it)>
+ component.set<it.template>(methodBinding);
+}
+>>
+
+SuggestMethod() ::= <<
+if (<it.propertyName> != null && isValueReference(<it.propertyName>)) {
+ <createMethodBinding(it)>
+ component.set<it.template>(methodBinding);
+}
+>>
+
+Validator() ::= <<
+if (<it.propertyName> != null && isValueReference(<it.propertyName>)) {
+ <createMethodBinding(it)>
+ component.setValidator(methodBinding);
+}
+>>
+
+Action() ::= <<
+if (<it.propertyName> != null) {
+ if (isValueReference(<it.propertyName>)) {
+ <createMethodBinding(it)>
+ component.setAction(methodBinding);
+ } else {
+ component.setAction(new org.apache.myfaces.tobago.el.ConstantMethodBinding(<it.propertyName>));
+ }
+}
+>>
+
+Converter() ::= <<
+if (<it.propertyName> != null) {
+ if (isValueReference(<it.propertyName>)) {
+ <createValueBinding(it)>
+ } else {
+ component.setConverter(context.getApplication().createConverter(<it.propertyName>));
+ }
+}
+>>
+
+createMethodBinding(it) ::= <<
+javax.faces.el.MethodBinding methodBinding = application.createMethodBinding(<it.propertyName>,
+ new Class[] { <first(it.methodSignature):{ n | <n>.class }><rest(it.methodSignature):{ n | , <n>.class}>} );
+>>
+
+createStringProperty(it) ::= <<
+if (<it.propertyName> != null) {
+ if (isValueReference(<it.propertyName>)) {
+ <createValueBinding(it)>
+ } else {
+ component.set<it.upperCamelCaseName>(<it.propertyName>);
+ }
+}
+>>
+
+createValueBinding(it) ::= <<
+component.setValueBinding("<it.name>", application.createValueBinding(<it.propertyName>));
+>>
Added: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/tagAbstract1.2.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/tagAbstract1.2.stg?rev=646669&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/tagAbstract1.2.stg (added)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/tagAbstract1.2.stg Thu Apr 10 00:37:25 2008
@@ -0,0 +1,294 @@
+group tags;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+tag(tagInfo) ::= <<
+//------------------ GENERATED CODE BEGIN (do not modify!) --------------------
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package <tagInfo.packageName>;
+
+<tagInfo.imports:import(); separator="\n">
+
+public class <tagInfo.className> extends <tagInfo.superClassName> {
+ private static final Log LOG = LogFactory.getLog(<tagInfo.className>.class);
+ <tagInfo.properties:field(); separator="\n">
+
+ <if(tagInfo.properties)>
+ <tagInfo.properties:property(); separator="\n">
+
+ @Override
+ public void release() {
+ super.release();
+ <tagInfo.properties:release(); separator="\n">
+ }
+ <endif>
+}
+>>
+
+import() ::= <<
+import <it>;
+>>
+
+release() ::= <<
+<it.propertyName> = null;
+>>
+
+property() ::= <<
+<if(it.literalOnly)>
+public <it.type> get<it.upperCamelCaseName>() {
+ return <it.propertyName>;
+}
+
+public void set<it.upperCamelCaseName>(<it.type> <it.propertyName>) {
+ this.<it.propertyName> = <it.propertyName>;
+}
+<else>
+<if(it.methodExpressionRequired)>
+public javax.el.MethodExpression get<it.upperCamelCaseName>() {
+ return <it.propertyName>;
+}
+
+public void set<it.upperCamelCaseName>(javax.el.MethodExpression <it.propertyName>) {
+ this.<it.propertyName> = <it.propertyName>;
+}
+<else>
+public <it.type> get<it.upperCamelCaseName>Value() {
+ if (<it.propertyName> != null) {
+ return (<it.type>) <it.propertyName>.getValue(javax.faces.context.FacesContext.getCurrentInstance().getELContext());
+ }
+ return null;
+}
+
+public boolean is<it.upperCamelCaseName>Literal() {
+ return <it.propertyName>.isLiteralText();
+}
+
+public boolean is<it.upperCamelCaseName>Set() {
+ return <it.propertyName> != null;
+}
+
+public void set<it.upperCamelCaseName>(javax.el.ValueExpression <it.propertyName>) {
+ this.<it.propertyName> = <it.propertyName>;
+}
+
+public Object get<it.upperCamelCaseName>AsBindingOrExpression() {
+ return <it.propertyName>;
+}
+
+public String get<it.upperCamelCaseName>Expression() {
+ return <it.propertyName>.getExpressionString();
+}
+<endif>
+<endif>
+
+
+>>
+
+field() ::= <<
+<if(it.literalOnly)>
+private String <it.propertyName>;
+<else>
+ <if(it.methodExpressionRequired)>
+private javax.el.MethodExpression <it.propertyName>;
+ <else>
+private javax.el.ValueExpression <it.propertyName>;
+ <endif>
+<endif>
+>>
+
+ValueExpression() ::= <<
+if (<it.propertyName> != null) {
+ if (!<it.propertyName>.isLiteralText()) {
+ <createValueBinding(it)>
+ /*} else {
+ component.set<it.upperCamelCaseName>(<it.propertyName>.getExpressionString());*/
+ }
+}
+>>
+
+String() ::= <<
+<createStringProperty(it)>
+>>
+
+Severity() ::= <<
+if (<it.propertyName> != null) {
+ if (!<it.propertyName>.isLiteralText()) {
+ <createValueBinding(it)>
+ } else {
+ component.getAttributes().put("<it.name>", <it.propertyName>.getExpressionString());
+ }
+}
+>>
+
+Object() ::= <<
+<createStringProperty(it)>
+>>
+
+Character() ::= <<
+if (<it.propertyName> != null) {
+ if (!<it.propertyName>.isLiteralText()) {
+ <createValueBinding(it)>
+ } else {
+ component.set<it.upperCamelCaseName>(<it.propertyName>.getExpressionString().charAt(0));
+ }
+}
+>>
+
+Boolean() ::= <<
+if (<it.propertyName> != null) {
+ if (!<it.propertyName>.isLiteralText()) {
+ <createValueBinding(it)>
+ } else {
+ component.set<it.upperCamelCaseName>(Boolean.valueOf(<it.propertyName>.getExpressionString()));
+ }
+}
+>>
+
+Integer() ::= <<
+if (<it.propertyName> != null) {
+ if (!<it.propertyName>.isLiteralText()) {
+ <createValueBinding(it)>
+ } else {
+ <if(it.widthOrHeight)>
+ String <it.propertyName>Str = <it.propertyName>.getExpressionString();
+ if (<it.propertyName>Str.endsWith("px")) {
+ <it.propertyName>Str = <it.propertyName>Str.substring(0, <it.propertyName>Str.length() - 2);
+ }
+ component.set<it.upperCamelCaseName>(Integer.parseInt(<it.propertyName>Str));
+ <else>
+ component.set<it.upperCamelCaseName>(Integer.parseInt(<it.propertyName>.getExpressionString()));
+ <endif>
+ }
+}
+>>
+
+OrderBy() ::= <<
+if (<it.propertyName> != null) {
+ if (!<it.propertyName>.isLiteralText()) {
+ <createValueBinding(it)>
+ } else {
+ component.set<it.upperCamelCaseName>(org.apache.myfaces.tobago.component.AbstractUIMessages.OrderBy.parse(<it.propertyName>.getExpressionString()));
+ }
+}
+>>
+
+StringArray() ::= <<
+if (<it.propertyName> != null) {
+ if (!<it.propertyName>.isLiteralText()) {
+ <createValueBinding(it)>
+ } else {
+ component.set<it.upperCamelCaseName>(splitList(<it.propertyName>.getExpressionString()));
+ }
+}
+>>
+
+TabChangeListener() ::= <<
+if (<it.propertyName> != null) {
+ component.add<it.template>(new org.apache.myfaces.tobago.event.MethodExpressionTabChangeListener(<it.propertyName>));
+}
+>>
+
+ActionListener() ::= <<
+if (<it.propertyName> != null) {
+ component.add<it.template>(new javax.faces.event.MethodExpressionActionListener(<it.propertyName>));
+}
+>>
+
+ValueChangeListener() ::= <<
+if (<it.propertyName> != null) {
+ component.add<it.template>(new javax.faces.event.MethodExpressionValueChangeListener(<it.propertyName>));
+}
+>>
+
+StateChangeListener() ::= <<
+if (<it.propertyName> != null) {
+ component.add<it.template>(new org.apache.myfaces.tobago.event.MethodExpressionStateChangeListener(<it.propertyName>));
+}
+>>
+
+SortActionListener() ::= <<
+if (<it.propertyName> != null) {
+ component.set<it.template>Expression(<it.propertyName>);
+}
+>>
+
+SuggestMethod() ::= <<
+if (<it.propertyName> != null) {
+ component.set<it.template>Expression(<it.propertyName>);
+}
+>>
+
+Validator() ::= <<
+if (<it.propertyName> != null) {
+ component.addValidator(new javax.faces.validator.MethodExpressionValidator(<it.propertyName>));
+}
+>>
+
+Action() ::= <<
+if (<it.propertyName> != null) {
+ component.setActionExpression(<it.propertyName>);
+}
+>>
+
+Converter() ::= <<
+if (<it.propertyName> != null) {
+ if (!<it.propertyName>.isLiteralText()) {
+ <createValueBinding(it)>
+ } else {
+ component.setConverter(application.createConverter(<it.propertyName>.getExpressionString()));
+ }
+}
+>>
+
+createMethodBinding(it) ::= <<
+javax.faces.el.MethodBinding methodBinding = application.createMethodBinding(<it.propertyName>.getExpressionString(),
+ new Class[] { <first(it.methodSignature):{ n | <n>.class }><rest(it.methodSignature):{ n | , <n>.class}>} );
+>>
+
+createStringProperty(it) ::= <<
+if (<it.propertyName> != null) {
+ <if(it.literalOnly)>
+ component.set<it.upperCamelCaseName>(<it.propertyName>);
+ <else>
+ <createValueBinding(it)>
+ <endif>
+}
+
+>>
+
+createValueBinding(it) ::= <<
+component.setValueExpression("<it.name>", <it.propertyName>);
+>>