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/test/org/apache/tapestry/spec TestComponentSpecification.java
Date Thu, 02 Jun 2005 13:35:10 GMT
hlship      2005/06/02 06:35:10

  Modified:    .        status.xml
               contrib/src/java/org/apache/tapestry/contrib/table/components
                        TableView.jwc
               portlet/src/java/org/apache/tapestry/portlet
                        PortletConstants.java PortletRendererImpl.java
                        PortletResponseRenderer.java
               portlet/src/descriptor/META-INF
                        tapestry.portlet.services.xml
               framework/src/java/org/apache/tapestry/pageload
                        EstablishDefaultParameterValuesVisitor.java
                        VerifyRequiredParametersVisitor.java
                        QueuedInheritedBinding.java
               portlet/src/test/org/apache/tapestry/portlet
                        TestPortletResponseRenderer.java
               framework/src/java/org/apache/tapestry/spec
                        IComponentSpecification.java
                        ComponentSpecification.java
               examples/Workbench/src/context/WEB-INF LocaleSelection.jwc
               framework/src/test/org/apache/tapestry/spec
                        TestComponentSpecification.java
  Log:
  Properly wire the assetFactory property of the tapestry.portlet.services.PortletRenderer
service.
  Fix some missing default bindings for the Table component (and subcomponents).
  Add getRequiredParameters() method to IComponentSpecification.
  Make inherited bindings (a holdover from the 3.0 DTDs) override (quietly) default parameter
bindings.
  Properly identify when portal mode or window state has changed.
  
  Revision  Changes    Path
  1.113     +5 -0      jakarta-tapestry/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/status.xml,v
  retrieving revision 1.112
  retrieving revision 1.113
  diff -u -r1.112 -r1.113
  --- status.xml	31 May 2005 16:36:13 -0000	1.112
  +++ status.xml	2 Jun 2005 13:35:10 -0000	1.113
  @@ -60,6 +60,11 @@
          <action type="add" dev="HLS">Add support for validation decoration to TextArea.</action>
          <action type="add" dev="HLS">Add raw parameter to InsertText.</action>
          <action type="add" dev="HLS">Add aliases attribute to &lt;parmeter&gt;
element, to allow parameters to be renamed.</action>
  +       <action type="fix" dev="HLS">Properly wire the assetFactory property of the
tapestry.portlet.services.PortletRenderer service.</action>
  +       <action type="fix" dev="HLS">Fix some missing default bindings for the Table
component (and subcomponents).</action>
  +       <action type="add" dev="HLS">Add getRequiredParameters() method to IComponentSpecification.
</action>
  +       <action type="fix" dev="HLS">Make inherited bindings (a holdover from the
3.0 DTDs) override (quietly) default parameter bindings.</action>
  +       <action type="fix" dev="HLS">Properly identify when portal mode or window
state has changed.</action>
       </release>
       <release version="4.0-alpha-3" date="May 16 2005">
         <action type="add" dev="HLS">Add initial support for the validator: binding
