tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-tapestry/framework/src/java/org/apache/tapestry/parse Tapestry_3_1.dtd
Date Wed, 03 Nov 2004 13:53:43 GMT
hlship      2004/11/03 05:53:43

  Modified:    src/documentation/content/xdocs/UsersGuide spec.xml
                        state.xml
               framework/src/java/org/apache/tapestry/enhance
                        SpecifiedPropertyWorker.java
               framework/src/test/org/apache/tapestry/enhance
                        TestSpecifiedPropertyWorker.java
               framework/src/java/org/apache/tapestry/spec
                        PropertySpecification.java
               framework/src/test/org/apache/tapestry/junit/parse
                        TestSpecificationParser.java Property.page
               framework/src/java/org/apache/tapestry/parse
                        Tapestry_3_1.dtd
  Log:
  Remove the type attribute from the <property> element; make specified properties match
abstract accessors (if any), or just be type Object.
  
  Revision  Changes    Path
  1.6       +5 -16     jakarta-tapestry/src/documentation/content/xdocs/UsersGuide/spec.xml
  
  Index: spec.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/src/documentation/content/xdocs/UsersGuide/spec.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- spec.xml	2 Nov 2004 03:32:42 -0000	1.5
  +++ spec.xml	3 Nov 2004 13:53:43 -0000	1.6
  @@ -120,7 +120,8 @@
     <li>The &lt;inherited-binding&gt; element has been removed; parameters
of parent components may be
       accessed as properties.</li>
     <li>The &lt;property&gt; element (in 3.0) has been renamed to &spec.meta;.</li>
  -  <li>The &lt;property-specification; element (in 3.0) has been renamed to &spec.property;.</li>
  +  <li>The &lt;property-specification; element (in 3.0) has been renamed to &spec.property;,
and the type
  +    attribute has been dropped.</li>
     <li>The &spec.inject; element has been added.</li>
   </ul>
   
  @@ -1406,18 +1407,6 @@
   	<td>The name of the property to create.</td>
   </tr>
   <tr>
  -	<td>type</td>
  -	<td>string</td>
  -	<td>no</td>
  -	<td>java.lang.Object</td>
  -	<td>
  -	The type of the property.  If abstract accessors exist, they must exactly match
  -	this type.  The type may be either a fully qualified class name, or the name
  -	of one of the basic scalar types (int, boolean, etc.). It may be suffixed with
  -	[] to indicate an array of the indicated type.
  -	</td>
  -</tr>
  -<tr>
   	<td>persistent</td>
   	<td>yes|no</td>
   	<td>no</td>
  @@ -1440,9 +1429,9 @@
   
   </table>
   
  -<note>
  -  In the Tapestry 3.0 DTD, this element was named &lt;property-specification&gt;.
  -</note>
  +<note> In the Tapestry 3.0 DTD, this element was named &lt;property-specification&gt;
and had an additional attribute, 
  +  type. In Tapestry 3.1, the type of the implemented property will simply match the type
of any existing (abstract) 
  +  property, or will simply be type Object. </note>
   
   </section> <!-- spec.property -->
   
  
  
  
  1.4       +16 -19    jakarta-tapestry/src/documentation/content/xdocs/UsersGuide/state.xml
  
  Index: state.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/src/documentation/content/xdocs/UsersGuide/state.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- state.xml	2 Nov 2004 03:32:42 -0000	1.3
  +++ state.xml	3 Nov 2004 13:53:43 -0000	1.4
  @@ -437,7 +437,7 @@
     <property
       name="itemsPerPage"
       persistent="yes"
  -    type="int" initial-value="10"/>
  +    initial-value="10"/>
   
   </page-specification>
   ]]>
  @@ -450,28 +450,19 @@
   always include both a getter and a setter.
   </p>
   
  -<warning>
  +<note>
   In Tapestry 3.0, many users were frustrated that they had to specify the type of property
   in both the Java code and in the page specification. This is a violation of the
   <link href="http://c2.com/cgi/wiki?DontRepeatYourself">Dont Repeat Yourself</link>
principal -- requiring
  -coordination is just an inviation for the two sides to get out of synchronization.  In
