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 2011/04/05 21:21:16 UTC

svn commit: r1089165 - in /myfaces/tobago/trunk/tobago-tool: tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/ tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/ tobago-tool-apt/src/main/java/org/apache/myfaces/to...

Author: bommel
Date: Tue Apr  5 19:21:15 2011
New Revision: 1089165

URL: http://svn.apache.org/viewvc?rev=1089165&view=rev
Log:
(TOBAGO-988) Support for transient properties in UIComponent generation

Modified:
    myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/UIComponentTagAttribute.java
    myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java
    myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentInfo.java
    myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentPropertyInfo.java
    myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java
    myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg
    myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg
    myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component2.0.stg

Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/UIComponentTagAttribute.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/UIComponentTagAttribute.java?rev=1089165&r1=1089164&r2=1089165&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/UIComponentTagAttribute.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-annotation/src/main/java/org/apache/myfaces/tobago/apt/annotation/UIComponentTagAttribute.java Tue Apr  5 19:21:15 2011
@@ -62,7 +62,6 @@ public @interface UIComponentTagAttribut
    */
   boolean isReadOnly() default false;
 
-
-
+  boolean isTransient() default false;
 
 }

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=1089165&r1=1089164&r2=1089165&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 Tue Apr  5 19:21:15 2011
@@ -208,28 +208,17 @@ public class CreateComponentAnnotationVi
       }
       try {
         Class componentBaseClass = Class.forName(componentTag.uiComponentBaseClass());
-        int index = 0;
         for (PropertyInfo info : properties.values()) {
           String methodName
               = (info.getType().equals("java.lang.Boolean") ? "is" : "get") + info.getUpperCamelCaseName();
-          String possibleUnifiedElAlternative = "set" + info.getUpperCamelCaseName() + "Expression";
+
           try {
             Method method = componentBaseClass.getMethod(methodName);
             if (Modifier.isAbstract(method.getModifiers())) {
-              ComponentPropertyInfo property = addPropertyToComponent(componentInfo, info, index, false);
-              if (elMethods.contains(possibleUnifiedElAlternative)) {
-                addPropertyToComponent(componentInfo, info, index, true);
-                property.setElAlternativeAvailable(true);
-              }
-              index++;
+              addPropertyToComponent(componentInfo, info, elMethods, false);
             }
           } catch (NoSuchMethodException e) {
-            ComponentPropertyInfo property = addPropertyToComponent(componentInfo, info, index, false);
-            if (elMethods.contains(possibleUnifiedElAlternative)) {
-              addPropertyToComponent(componentInfo, info, index, true);
-              property.setElAlternativeAvailable(true);
-            }
-            index++;
+            addPropertyToComponent(componentInfo, info, elMethods, false);
           }
         }
         boolean found = false;
@@ -249,11 +238,9 @@ public class CreateComponentAnnotationVi
 
       } catch (ClassNotFoundException e) {
         Map<String, PropertyInfo> baseClassProperties = getBaseClassProperties(componentTag.uiComponentBaseClass());
-        int index = 0;
         for (PropertyInfo info : properties.values()) {
           if (!baseClassProperties.containsValue(info)) {
-            addPropertyToComponent(componentInfo, info, index, false);
-            index++;
+            addPropertyToComponent(componentInfo, info, elMethods, false);
           }
         }
       }
