You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Howard Lewis Ship <hl...@gmail.com> on 2009/02/18 21:17:30 UTC

Re: svn commit: r745627 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry5/corelib/components/ test/java/org/apache/tapestry5/integration/ test/java/org/apache/tapestry5/integration/app1/pages/ test/resources/org/apache/

I'm concerned about this fix.

It does not look to actually record the context value into the form
data (or the URL for that matter ... watch out for cut-n-paste!). It
will resolve the context parameter when the form is submitted.  This
is useful, but not what is documented.

To work as described, it should be recording a ComponentAction into
the FormSupport when rendering; the CA needs to contain the serialized
version of the context data.  That context data can be converted back
into an EventContext when the CA is triggered (by the Form
submission).

Alternately, fix the documentation to match the actual behavior.

Sorry to nitpick,

Howard


On Wed, Feb 18, 2009 at 11:45 AM,  <dr...@apache.org> wrote:
> Author: drobiazko
> Date: Wed Feb 18 19:45:03 2009
> New Revision: 745627
>
> URL: http://svn.apache.org/viewvc?rev=745627&view=rev
> Log:
> TAP5-194: Handler method of Submit component should accept a context
>
> Added:
>    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/SubmitWithContext.java
>    tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/SubmitWithContext.tml
> Modified:
>    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Submit.java
>    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
>    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
>
> Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Submit.java
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Submit.java?rev=745627&r1=745626&r2=745627&view=diff
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Submit.java (original)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Submit.java Wed Feb 18 19:45:03 2009
> @@ -52,6 +52,14 @@
>      */
>     @Parameter("false")
>     private boolean disabled;
> +
> +    /**
> +     * The context for the link (optional parameter). This list of values will be converted into strings and included in
> +     * the URI. The strings will be coerced back to whatever their values are and made available to event handler
> +     * methods.
> +     */
> +    @Parameter
> +    private Object[] context;
>
>
>     @Environmental
> @@ -131,7 +139,7 @@
>         {
>             public void run()
>             {
> -                resources.triggerEvent(event, null, null);
> +                resources.triggerEvent(event, context, null);
>             }
>         };
>
>
> Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java?rev=745627&r1=745626&r2=745627&view=diff
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java (original)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java Wed Feb 18 19:45:03 2009
> @@ -1992,6 +1992,16 @@
>
>         assertText("sum", "0.0");
>     }
> +
> +    @Test
> +    public void submit_with_context()
> +    {
> +        start("Submit With Context");
> +
> +        clickAndWait(SUBMIT);
> +
> +        assertTextPresent("Result: 10.14159");
> +    }
>
>     /**
>      * TAPESTRY-2196
>
> Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java?rev=745627&r1=745626&r2=745627&view=diff
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java (original)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java Wed Feb 18 19:45:03 2009
> @@ -317,7 +317,10 @@
>                      "Access to informal parameters names and values"),
>
>             new Item("FormFieldOutsideForm", "Form Field Outside Form",
> -                     "Nice exception message for common problem of form fields outside forms")
> +                     "Nice exception message for common problem of form fields outside forms"),
> +
> +            new Item("SubmitWithContext", "Submit With Context",
> +                              "Providing a context for Submit component")
>     );
>
>     static
>
> Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/SubmitWithContext.java
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/SubmitWithContext.java?rev=745627&view=auto
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/SubmitWithContext.java (added)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/SubmitWithContext.java Wed Feb 18 19:45:03 2009
> @@ -0,0 +1,35 @@
> +// Copyright 2009 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.tapestry5.integration.app1.pages;
> +
> +import org.apache.tapestry5.annotations.Persist;
> +import org.apache.tapestry5.annotations.Property;
> +
> +public class SubmitWithContext
> +{
> +    @Persist
> +    @Property
> +    private Double result;
> +
> +    public Object[] getFormContext()
> +    {
> +        return new Object[]{new Integer(7), new Double(3.14159)};
> +     }
> +
> +    void onSelected(Integer first, Double second)
> +    {
> +        result = first + second;
> +    }
> +}
>
> Added: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/SubmitWithContext.tml
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/SubmitWithContext.tml?rev=745627&view=auto
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/SubmitWithContext.tml (added)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/SubmitWithContext.tml Wed Feb 18 19:45:03 2009
> @@ -0,0 +1,12 @@
> +<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
> +    <h1>Submit With Context</h1>
> +
> +    <p>  Result: ${result}.</p>
> +
> +    <p>
> +      <t:form>
> +            <input t:type="submit" context="formContext" value="Send"/>
> +       </t:form>
> +    </p>
> +
> +</html>
>
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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