Tapestry 3.1, it
  -is likely that <em>any</em> abstract property in the Java code will become
a transient property, even when
  -there's no corresponding &spec.property; element. The &spec.property; element will
  -be used to mark a property as persistent (the type will still not have to be defined),
to provide an initial value,
  -or specify a property that isn't referenced from Java code (and even here, type will be
optional and default to Object).
  -</warning>
  +coordination is just an inviation for the two sides to get out of synchronization. Starting
with Tapestry 3.1,
  +there is no type attribute on the &spec.property; element; instead Tapestry matches
the type to the
  +property type of any existing accessor methods, and simply uses Object when there are no
accessor methods.  In
  +this example, the persistent itemsPerPage property will be type int, because of the abstract
accessor methods.
  +</note>
   
   <p>
  -This exact same technique can be used with components as well as pages.
  -</p>
  -
  -<p>
  -A last note about initialization.  After Tapestry invokes the <code>finishLoad()</code>
  -method, it processes the initial value provided in the specification.  If 
  -the initial-value attribute is ommitted or blank, no change takes place.
  -Tapestry then takes a snapshot of the property value, which it retains 
  -and uses at the end of each request cycle
  -to reset the property back to its "pristine" state.
  +This exact same technique can be used with components as well as pages, the component specification
also supports
  +the &spec.property; element.
   </p>
   
   <p>
  @@ -586,7 +577,7 @@
     {
       _itemsPerPage = itemsPerPage;
       
  -    Tapestry.fireObservedChange(this, "itemsPerPage", itemsPerPage);
  +    Tapestry.fireObservedChange(this, "itemsPerPage", new Integer(itemsPerPage));
     }
     
     protected void initialize()
  @@ -731,6 +722,12 @@
   organized in such a way that the Visit object is not created, and no persistent state is
stored).  This will help
   speed the initial display of the application, since no processing time will be used in
creating the HttpSession.
   </p>	
  +
  +<note>
  +There are plans for Tapestry 3.1 to allow some persistent state to be stored as HTTP cookies
or in hidden form fields (and as query parameters
  +inside URLs). In these cases, a web application would be "stateful" without necessarily