prefix.</action>
  
  
  
  1.10      +1 -1      jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/TableView.jwc
  
  Index: TableView.jwc
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/TableView.jwc,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TableView.jwc	18 Apr 2005 17:08:19 -0000	1.9
  +++ TableView.jwc	2 Jun 2005 13:35:10 -0000	1.10
  @@ -102,7 +102,7 @@
           </description>
       </parameter>
       
  -    <parameter name="element" default-value="table">
  +    <parameter name="element" default-value="table" default-binding="literal"> 
           <description>
               The tag with which the component will be inserted in the generated content.
           </description>
  
  
  
  1.4       +14 -0     jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/PortletConstants.java
  
  Index: PortletConstants.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/PortletConstants.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PortletConstants.java	4 May 2005 23:03:42 -0000	1.3
  +++ PortletConstants.java	2 Jun 2005 13:35:10 -0000	1.4
  @@ -39,6 +39,20 @@
   
       public static final String PORTLET_EXCEPTION_MARKUP_ATTRIBUTE = "org.apache.tapestry.portlet.PortletExceptionMarkup";
   
  +    /**
  +     * Render parameter name storing the portlet mode at the time the render URL was created.
This
  +     * is necessary for determining when the mode has changed.
  +     */
  +
  +    public static final String PORTLET_MODE = "portlet-mode";
  +
  +    /**
  +     * Render parameter name storing the window state at the time the render URL was created.
Again,
  +     * this is necessary for determining when the window state has changed.
  +     */
  +
  +    public static final String WINDOW_STATE = "window-state";
  +
       private PortletConstants()
       {
           // Prevent instantiation
  
  
  
  1.7       +1 -1      jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/PortletRendererImpl.java
  
  Index: PortletRendererImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/PortletRendererImpl.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PortletRendererImpl.java	20 May 2005 12:46:07 -0000	1.6
  +++ PortletRendererImpl.java	2 Jun 2005 13:35:10 -0000	1.7
  @@ -32,7 +32,7 @@
   
   /**
    * The guts of rendering a page as a portlet response; used by
  - * {@link org.apache.tapestry.portlet.RenderService}&nbsp;and
  + * {@link org.apache.tapestry.portlet.RenderService} and
    * {@link org.apache.tapestry.portlet.PortletHomeService}.
    * 
    * @author Howard M. Lewis Ship
  
  
  
  1.5       +15 -3     jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/PortletResponseRenderer.java
  
  Index: PortletResponseRenderer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/PortletResponseRenderer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PortletResponseRenderer.java	18 Apr 2005 17:08:37 -0000	1.4
  +++ PortletResponseRenderer.java	2 Jun 2005 13:35:10 -0000	1.5
  @@ -15,15 +15,16 @@
   package org.apache.tapestry.portlet;
   
   import javax.portlet.ActionResponse;
  +import javax.portlet.PortletRequest;
   
   import org.apache.tapestry.IRequestCycle;
   import org.apache.tapestry.services.ResponseRenderer;
   import org.apache.tapestry.services.ServiceConstants;
   
   /**
  - * Sets render parameters on the current {@link javax.portlet.ActionResponse}&nbsp;that
will invoke
  - * the {@link org.apache.tapestry.portlet.RenderService}to render the (currently) active
page. This
  - * reflects the Portlet APIs very clear division between processing an action and rendering
a
  + * Sets render parameters on the current {@link javax.portlet.ActionResponse} that will
invoke the
  + * {@link org.apache.tapestry.portlet.RenderService} to render the (currently) active page.
This
  + * reflects the Portlet API's very clear division between processing an action and rendering
a
    * response; we need to record into the implicit render URL the render service and the
name of the
    * active page.
    * 
  @@ -32,6 +33,8 @@
    */
   public class PortletResponseRenderer implements ResponseRenderer
   {
  +    private PortletRequest _request;
  +
       private ActionResponse _response;
   
       public void renderResponse(IRequestCycle cycle)
  @@ -40,10 +43,19 @@
   
           _response.setRenderParameter(ServiceConstants.SERVICE, PortletConstants.RENDER_SERVICE);
           _response.setRenderParameter(ServiceConstants.PAGE, pageName);
  +        _response.setRenderParameter(PortletConstants.PORTLET_MODE, _request.getPortletMode()
  +                .toString());
  +        _response.setRenderParameter(PortletConstants.WINDOW_STATE, _request.getWindowState()
  +                .toString());
       }
   
       public void setResponse(ActionResponse response)
       {
           _response = response;
       }
  +
  +    public void setRequest(PortletRequest request)
  +    {
  +        _request = request;
  +    }
   }
  \ No newline at end of file
  
  
  
  1.13      +2 -1      jakarta-tapestry/portlet/src/descriptor/META-INF/tapestry.portlet.services.xml
  
  Index: tapestry.portlet.services.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/portlet/src/descriptor/META-INF/tapestry.portlet.services.xml,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- tapestry.portlet.services.xml	15 May 2005 22:56:37 -0000	1.12
  +++ tapestry.portlet.services.xml	2 Jun 2005 13:35:10 -0000	1.13
  @@ -82,7 +82,7 @@
         <construct class="PortletRendererImpl">
           <set-object property="markupWriterSource" value="infrastructure:markupWriterSource"/>
           <set-object property="response" value="infrastructure:response"/>       
  -        <set-object property="assetService" value="engine-service:asset"/>
  +        <set-object property="assetFactory" value="infrastructure:assetFactory"/>
           <set-object property="applicationId" value="infrastructure:applicationId"/>
         </construct>
       </invoke-factory>
  @@ -118,6 +118,7 @@
     
     <invoke-factory>
       <construct class="PortletResponseRenderer">
  +      <set-service property="request" service-id="tapestry.portlet.PortletRequest"/>
         <set-service property="response" service-id="tapestry.portlet.ActionResponse"/>
       </construct>
     </invoke-factory>
  
  
  
  1.13      +6 -1      jakarta-tapestry/framework/src/java/org/apache/tapestry/pageload/EstablishDefaultParameterValuesVisitor.java
  
  Index: EstablishDefaultParameterValuesVisitor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/pageload/EstablishDefaultParameterValuesVisitor.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- EstablishDefaultParameterValuesVisitor.java	18 Apr 2005 17:06:40 -0000	1.12
  +++ EstablishDefaultParameterValuesVisitor.java	2 Jun 2005 13:35:10 -0000	1.13
  @@ -50,6 +50,11 @@
               String name = (String) i.next();
               IParameterSpecification parameterSpec = spec.getParameter(name);
   
  +            // Skip aliases
  +            
  +            if (! name.equals(parameterSpec.getParameterName()))
  +                continue;
  +            
               String defaultValue = parameterSpec.getDefaultValue();
               if (defaultValue == null)
                   continue;
  @@ -61,7 +66,7 @@
                           .getLocation(), null);
   
               // if there is no binding for this parameter, bind it to the default value.
  -            // In 3.0, default-value as always an OGNL expression, but now its a locator.
  +            // In 3.0, default-value was always an OGNL expression, but now its a binding