@@ -300,23 +287,29 @@ public class CreateComponentAnnotationVi
   }
 
   private ComponentPropertyInfo addPropertyToComponent(
-      ComponentInfo componentInfo, PropertyInfo info, int index, boolean methodExpression) {
-
+      ComponentInfo componentInfo, PropertyInfo info, List<String> elMethods, boolean methodExpression) {
     ComponentPropertyInfo componentPropertyInfo = (ComponentPropertyInfo) info.fill(new ComponentPropertyInfo());
-    componentPropertyInfo.setIndex(index);
-    if (methodExpression) {
-      componentPropertyInfo.setType("javax.el.MethodExpression");
-      componentPropertyInfo.setName(info.getName() + "Expression");
+    String possibleUnifiedElAlternative = "set" + info.getUpperCamelCaseName() + "Expression";
+    ComponentPropertyInfo elAlternative = null;
+    if (elMethods.contains(possibleUnifiedElAlternative) && !methodExpression) {
+      elAlternative = addPropertyToComponent(componentInfo, info, elMethods, true);
+      componentPropertyInfo.setElAlternativeAvailable(true);
     }
     componentInfo.addImport(componentPropertyInfo.getUnmodifiedType());
     componentInfo.addImport("javax.faces.context.FacesContext");
-    componentInfo.getProperties().add(componentPropertyInfo);
+
     if ("markup".equals(info.getName())) {
       componentInfo.addInterface("org.apache.myfaces.tobago.component.SupportsMarkup");
     }
     if ("requiredMessage".equals(info.getName())) {
       componentInfo.setMessages(true);
     }
+    if (methodExpression) {
+      componentPropertyInfo.setType("javax.el.MethodExpression");
+      componentPropertyInfo.setName(info.getName() + "Expression");
+    } else {
+      componentInfo.addPropertyInfo(componentPropertyInfo, elAlternative);
+    }
     return componentPropertyInfo;
   }
 
@@ -414,6 +407,7 @@ public class CreateComponentAnnotationVi
         propertyInfo.setMethodSignature(uiComponentTagAttribute.methodSignature());
         propertyInfo.setDeprecated(declaration.getAnnotation(Deprecated.class) != null);
         propertyInfo.setDescription(getDescription(declaration));
+        propertyInfo.setTransient(uiComponentTagAttribute.isTransient());
         if (properties.containsKey(name)) {
           getEnv().getMessager().printWarning("Redefinition of attribute '" + name + "'.");
         }

Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentInfo.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentInfo.java?rev=1089165&r1=1089164&r2=1089165&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentInfo.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentInfo.java Tue Apr  5 19:21:15 2011
@@ -17,15 +17,18 @@ package org.apache.myfaces.tobago.apt.ge
  * limitations under the License.
  */
 
-/*
- * Date: 13.03.2008
- * Time: 15:27:56
- */
+import java.util.ArrayList;
+import java.util.List;
+
 public class ComponentInfo extends TagInfo {
+  private List<PropertyInfo> nonTransientProperties = new ArrayList<PropertyInfo>();
+  private List<PropertyInfo> transientProperties = new ArrayList<PropertyInfo>();
   private boolean invokeOnComponent;
   private boolean messages;
   private String description;
   private boolean deprecated;
+  private int index = 0;
+  private int nonTransientIndex = 0;
 
   public ComponentInfo(String sourceClass, String qualifiedName, String rendererType) {
     super(sourceClass, qualifiedName, rendererType);
@@ -39,6 +42,51 @@ public class ComponentInfo extends TagIn
     this.invokeOnComponent = invokeOnComponent;
   }
 
+  public void addPropertyInfo(ComponentPropertyInfo propertyInfo, ComponentPropertyInfo elAlternative) {
+    getProperties().add(propertyInfo);
+    propertyInfo.setIndex(index);
+    if (elAlternative != null) {
+      getProperties().add(elAlternative);
+      elAlternative.setIndex(index);
+    }
+    index++;
+    if (!propertyInfo.isTransient()) {
+      nonTransientProperties.add(propertyInfo);
+      propertyInfo.setNonTransientIndex(nonTransientIndex);
+      if (elAlternative != null) {
+        nonTransientProperties.add(elAlternative);
+        elAlternative.setNonTransientIndex(nonTransientIndex);
+      }
+      nonTransientIndex++;
+    } else {
+      transientProperties.add(propertyInfo);
+    }
+  }
+
+  public List<PropertyInfo> getNonTransientProperties() {
+    return nonTransientProperties;
+  }
+
+  public List<PropertyInfo> getTransientProperties() {
+    return transientProperties;
+  }
+
+  public int getPropertiesSize() {
+    return index;
+  }
+
+  public int getPropertiesSizePlusOne() {
+    return index + 1;
+  }
+
+  public int getNonTransientPropertiesSize() {
+    return nonTransientIndex;
+  }
+
+  public int getNonTransientPropertiesSizePlusOne() {
+    return nonTransientIndex + 1;
+  }
+
   public boolean isMessages() {
     return messages;
   }

Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentPropertyInfo.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentPropertyInfo.java?rev=1089165&r1=1089164&r2=1089165&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentPropertyInfo.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentPropertyInfo.java Tue Apr  5 19:21:15 2011
@@ -20,6 +20,7 @@ package org.apache.myfaces.tobago.apt.ge
 public class ComponentPropertyInfo extends PropertyInfo {
   private int index;
   private boolean elAlternativeAvailable;
+  private int nonTransientIndex;
 
   public String getPropertyTemplate() {
     return getShortTypeProperty() + "Property";
@@ -41,6 +42,18 @@ public class ComponentPropertyInfo exten
     this.index = index;
   }
 
+  public int getNonTransientIndex() {
+    return nonTransientIndex;
+  }
+
+  public int getNonTransientIndexPlusOne() {
+    return nonTransientIndex + 1;
+  }
+
+  public void setNonTransientIndex(int index) {
+    this.nonTransientIndex = index;
+  }
+
   public int getIndexPlusOne() {
     return index + 1;
   }

Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java?rev=1089165&r1=1089164&r2=1089165&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java Tue Apr  5 19:21:15 2011
@@ -33,6 +33,7 @@ public class PropertyInfo {
   private boolean bodyContent;
   private boolean tagAttribute;
   private String description;
+  private boolean transientValue;
 
   public PropertyInfo() {
   }
@@ -210,6 +211,7 @@ public class PropertyInfo {
     info.setMethodExpressionRequired(methodExpressionRequired);
     info.setTagAttribute(tagAttribute);
     info.setDescription(description);
+    info.setTransient(transientValue);
     return info;
   }
 
@@ -238,4 +240,12 @@ public class PropertyInfo {
   public String getDescription() {
     return description;
   }
+
+  public boolean isTransient() {
+    return transientValue;
+  }
+
+  public void setTransient(boolean transientValue) {
+    this.transientValue = transientValue;
+  }
 }

Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg?rev=1089165&r1=1089164&r2=1089165&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg Tue Apr  5 19:21:15 2011
@@ -91,13 +91,14 @@ public class <componentInfo.className>
   public void restoreState(FacesContext context, Object componentState) {
     Object[] values = (Object[]) componentState;
     super.restoreState(context, values[0]);
-    <componentInfo.properties:{ p | <p:(p.propertyRestoreStateTemplate)()>}; separator="\n">
+    <componentInfo.nonTransientProperties:{ p | <p:(p.propertyRestoreStateTemplate)()>}; separator="\n">
   }
 
   public Object saveState(FacesContext context) {
-    Object[] values = new Object[<componentInfo.propertiesSizePlusOne>];
+    Object[] values = new Object[<componentInfo.nonTransientPropertiesSizePlusOne>];
     values[0] = super.saveState(context);
-    <componentInfo.properties:{ p | <p:(p.propertySaveStateTemplate)()>}; separator="\n">
+    <componentInfo.nonTransientProperties:{ p | <p:(p.propertySaveStateTemplate)()>}; separator="\n">
+    <componentInfo.transientProperties:{ p | <p:resetField()>}; separator="\n">
     return values;
   }
   <endif>
@@ -501,7 +502,7 @@ public <property.type> get<property.uppe
 }
 
 <checkDeprecated(property)>
-public void set<property.upperCamelCaseName>(Measure <property.propertyName>) {
+public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
   this.<property.propertyName> = <property.propertyName>;
 }
 >>
@@ -544,7 +545,12 @@ public <property.type> get<property.uppe
     Object object = <getValue(property)>
     return Markup.valueOf(object);
   }
+  <endif>
+  <if(property.defaultCode)>
+  return <property.defaultCode>;
+  <else>
   return null;
+  <endif>
 }
 
 <checkDeprecated(property)>
@@ -557,125 +563,129 @@ field() ::= <<
 private <it.internalType> <it.propertyName>;
 >>
 
+resetField() ::= <<
+<it.propertyName> = null;
+>>
+
 WizardSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 ObjectSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 IntegerSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 StringSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 StringArraySaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 booleanSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 BooleanSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 CharacterSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 SeveritySaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 MeasureSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 TextAlignSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 MarkupSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 DisplaySaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 OrderBySaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 MethodBindingSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = saveAttachedState(context, <it.propertyName>);
+values[<it.nonTransientIndexPlusOne>] = saveAttachedState(context, <it.propertyName>);
 >>
 
 
 WizardRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 ObjectRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 IntegerRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 StringRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 StringArrayRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 booleanRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.internalType>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.internalType>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 BooleanRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 CharacterRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 SeverityRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 MeasureRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 TextAlignRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 MarkupRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 DisplayRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 OrderByRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 MethodBindingRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) restoreAttachedState(context, values[<it.indexPlusOne>]);