using an HttpSession. What remains to be seen
  +is whether this will be practical.
  +</note>
   	
   </section> <!-- state.stateless -->
   
  
  
  
  1.3       +19 -2     jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/SpecifiedPropertyWorker.java
  
  Index: SpecifiedPropertyWorker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/SpecifiedPropertyWorker.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SpecifiedPropertyWorker.java	2 Nov 2004 18:59:14 -0000	1.2
  +++ SpecifiedPropertyWorker.java	3 Nov 2004 13:53:43 -0000	1.3
  @@ -75,9 +75,8 @@
           Defense.notNull(ps, "ps");
   
           String propertyName = ps.getName();
  -        Class propertyType = op.convertTypeName(ps.getType());
   
  -        op.validateProperty(propertyName, propertyType);
  +        Class propertyType = extractPropertyType(op, propertyName, ps.getType());
   
           op.claimProperty(propertyName);
   
  @@ -91,6 +90,24 @@
   
           addAccessor(op, propertyName, propertyType, field);
           addMutator(op, propertyName, propertyType, field, ps.isPersistent());
  +    }
  +
  +    // Package private for testing purposes
  +
  +    Class extractPropertyType(EnhancementOperation op, String propertyName, String typeName)
  +    {
  +        if (typeName != null)
  +        {
  +            Class propertyType = op.convertTypeName(typeName);
  +
  +            op.validateProperty(propertyName, propertyType);
  +
  +            return propertyType;
  +        }
  +
  +        Class propertyType = op.getPropertyType(propertyName);
  +
  +        return propertyType == null ? Object.class : propertyType;
       }
   
       private void addAccessor(EnhancementOperation op, String name, Class type, String field)
  
  
  
  1.3       +61 -0     jakarta-tapestry/framework/src/test/org/apache/tapestry/enhance/TestSpecifiedPropertyWorker.java
  
  Index: TestSpecifiedPropertyWorker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/enhance/TestSpecifiedPropertyWorker.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestSpecifiedPropertyWorker.java	2 Nov 2004 18:59:13 -0000	1.2
  +++ TestSpecifiedPropertyWorker.java	3 Nov 2004 13:53:43 -0000	1.3
  @@ -19,6 +19,7 @@
   import java.util.Collections;
   import java.util.Iterator;
   import java.util.List;
  +import java.util.Map;
   
   import org.apache.hivemind.ApplicationRuntimeException;
   import org.apache.hivemind.ErrorLog;
  @@ -214,5 +215,65 @@
           w.performEnhancement(op);
   
           verifyControls();
  +    }
  +
  +    public void testTypeUnspecifiedWithNoExistingProperty()
  +    {
  +        MockControl opc = newControl(EnhancementOperation.class);
  +        EnhancementOperation op = (EnhancementOperation) opc.getMock();
  +
  +        op.getPropertyType("wilma");
  +        opc.setReturnValue(null);
  +
  +        replayControls();
  +
  +        SpecifiedPropertyWorker w = new SpecifiedPropertyWorker();
  +
  +        Class result = w.extractPropertyType(op, "wilma", null);
  +
  +        assertEquals(Object.class, result);
  +
  +        verifyControls();
  +    }
  +
  +    public void testTypeUnspecifiedButExistingProperty()
  +    {
  +        MockControl opc = newControl(EnhancementOperation.class);
  +        EnhancementOperation op = (EnhancementOperation) opc.getMock();
  +
  +        op.getPropertyType("fred");
  +        opc.setReturnValue(Map.class);
  +
  +        replayControls();
  +
  +        SpecifiedPropertyWorker w = new SpecifiedPropertyWorker();
  +
  +        Class result = w.extractPropertyType(op, "fred", null);
  +
  +        assertEquals(Map.class, result);
  +
  +        verifyControls();
  +    }
  +
  +    public void testTypeSpecified()
  +    {
  +        MockControl opc = newControl(EnhancementOperation.class);
  +        EnhancementOperation op = (EnhancementOperation) opc.getMock();
  +
  +        op.convertTypeName("int[]");
  +        opc.setReturnValue(int[].class);
  +
  +        op.validateProperty("betty", int[].class);
  +
  +        replayControls();
  +
  +        SpecifiedPropertyWorker w = new SpecifiedPropertyWorker();
  +
  +        Class result = w.extractPropertyType(op, "betty", "int[]");
  +
  +        assertEquals(int[].class, result);
  +
  +        verifyControls();
  +
       }
   }
  
  
  
  1.3       +26 -20    jakarta-tapestry/framework/src/java/org/apache/tapestry/spec/PropertySpecification.java
  
  Index: PropertySpecification.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/spec/PropertySpecification.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PropertySpecification.java	16 Sep 2004 00:26:28 -0000	1.2
  +++ PropertySpecification.java	3 Nov 2004 13:53:43 -0000	1.3
  @@ -17,22 +17,24 @@
   import org.apache.hivemind.impl.BaseLocatable;
   
   /**
  - *  Defines a transient or persistant property of a component or page.  
  - *  A {@link org.apache.tapestry.engine.IComponentClassEnhancer} uses this information
  - *  to create a subclass with the necessary instance variables and methods.  
  - *
  - *  @author Howard Lewis Ship
  - *  @since 3.0
  + * Defines a transient or persistant property of a component or page. A
  + * {@link org.apache.tapestry.engine.IComponentClassEnhancer}uses this information to create
a
  + * subclass with the necessary instance variables and methods.
    * 
  - **/
  + * @author Howard Lewis Ship
  + * @since 3.0
  + */
   
   public class PropertySpecification extends BaseLocatable implements IPropertySpecification
   {
  -	private String _name;
  -	private String _type = "java.lang.Object";
  -	private boolean _persistent;
  -	private String _initialValue;
  -	
  +    private String _name;
  +
  +    private String _type;
  +
  +    private boolean _persistent;
  +
  +    private String _initialValue;
  +
       public String getInitialValue()
       {
           return _initialValue;
  @@ -48,6 +50,12 @@
           return _persistent;
       }
   
  +    /**
  +     * The type of property to create, or null if no type was specified. The value is the
name of a
  +     * primitive type, a fully qualified class name, or an array name for either. Type
is only
  +     * specified for 3.0 DTDs, in 3.1 the only behavior is for the new property to match
the type
  +     * defined by an abstract accessor, or to be java.lang.Object.
  +     */
       public String getType()
       {
           return _type;
  @@ -58,13 +66,11 @@
           _initialValue = initialValue;
       }
   
  -	/**
  -	 *  Sets the name of the property.  This should not be changed
  -	 *  once this IPropertySpecification is added to
  -	 *  a {@link org.apache.tapestry.spec.ComponentSpecification}.
  -	 * 
  -	 **/
  -	
  +    /**
  +     * Sets the name of the property. This should not be changed once this IPropertySpecification
is
  +     * added to a {@link org.apache.tapestry.spec.ComponentSpecification}.
  +     */
  +
       public void setName(String name)
       {
           _name = name;
  @@ -80,4 +86,4 @@
           _type = type;
       }
   
  -}
  +}
  \ No newline at end of file
  
  
  
  1.4       +11 -14    jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/parse/TestSpecificationParser.java
  
  Index: TestSpecificationParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/parse/TestSpecificationParser.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestSpecificationParser.java	2 Nov 2004 13:30:00 -0000	1.3
  +++ TestSpecificationParser.java	3 Nov 2004 13:53:43 -0000	1.4
  @@ -516,14 +516,14 @@
           ps = spec.getPropertySpecification("init");
           assertEquals("name", "init", ps.getName());
           assertEquals("persistent", false, ps.isPersistent());
  -        assertEquals("type", "java.lang.Object", ps.getType());
  +        assertNull("type", ps.getType());
           assertEquals("initialValue", "pageName", ps.getInitialValue());
           checkLine(ps, 26);
   
           ps = spec.getPropertySpecification("persist");
           assertEquals("name", "persist", ps.getName());
           assertEquals("persistent", true, ps.isPersistent());
  -        assertEquals("type", "java.lang.Object", ps.getType());
  +        assertNull("type", ps.getType());
           assertNull("initialValue", ps.getInitialValue());
           checkLine(ps, 25);
   
  @@ -847,10 +847,10 @@
           assertEquals("rubble", i2.getObjectReference());
           assertNotNull(i2.getLocation());
       }
  -    
  +
       /**
  -     * Test that the new &lt;property&gt; element (was &lt;property-specification&gt;)
  -     * works correctly.
  +     * Test that the new &lt;property&gt; element (was &lt;property-specification&gt;
in release
  +     * 3.0) works correctly.
        * 
        * @since 3.1
        */
  @@ -865,31 +865,28 @@
           IPropertySpecification ps = spec.getPropertySpecification("bool");
           assertEquals("name", "bool", ps.getName());
           assertEquals("persistent", false, ps.isPersistent());
  -        assertEquals("type", "boolean", ps.getType());
  +
  +        // In a 3.1 DTD, type is always null.
  +        assertNull("type", ps.getType());
           assertNull("initialValue", ps.getInitialValue());
           checkLine(ps, 24);
   
           ps = spec.getPropertySpecification("init");
           assertEquals("name", "init", ps.getName());
           assertEquals("persistent", false, ps.isPersistent());
  -        
  -        // Note: this will like change to null as the default, to differentiate
  -        // explicitly "java.lang.Object" from "no value specified"
  -        
  -        assertEquals("type", "java.lang.Object", ps.getType());
  +
           assertEquals("initialValue", "pageName", ps.getInitialValue());
           checkLine(ps, 26);
   
           ps = spec.getPropertySpecification("persist");
           assertEquals("name", "persist", ps.getName());
           assertEquals("persistent", true, ps.isPersistent());
  -        assertEquals("type", "java.lang.Object", ps.getType());
           assertNull("initialValue", ps.getInitialValue());
           checkLine(ps, 25);
   
           ps = spec.getPropertySpecification("unknown");
   
           assertNull("Unknown PropertySpecification", ps);
  -    }    
  -    
  +    }
  +
   }
  
  
  
  1.2       +3 -3      jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/parse/Property.page
  
  Index: Property.page
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/parse/Property.page,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Property.page	2 Nov 2004 03:32:43 -0000	1.1
  +++ Property.page	3 Nov 2004 13:53:43 -0000	1.2
  @@ -21,9 +21,9 @@
        	
   <page-specification>
   
  -<property name="bool" type="boolean"/>
  -<property name="persist" persistent="yes"/>
  -<property name="init" initial-value="pageName"/>
  +  <property name="bool"/>
  +  <property name="persist" persistent="yes"/>
  +  <property name="init" initial-value="pageName"/>
   
   </page-specification>
   
  
  
  
  1.5       +23 -26    jakarta-tapestry/framework/src/java/org/apache/tapestry/parse/Tapestry_3_1.dtd
  
  Index: Tapestry_3_1.dtd
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/parse/Tapestry_3_1.dtd,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Tapestry_3_1.dtd	2 Nov 2004 03:32:42 -0000	1.4
  +++ Tapestry_3_1.dtd	3 Nov 2004 13:53:43 -0000	1.5
  @@ -31,6 +31,7 @@
     There is now just <binding>, whose value attribute contains a prefix to interpret