reference.
   
               if (component.getBinding(name) == null)
               {
  
  
  
  1.6       +3 -12     jakarta-tapestry/framework/src/java/org/apache/tapestry/pageload/VerifyRequiredParametersVisitor.java
  
  Index: VerifyRequiredParametersVisitor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/pageload/VerifyRequiredParametersVisitor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- VerifyRequiredParametersVisitor.java	31 May 2005 16:35:11 -0000	1.5
  +++ VerifyRequiredParametersVisitor.java	2 Jun 2005 13:35:10 -0000	1.6
  @@ -37,22 +37,13 @@
       {
           IComponentSpecification spec = component.getSpecification();
   
  -        Iterator i = spec.getParameterNames().iterator();
  +        Iterator i = spec.getRequiredParameters().iterator();
   
           while (i.hasNext())
           {
  -            String name = (String) i.next();
  -            IParameterSpecification parameterSpec = spec.getParameter(name);
  +            IParameterSpecification parameterSpec = (IParameterSpecification) i.next();
   
  -            if (!parameterSpec.isRequired())
  -                continue;
  -
  -            // The names include aliases, but the aliases are translated to primary names
  -            // as they are bound. The pspec will be keyed under both the alias name
  -            // and the primary name, so the check only should apply to the primary name.
  -
  -            if (!name.equals(parameterSpec.getParameterName()))
  -                continue;
  +            String name = parameterSpec.getParameterName();
   
               if (component.getBinding(name) == null)
                   throw new ApplicationRuntimeException(PageloadMessages.requiredParameterNotBound(
  
  
  
  1.6       +7 -1      jakarta-tapestry/framework/src/java/org/apache/tapestry/pageload/QueuedInheritedBinding.java
  
  Index: QueuedInheritedBinding.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/pageload/QueuedInheritedBinding.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- QueuedInheritedBinding.java	31 May 2005 16:35:11 -0000	1.5
  +++ QueuedInheritedBinding.java	2 Jun 2005 13:35:10 -0000	1.6
  @@ -46,6 +46,12 @@
           if (binding == null)
               return;
   
  -        PageLoader.addBindingToComponent(_component, _parameterName, binding);
  +        // In many cases, a default parameter binding will have been set on the child component
  +        // parameter, which
  +        // gets overwritten by this inherited binding. There's still a lot of ambiquity
concerning
  +        // binding
  +        // an alias this way.
  +
  +        _component.setBinding(_parameterName, binding);
       }
   }
  \ No newline at end of file
  
  
  
  1.4       +16 -0     jakarta-tapestry/portlet/src/test/org/apache/tapestry/portlet/TestPortletResponseRenderer.java
  
  Index: TestPortletResponseRenderer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/portlet/src/test/org/apache/tapestry/portlet/TestPortletResponseRenderer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestPortletResponseRenderer.java	18 Apr 2005 17:08:37 -0000	1.3
  +++ TestPortletResponseRenderer.java	2 Jun 2005 13:35:10 -0000	1.4
  @@ -15,6 +15,9 @@
   package org.apache.tapestry.portlet;
   
   import javax.portlet.ActionResponse;
  +import javax.portlet.PortletMode;
  +import javax.portlet.PortletRequest;
  +import javax.portlet.WindowState;
   
   import org.apache.hivemind.test.HiveMindTestCase;
   import org.apache.tapestry.IPage;
  @@ -61,15 +64,28 @@
       {
           IPage page = newPage("Frodo");
           IRequestCycle cycle = newCycle(page);
  +
  +        MockControl requestc = newControl(PortletRequest.class);
  +        PortletRequest request = (PortletRequest) requestc.getMock();
  +
  +        request.getPortletMode();
  +        requestc.setReturnValue(PortletMode.VIEW);
  +
  +        request.getWindowState();
  +        requestc.setReturnValue(WindowState.NORMAL);
  +
           ActionResponse response = newResponse();
   
           response.setRenderParameter(ServiceConstants.SERVICE, PortletConstants.RENDER_SERVICE);
           response.setRenderParameter(ServiceConstants.PAGE, "Frodo");
  +        response.setRenderParameter(PortletConstants.PORTLET_MODE, "view");
  +        response.setRenderParameter(PortletConstants.WINDOW_STATE, "normal");
   
           replayControls();
   
           PortletResponseRenderer renderer = new PortletResponseRenderer();
           renderer.setResponse(response);
  +        renderer.setRequest(request);
   
           renderer.renderResponse(cycle);
   
  
  
  
  1.10      +11 -1     jakarta-tapestry/framework/src/java/org/apache/tapestry/spec/IComponentSpecification.java
  
  Index: IComponentSpecification.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/spec/IComponentSpecification.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- IComponentSpecification.java	31 May 2005 16:35:11 -0000	1.9
  +++ IComponentSpecification.java	2 Jun 2005 13:35:10 -0000	1.10
  @@ -62,7 +62,8 @@
       public void addComponent(String id, IContainedComponent component);
   
       /**
  -     * Adds the parameter. The name is added as a reserved name.
  +     * Adds the parameter. The parameter name and aliases are added as a reserved name.
The code
  +     * assumes that the parameter specification will <strong>not</strong> be
subsequently changed.
        * 
        * @throws IllegalArgumentException
        *             if the name already exists.
  @@ -135,6 +136,15 @@
       public IParameterSpecification getParameter(String name);
   
       /**
  +     * Returns an unordered collection of {@link IParameterSpecification}, for all parameters
that
  +     * are required. This includes only "real" parameters, not aliases.
  +     * 
  +     * @since 4.0
  +     */
  +    
  +    public Collection getRequiredParameters();
  +    
  +    /**
        * Returns a List of of String names of all parameters. This list is in alphabetical
order.
        * 
        * @see #addParameter(String, IParameterSpecification)
  
  
  
  1.10      +26 -0     jakarta-tapestry/framework/src/java/org/apache/tapestry/spec/ComponentSpecification.java
  
  Index: ComponentSpecification.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/spec/ComponentSpecification.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ComponentSpecification.java	31 May 2005 16:35:11 -0000	1.9
  +++ ComponentSpecification.java	2 Jun 2005 13:35:10 -0000	1.10
  @@ -335,6 +335,32 @@
           return (IParameterSpecification) get(_parameters, name);
       }
   
  +    public Collection getRequiredParameters()
  +    {
  +        if (_parameters == null)
  +            return Collections.EMPTY_LIST;
  +
  +        Collection result = new ArrayList();
  +
  +        Iterator i = _parameters.entrySet().iterator();
  +        while (i.hasNext())
  +        {
  +            Map.Entry entry = (Map.Entry) i.next();
  +            String name = (String) entry.getKey();
  +            IParameterSpecification spec = (IParameterSpecification) entry.getValue();
  +
  +            if (!spec.isRequired())
  +                continue;
  +
  +            if (!name.equals(spec.getParameterName()))
  +                continue;
  +
  +            result.add(spec);
  +        }
  +
  +        return result;
  +    }
  +
       /**
        * Returns a List of of String names of all parameters. This list is in alphabetical
order.
        * 
  
  
  
  1.7       +1 -1      jakarta-tapestry/examples/Workbench/src/context/WEB-INF/LocaleSelection.jwc
  
  Index: LocaleSelection.jwc
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Workbench/src/context/WEB-INF/LocaleSelection.jwc,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LocaleSelection.jwc	18 Apr 2005 17:09:03 -0000	1.6
  +++ LocaleSelection.jwc	2 Jun 2005 13:35:10 -0000	1.7
  @@ -61,7 +61,7 @@
           <binding name="row" value="ognl:currentLocale"/>
           
           <!-- Each rendered row will be given the CSS class of 'tableRowsClass' -->
  -		<binding name="rowsClass" value="tableRowsClass"/>
  +		<binding name="rowsClass" value="literal:tableRowsClass"/>
           
   	</component>
   	
  
  
  
  1.3       +34 -0     jakarta-tapestry/framework/src/test/org/apache/tapestry/spec/TestComponentSpecification.java
  
  Index: TestComponentSpecification.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/spec/TestComponentSpecification.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestComponentSpecification.java	31 May 2005 16:35:12 -0000	1.2
  +++ TestComponentSpecification.java	2 Jun 2005 13:35:10 -0000	1.3
  @@ -182,6 +182,40 @@
               assertEquals(SpecMessages.duplicateBean("wilma", b1), ex.getMessage());
               assertSame(l2, ex.getLocation());
           }
  +    }
  +
  +    public void testGetRequiredParametersNone()
  +    {
  +        ComponentSpecification cs = new ComponentSpecification();
  +
  +        assertTrue(cs.getRequiredParameters().isEmpty());
  +    }
  +
  +    public void testGetRequiredParametersOptional()
  +    {
  +        ComponentSpecification cs = new ComponentSpecification();
  +
  +        ParameterSpecification ps = new ParameterSpecification();
  +        ps.setParameterName("fred");
  +        ps.setAliases("barney");
  +
  +        cs.addParameter(ps);
  +
  +        assertTrue(cs.getRequiredParameters().isEmpty());
  +    }
  +
  +    public void testGetRequiredParametersFiltersAliases()
  +    {
  +        ComponentSpecification cs = new ComponentSpecification();
  +
  +        ParameterSpecification ps = new ParameterSpecification();
  +        ps.setParameterName("fred");
  +        ps.setAliases("barney");
  +        ps.setRequired(true);
  +
  +        cs.addParameter(ps);
   
  +        assertListsEqual(new Object[]
  +        { ps }, cs.getRequiredParameters().toArray());
       }
   }
  
  
  

---------------------------------------------------------------------
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