+<it.propertyName> = (<it.type>) restoreAttachedState(context, values[<it.nonTransientIndexPlusOne>]);
 >>
 
 

Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg?rev=1089165&r1=1089164&r2=1089165&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg Tue Apr  5 19:21:15 2011
@@ -94,13 +94,14 @@ public class <componentInfo.className>
   public void restoreState(FacesContext context, Object componentState) {
     Object[] values = (Object[]) componentState;
     super.restoreState(context, values[0]);
-    <componentInfo.properties:{ p | <p:(p.propertyRestoreStateTemplate)()>}; separator="\n">
+    <componentInfo.nonTransientProperties:{ p | <p:(p.propertyRestoreStateTemplate)()>}; separator="\n">
   }
 
   public Object saveState(FacesContext context) {
-    Object[] values = new Object[<componentInfo.propertiesSizePlusOne>];
+    Object[] values = new Object[<componentInfo.nonTransientPropertiesSizePlusOne>];
     values[0] = super.saveState(context);
-    <componentInfo.properties:{ p | <p:(p.propertySaveStateTemplate)()>}; separator="\n">
+    <componentInfo.nonTransientProperties:{ p | <p:(p.propertySaveStateTemplate)()>}; separator="\n">
+    <componentInfo.transientProperties:{ p | <p:resetField()>}; separator="\n">
     return values;
   }
   <endif>