how
     the remainder of the value is interpreted (no prefix meaning a literal, or static, value).
   - <property> renamed to <meta> and <property-specification> renamed to
<property>
  +- Removed the type attribute from <property>
   - Added <inject>
   
   -->
  @@ -346,6 +347,28 @@
   	language CDATA #IMPLIED
   >
   <!-- =======================================================
  +Element: meta
  +Contained by: (many other elements)
  +
  +Defines a key/value pair associated with the application or component specification.  Properties
  +are used to capture information that doesn't fit into the DTD.  The value for the property
is
  +either the value attribute, or the PCDATA wrapped by the property tag 
  +(which is trimmed of leading and trailing whitespace).
  +
  +This should not be confused with several other tags which are used to set JavaBeans properties
  +of various objects.  The <property> tag exists to allow meta-data to be stored in
the specification.
  +
  +Attributes:
  +  key: The name of the property to set.
  +  value: If specified, is the value of the property, otherwise, the PCDATA is used.
  +  
  +-->
  +<!ELEMENT meta (#PCDATA)>
  +<!ATTLIST meta
  +	key CDATA #REQUIRED
  +	value CDATA #IMPLIED
  +>
  +<!-- =======================================================
   Element: page-specification
   Root element
   
  @@ -403,28 +426,6 @@
   	resource-path CDATA #REQUIRED
   >
   <!-- =======================================================
  -Element: meta
  -Contained by: (many other elements)
  -
  -Defines a key/value pair associated with the application or component specification.  Properties
  -are used to capture information that doesn't fit into the DTD.  The value for the property
is
  -either the value attribute, or the PCDATA wrapped by the property tag 
  -(which is trimmed of leading and trailing whitespace).
  -
  -This should not be confused with several other tags which are used to set JavaBeans properties
  -of various objects.  The <property> tag exists to allow meta-data to be stored in
the specification.
  -
  -Attributes:
  -  key: The name of the property to set.
  -  value: If specified, is the value of the property, otherwise, the PCDATA is used.
  -  
  --->
  -<!ELEMENT meta (#PCDATA)>
  -<!ATTLIST meta
  -	key CDATA #REQUIRED
  -	value CDATA #IMPLIED
  ->
  -<!-- =======================================================
   Element: property
   Appears in: page-specification, component-specification
   
  @@ -432,9 +433,6 @@
   
   Attributes:
     name: The name of the property.
  -  type: The type of the value, either the name of a scalar type,
  -    or the fully qualified name of a class.  If omitted,
  -    java.lang.Object is used.
     persistent: If "yes", the value will be made persistant.  Default
       is "no".
     initial-value:  If provided, this is an OGNL expression used
  @@ -445,7 +443,6 @@
   <!ELEMENT property (#PCDATA)>
   <!ATTLIST property
   	name CDATA #REQUIRED
  -	type CDATA #IMPLIED
   	persistent %attribute-flag; "no"
   	initial-value CDATA #IMPLIED
   >
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


Mime
View raw message