You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2004/04/06 20:18:57 UTC

cvs commit: jakarta-tapestry/junit/context35 Home.html README

hlship      2004/04/06 11:18:57

  Modified:    .        status.xml
               framework/src/org/apache/tapestry/enhance/javassist
                        CreateAutoParameterEnhancer.java
               doc/src/UsersGuide components.xml
  Added:       junit/mock-scripts TestAutoLongParameter.xml
               junit/context35/WEB-INF Home.page MyComponent.html
                        MyComponent.jwc
               junit/src/org/apache/tapestry/junit/mock/c35
                        MyComponent.java
               junit/context35 Home.html README
  Log:
  [28235] CodeGenerationException in case of a component parameter type "long"
  
  Revision  Changes    Path
  1.42      +6 -1      jakarta-tapestry/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/status.xml,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- status.xml	6 Apr 2004 16:26:58 -0000	1.41
  +++ status.xml	6 Apr 2004 18:18:57 -0000	1.42
  @@ -236,6 +236,11 @@
     	Make checks for unimplemented abstract methods optional, to work around a bug
     	in IBM JDK 1.3.1 (used with Websphere 4.x).	
     </action>
  +  <action type="fix" dev="HLS" fixes-bug="28235">
  +  Allow more primitive types to be used with parameter direction <code>auto</code>
  +  (byte, char, short, float and long) in addition to the previously accepted types
  +  (boolean, int, double and objects).
  +  </action>
    </release> 
     
    <release version="3.0-rc-2" date="Apr 1 2004">
  
  
  
  1.5       +28 -4     jakarta-tapestry/framework/src/org/apache/tapestry/enhance/javassist/CreateAutoParameterEnhancer.java
  
  Index: CreateAutoParameterEnhancer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/enhance/javassist/CreateAutoParameterEnhancer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CreateAutoParameterEnhancer.java	19 Feb 2004 17:37:56 -0000	1.4
  +++ CreateAutoParameterEnhancer.java	6 Apr 2004 18:18:57 -0000	1.5
  @@ -65,12 +65,13 @@
        *  Legend:                             <br>
        *      {0} = readBindingMethodName     <br>
        *      {1} = binding value mutator     <br>
  +     *      {2} = value cast
        */
       protected static final String PARAMETER_MUTATOR_TEMPLATE =
           ""
               + "'{'"
               + "  org.apache.tapestry.IBinding binding = {0}();"
  -            + "  binding.{1}($1); "
  +            + "  binding.{1}({2} $1); "
               + "'}'";
   
       /**
  @@ -80,13 +81,23 @@
        */
       private static final Map SPECIAL_BINDING_TYPES = new HashMap();
   
  -    {
  +    static {
           SPECIAL_BINDING_TYPES.put("boolean", "boolean");
           SPECIAL_BINDING_TYPES.put("int", "int");
           SPECIAL_BINDING_TYPES.put("double", "double");
           SPECIAL_BINDING_TYPES.put("java.lang.String", "string");
       }
   
  +    private static final Map VALUE_CAST_TYPES = new HashMap();
  +
  +    static {
  +        VALUE_CAST_TYPES.put("byte", "($w)");
  +        VALUE_CAST_TYPES.put("long", "($w)");
  +        VALUE_CAST_TYPES.put("short", "($w)");
  +        VALUE_CAST_TYPES.put("char", "($w)");
  +        VALUE_CAST_TYPES.put("float", "($w)");
  +    }
  +
       private EnhancedClass _enhancedClass;
       private String _propertyName;
       private String _parameterName;
  @@ -128,6 +139,13 @@
           return (String) SPECIAL_BINDING_TYPES.get(typeName);
       }
   
  +    private String getValueCastType()
  +    {
  +        String typeName = _type.getName();
  +
  +        return (String) VALUE_CAST_TYPES.get(typeName);
  +    }
  +
       private void createReadMethod(ClassFabricator cf, String readBindingMethodName)
       {
           String castToType;
  @@ -165,6 +183,7 @@
       private void createWriteMethod(ClassFabricator cf, String readBindingMethodName)
       {
           String bindingValueAccessor;
  +        String valueCast = "";
   
           String specialBindingType = getSpecialBindingType();
           if (specialBindingType != null)
  @@ -174,12 +193,17 @@
           else
           {
               bindingValueAccessor = "setObject";
  +
  +            String castForType = getValueCastType();
  +
  +            if (castForType != null)
  +                valueCast = castForType;
           }
   
           String writeMethodBody =
               MessageFormat.format(
                   PARAMETER_MUTATOR_TEMPLATE,
  -                new Object[] { readBindingMethodName, bindingValueAccessor });
  +                new Object[] { readBindingMethodName, bindingValueAccessor, valueCast });
   
           try
           {
  
  
  
  1.4       +2 -3      jakarta-tapestry/doc/src/UsersGuide/components.xml
  
  Index: components.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/doc/src/UsersGuide/components.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- components.xml	9 Mar 2004 12:42:01 -0000	1.3
  +++ components.xml	6 Apr 2004 18:18:57 -0000	1.4
  @@ -488,8 +488,7 @@
   
   <para>
   This can be a bit less efficient than direction <literal>in</literal>, as the &OGNL; expression may be
  -evaluated multiple times. In Tapestry 3.0, there are other limitations: the parameter must either be an object type, 
  -or one of a limited number of primitive Java types: boolean, int or double. The parameter must also be required. Future releases
  +evaluated multiple times. In Tapestry 3.0, the parameter must also be required. Future releases
   of Tapestry will relax these limitations.
   </para>
   
  
  
  
  1.1                  jakarta-tapestry/junit/mock-scripts/TestAutoLongParameter.xml
  
  Index: TestAutoLongParameter.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <!-- $Id: TestAutoLongParameter.xml,v 1.1 2004/04/06 18:18:57 hlship Exp $ -->
  <!--
     Copyright 2004 The Apache Software Foundation
    
     Licensed 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.
  -->
  <mock-test>
    <context name="c35" root="context35"/>
  
    <servlet name="app" class="org.apache.tapestry.ApplicationServlet"/>
  
  
    <request>
    
      <assert-output name="Initial Value">
      	Long Value: [100]	
      </assert-output>	
    	
    	<assert-output name="Link">
  			href="/c35/app?service=direct/0/Home/c.l"
    	</assert-output>
    	
    </request>
  	
    <request>
      <parameter name="service" value="direct/0/Home/c.l"/>
      
      <assert-output name="Updated Value">
      	Long Value: [37]	
      </assert-output>
    	
    </request>
  </mock-test>
  
  
  
  1.1                  jakarta-tapestry/junit/context35/WEB-INF/Home.page
  
  Index: Home.page
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!--
      Copyright 2004 The Apache Software Foundation
    
     Licensed 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.
  -->
  <!-- $Id: Home.page,v 1.1 2004/04/06 18:18:57 hlship Exp $ -->
  <!DOCTYPE page-specification PUBLIC 
    "-//Apache Software Foundation//Tapestry Specification 3.0//EN" 
    "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
  
  <page-specification>
  	
    <property-specification name="longValue" type="long" initial-value="100"/>
  	
  </page-specification>
  
  
  1.1                  jakarta-tapestry/junit/context35/WEB-INF/MyComponent.html
  
  Index: MyComponent.html
  ===================================================================
  <!--
      Copyright 2004 The Apache Software Foundation
    
     Licensed 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.
  -->
  <!-- $Id: MyComponent.html,v 1.1 2004/04/06 18:18:57 hlship Exp $ -->
  <span jwcid="$content$">
  
  <a href="#" jwcid="l@DirectLink" listener="ognl:listeners.updateValue">update value</a>
  
  </span>
  
  
  1.1                  jakarta-tapestry/junit/context35/WEB-INF/MyComponent.jwc
  
  Index: MyComponent.jwc
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!--
      Copyright 2004 The Apache Software Foundation
    
     Licensed 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.
  -->
  <!-- $Id: MyComponent.jwc,v 1.1 2004/04/06 18:18:57 hlship Exp $ -->
  <!DOCTYPE component-specification PUBLIC 
    "-//Apache Software Foundation//Tapestry Specification 3.0//EN" 
    "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
  
  <component-specification class="org.apache.tapestry.junit.mock.c35.MyComponent">
  	
  	<parameter name="long" type="long" required="yes" direction="auto"/>
  	
  </component-specification>
  
  
  1.1                  jakarta-tapestry/junit/src/org/apache/tapestry/junit/mock/c35/MyComponent.java
  
  Index: MyComponent.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed 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 org.apache.tapestry.junit.mock.c35;
  
  import org.apache.tapestry.BaseComponent;
  import org.apache.tapestry.IRequestCycle;
  
  /**
   * Used to check that auto parameters of type long are implemented correctly.
   *
   * @author Howard Lewis Ship
   * @version $Id: MyComponent.java,v 1.1 2004/04/06 18:18:57 hlship Exp $
   */
  public abstract class MyComponent extends BaseComponent
  {
      public abstract void setLong(long value);
  
      public void updateValue(IRequestCycle cycle)
      {
          setLong(37l);
      }
  }
  
  
  
  1.1                  jakarta-tapestry/junit/context35/Home.html
  
  Index: Home.html
  ===================================================================
  <html jwcid="@Shell" title="context35">
  <body jwcid="@Body">
  
  
  Long Value: [<span jwcid="@Insert" value="ognl:longValue"/>]
  
  <span jwcid="c@MyComponent" long="ognl:longValue"/>
  
  </body>
  </html>
  
  
  
  1.1                  jakarta-tapestry/junit/context35/README
  
  Index: README
  ===================================================================
  Bug 28235 CodeGenerationException in case of a component parameter type "long"  
  
  http://issues.apache.org/bugzilla/show_bug.cgi?id=28235
  
  

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