@@ -498,6 +499,7 @@ public <property.type> get<property.uppe
   if (<property.propertyName> != null) {
     return <property.propertyName>;
   }
+  <if(!property.transient)>
   <getValueExpression(property)>
   if (ve != null) {
     try {
@@ -507,7 +509,12 @@ public <property.type> get<property.uppe
 		  throw new FacesException(e);
 	  }
   }
+  <endif>
+  <if(property.defaultCode)>
+  return <property.defaultCode>;
+  <else>
   return null;
+  <endif>
 }
 
 <checkDeprecated(property)>
@@ -523,147 +530,153 @@ private <it.internalType> <it.propertyNa
 <endif>
 >>
 
+resetField() ::= <<
+<if(it.elAlternativeAvailable)>
+<else>
+<it.propertyName> = null;
+<endif>
+>>
+
 restoreStateField() ::= <<
 <it.propertyName> = (<it.type>) values[<i>];
 >>
 
 saveStateField() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 WizardSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 ObjectSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 IntegerSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 StringSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 StringArraySaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 booleanSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 BooleanSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 CharacterSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 SeveritySaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 MeasureSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 TextAlignSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 MarkupSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 DisplaySaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 OrderBySaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = <it.propertyName>;
+values[<it.nonTransientIndexPlusOne>] = <it.propertyName>;
 >>
 
 MethodBindingSaveStateProperty() ::= <<
 <if(it.elAlternativeAvailable)>
 <else>
-values[<it.indexPlusOne>] = saveAttachedState(context, <it.propertyName>);
+values[<it.nonTransientIndexPlusOne>] = saveAttachedState(context, <it.propertyName>);
 <endif>
 >>
 
 MethodExpressionSaveStateProperty() ::= <<
-values[<it.indexPlusOne>] = saveAttachedState(context, <it.propertyName>);
+values[<it.nonTransientIndexPlusOne>] = saveAttachedState(context, <it.propertyName>);
 >>
 
-
 WizardRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 ObjectRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 IntegerRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 StringRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 StringArrayRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 booleanRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.internalType>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.internalType>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 BooleanRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 CharacterRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 SeverityRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 MeasureRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 TextAlignRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 MarkupRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 DisplayRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 OrderByRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) values[<it.indexPlusOne>];
+<it.propertyName> = (<it.type>) values[<it.nonTransientIndexPlusOne>];
 >>
 
 MethodBindingRestoreStateProperty() ::= <<
 <if(it.elAlternativeAvailable)>
 <else>
-<it.propertyName> = (<it.type>) restoreAttachedState(context, values[<it.indexPlusOne>]);
+<it.propertyName> = (<it.type>) restoreAttachedState(context, values[<it.nonTransientIndexPlusOne>]);
 <endif>
 >>
 
 MethodExpressionRestoreStateProperty() ::= <<
