Search code examples
tapestry

Tapestry: submit without refresh page, only update zone


I have simple tml:

<t:form t:id="myForm" class="default-form dt-1">
            <t:zone t:id="myZone">
        <div class="buttons-fieldset field">
                        <div class="field inline-field">
                            <div class="button">
                                <t:submit t:id="done" value="Send"/>
                            </div>
                        </div>
                </div>
            </t:zone>
</t:form>

I have 2 methods in java: onValidateFromMyForm and onSuccessFromMyForm. Both methods called success.

But on click button "Done", I see that page in browser reloaded. I want only update zone, but do not want reload page. How I can did it?


Solution

  • Add a zone parameter to your form element:

    <t:form t:id="myForm" class="default-form dt-1" zone="myZone"/>

    By the way, if the form is within the zone to be updated, you can refer to the containing zone as "^" like this:

    <t:form t:id="myForm" class="default-form dt-1" zone="^"/>

    Without a zone parmeter, the form supports only regular, non-ajax submissions.

    http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/corelib/components/Form.html

    http://tapestry.apache.org/ajax-and-zones.html