-<it.propertyName> = (<it.type>) restoreAttachedState(context, values[<it.indexPlusOne>]);
+<it.propertyName> = (<it.type>) restoreAttachedState(context, values[<it.nonTransientIndexPlusOne>]);
 >>
 
 getValueExpression(property) ::= <<

Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component2.0.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component2.0.stg?rev=1089165&r1=1089164&r2=1089165&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component2.0.stg (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component2.0.stg Tue Apr  5 19:21:15 2011
@@ -80,10 +80,11 @@ public class <componentInfo.className>
   public static final String COMPONENT_FAMILY = "<componentInfo.componentFamily>";
 
   <endif>
+  <componentInfo.transientProperties:field(); separator="\n">
+
   <if(componentInfo.properties)>
-  enum PropertyKeys
-  {
-  <componentInfo.properties:field(); separator="\n">
+  enum PropertyKeys {
+    <componentInfo.nonTransientProperties:enumName(); separator="\n">
   }
   <endif>
 
@@ -95,6 +96,13 @@ public class <componentInfo.className>
   <endif>
   <componentInfo.properties:{ p | <p:(p.propertyTemplate)()>}; separator="\n">
 
+  <if(componentInfo.transientProperties)>
+  public Object saveState(FacesContext context) {
+    <componentInfo.transientProperties:{ p | <p:resetField()>}; separator="\n">
+    return super.saveState(context);
+  }
+  <endif>
+
   <if(componentInfo.invokeOnComponent)>
   <invokeOnComponent()>
   <endif>
@@ -152,10 +160,16 @@ IntegerProperty(property) ::= <<
 <createDescription(property)>
 <checkDeprecated(property)>
 public <property.type> get<property.upperCamelCaseName>() {
+  <if(property.transient)>
+  if (<property.propertyName> != null) {
+    return <property.propertyName>;
+  }
+  <else>
   Number value  = (Number) getStateHelper().eval(PropertyKeys.<property.propertyName>);
   if (value != null) {
     return value.intValue();
   }
+  <endif>
   <if(property.defaultCode)>
   return <property.defaultCode>;
   <else>
@@ -166,7 +180,11 @@ public <property.type> get<property.uppe
 <checkDeprecated(property)>
 public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
   <logDeprecated(property)>
+  <if(property.transient)>
+  this.<property.propertyName> = <property.propertyName>;
+  <else>
   getStateHelper().put(PropertyKeys.<property.propertyName>, <property.propertyName>);
+  <endif>
 }
 >>
 
@@ -175,13 +193,23 @@ ObjectProperty(property) ::= <<
 <createDescription(property)>
 <checkDeprecated(property)>
 public <property.type> get<property.upperCamelCaseName>() {
+  <if(property.transient)>
+  if (<property.propertyName> != null) {
+    return <property.propertyName>;
+  }
+  <else>
   return getStateHelper().eval(PropertyKeys.<property.propertyName>);
+  <endif>
 }
 
 <checkDeprecated(property)>
 public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
   <logDeprecated(property)>
+  <if(property.transient)>
+  this.<property.propertyName> = <property.propertyName>;
+  <else>
   getStateHelper().put(PropertyKeys.<property.propertyName>, <property.propertyName>);
+  <endif>
 }
 >>
 
@@ -224,10 +252,16 @@ booleanProperty(property) ::= <<
 <createDescription(property)>
 <checkDeprecated(property)>
 public boolean is<property.upperCamelCaseName>() {
+  <if(property.transient)>
+  if (<property.propertyName> != null) {
+    return <property.propertyName>;
+  }
+  <else>
   Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.<property.propertyName>);
   if (bool != null) {
     return bool;
   }
+  <endif>
   <if(property.defaultCode)>
   return <property.defaultCode>;
   <else>
@@ -238,7 +272,11 @@ public boolean is<property.upperCamelCas
 <checkDeprecated(property)>
 public void set<property.upperCamelCaseName>(boolean <property.propertyName>) {
   <logDeprecated(property)>
+  <if(property.transient)>
+  this.<property.propertyName> = <property.propertyName>;
+  <else>
   getStateHelper().put(PropertyKeys.<property.propertyName>, <property.propertyName>);
+  <endif>
 }
 >>
 
@@ -247,10 +285,16 @@ BooleanProperty(property) ::= <<
 <createDescription(property)>
 <checkDeprecated(property)>
 public Boolean get<property.upperCamelCaseName>() {
-   Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.<property.propertyName>);
-   if (bool != null) {
-     return bool;
-   }
+  <if(property.transient)>
+  if (<property.propertyName> != null) {
+    return <property.propertyName>;
+  }
+  <else>
+  Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.<property.propertyName>);
+  if (bool != null) {
+    return bool;
+  }
+  <endif>
   <if(property.defaultCode)>
   return <property.defaultCode>;
   <else>
@@ -261,7 +305,11 @@ public Boolean get<property.upperCamelCa
 <checkDeprecated(property)>
 public void set<property.upperCamelCaseName>(Boolean <property.propertyName>) {
   <logDeprecated(property)>
+  <if(property.transient)>
+  this.<property.propertyName> = <property.propertyName>;
+  <else>
   getStateHelper().put(PropertyKeys.<property.propertyName>, <property.propertyName>);
+  <endif>
 }
 >>
 
@@ -341,6 +389,12 @@ NormalProperty(property) ::= <<
 <createDescription(property)>
 <checkDeprecated(property)>
 public <property.type> get<property.upperCamelCaseName>() {
+  <logDeprecated(property)>
+  <if(property.transient)>
+  if (<property.propertyName> != null) {
+    return <property.propertyName>;
+  }
+  <else>
   <if(property.defaultCode)>
   <property.type> <property.propertyName> = (<property.type>) getStateHelper().eval(PropertyKeys.<property.propertyName>);
   if (<property.propertyName> != null) {
@@ -349,6 +403,7 @@ public <property.type> get<property.uppe
   <else>
   return (<property.type>) getStateHelper().eval(PropertyKeys.<property.propertyName>);
   <endif>
+  <endif>
   <if(property.defaultCode)>
   return <property.defaultCode>;
   <endif>
@@ -356,7 +411,10 @@ public <property.type> get<property.uppe
 
 <checkDeprecated(property)>
 public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
+  <if(property.transient)>
+  <else>
   getStateHelper().put(PropertyKeys.<property.propertyName>, <property.propertyName>);
+  <endif>
 }
 >>
 
@@ -365,10 +423,16 @@ MeasureProperty(property) ::= <<
 <createDescription(property)>
 <checkDeprecated(property)>
 public <property.type> get<property.upperCamelCaseName>() {
+  <if(property.transient)>
+  if (<property.propertyName> != null) {
+    return <property.propertyName>;
+  }
+  <else>
   Object object = getStateHelper().eval(PropertyKeys.<property.propertyName>);
   if (object != null) {
      return Measure.valueOf(object);
   }
+  <endif>
   <if(property.defaultCode)>
   return <property.defaultCode>;
   <else>
@@ -378,7 +442,12 @@ public <property.type> get<property.uppe
 
 <checkDeprecated(property)>
 public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
+  <logDeprecated(property)>
+  <if(property.transient)>
+  this.<property.propertyName> = <property.propertyName>;
+  <else>
   getStateHelper().put(PropertyKeys.<property.propertyName>, <property.propertyName>);
+  <endif>
 }
 >>
 
@@ -398,6 +467,7 @@ public <property.type> get<property.uppe
 
 <checkDeprecated(property)>
 public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
+  <logDeprecated(property)>
   getStateHelper().put(PropertyKeys.<property.propertyName>, <property.propertyName>);
 }
 >>
@@ -406,22 +476,47 @@ MarkupProperty(property) ::= <<
 
 <checkDeprecated(property)>
 public <property.type> get<property.upperCamelCaseName>() {
+  <if(property.transient)>
+  if (<property.propertyName> != null) {
+    return <property.propertyName>;
+  }
+  <else>
   Object object = getStateHelper().eval(PropertyKeys.<property.propertyName>);
   if (object != null) {
     return Markup.valueOf(object);
   }
+  <endif>
   return null;
 }
 
 <checkDeprecated(property)>
 public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
+  <logDeprecated(property)>
+  <if(property.transient)>
+  this.<property.propertyName> = <property.propertyName>;
+  <else>
   getStateHelper().put(PropertyKeys.<property.propertyName>, <property.propertyName>);
+  <endif>
 }
 >>
 
-field() ::= <<
+enumName() ::= <<
 <if(it.elAlternativeAvailable)>
 <else>
 <it.propertyName>,
 <endif>
 >>
+
+field() ::= <<
+<if(it.elAlternativeAvailable)>
+<else>
+private <it.internalType> <it.propertyName>;
+<endif>
+>>
+
+resetField() ::= <<
+<if(it.elAlternativeAvailable)>
+<else>
+<it.propertyName> = null;
+<endif>
+>>