You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Michael Wyraz <mi...@evermind.de> on 2012/09/27 11:08:08 UTC

Updating form components via ajax - should be possible with small changes to T5

Hi,

yesterday I discussed with a colleague the possibility of replacing T5 
form components (parts of a form) with ajax zone updates.
The basic problem is:
- each component registers itself as "process submission" to the form 
(via formsupport)
- the form serializes all those submissions to a hidden field "t:formdata"
- during submit the submissions are deserialized and executed
So it it not possible to change the submissions without replacing the 
whole form. There are some workarounds that allows to add new form field 
by emulating formsupport and add extra t:formdata fields to the form.

Yesterday we had an idea for a different approach which I'd like to 
discuss here. What if each form field would render it's own submission 
to it's own t:formdata field? In this case it would not require 
formsupport to register itself to the form. The field would still be 
handled by the form during submission. But the component itself could 
then simply be added or removed with ajax.

Regards,
Michael,


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


Re: Updating form components via ajax - should be possible with small changes to T5

Posted by Ivan Khalopik <ik...@gmail.com>.
When page is loaded it will render two separate hidden inputs with name
t:formdata, one for Form actions, second for Zone actions.

<form>
    <input type="hidden" name="t:formdata" value="[encoded_form_actions]"/>
    ...
    <div id="updateZone">
        <input type="hidden" name="t:formdata"
value="[encoded_zone_actions]"/>
        ...
    </div>
    ...
</form>

When Zone is refreshed it will replace its body with new one and contained
hidden input will also be updated

<form>
    <input type="hidden" name="t:formdata" value="[encoded_form_actions]"/>
    ...
    <div id="updateZone">
        <input type="hidden" name="t:formdata"
value="[encoded_new_zone_actions]"/>
        ...
    </div>
    ...
</form>

Then we will press submit button, Form component will collect t:formdata
value from all submitted hidden controls and then it will execute all
stored in this value actions.


public class Form implements ClientElement, FormValidationControl {

    ...

    private void executeStoredActions() {
        String[] values = request.getParameters(FORM_DATA);
        ...
    }

    ...

}



On Thu, Sep 27, 2012 at 5:37 PM, Michael Wyraz <mi...@evermind.de>wrote:

> Will this also apply when the zone is rendered together with the form at
> age loading?
> Or will the submissions of the elements in the zone then go to the form's
> t:formdata field?
>
>> In addition to all this FormFragment and Zone components have their own
>> implementation of FormSupport service that renders separate t:formdata
>> hidden inputs. But to use this functionality on zone you should return
>> whole Zone instead of just its body in event handler.
>>
>> Object onUpdate() {
>>      return updateZone;
>> }
>>
>> So, you have a possibility to change/delete all stored process submissions
>> for components placed inside this zone.
>>
>> On Thu, Sep 27, 2012 at 12:08 PM, Michael Wyraz
>> <mi...@evermind.de>**wrote:
>>
>>  Hi,
>>>
>>> yesterday I discussed with a colleague the possibility of replacing T5
>>> form components (parts of a form) with ajax zone updates.
>>> The basic problem is:
>>> - each component registers itself as "process submission" to the form
>>> (via
>>> formsupport)
>>> - the form serializes all those submissions to a hidden field
>>> "t:formdata"
>>> - during submit the submissions are deserialized and executed
>>> So it it not possible to change the submissions without replacing the
>>> whole form. There are some workarounds that allows to add new form field
>>> by
>>> emulating formsupport and add extra t:formdata fields to the form.
>>>
>>> Yesterday we had an idea for a different approach which I'd like to
>>> discuss here. What if each form field would render it's own submission to
>>> it's own t:formdata field? In this case it would not require formsupport
>>> to
>>> register itself to the form. The field would still be handled by the form
>>> during submission. But the component itself could then simply be added or
>>> removed with ajax.
>>>
>>> Regards,
>>> Michael,
>>>
>>>
>>> ------------------------------****----------------------------**
>>> --**---------
>>> To unsubscribe, e-mail: dev-unsubscribe@tapestry.**apa**che.org<http://apache.org>
>>> <de...@tapestry.apache.org>
>>> >
>>>
>>> For additional commands, e-mail: dev-help@tapestry.apache.org
>>>
>>>
>>>
>>
>
> --
> Mit freundlichen Grüßen / Regards
>
> Michael Wyraz
>
> evermind GmbH
> Schorlemmerstraße 1
> 04155 Leipzig
>
> Tel.:       +49 (0)341-25 39 66 - 0
> Fax:        +49 (0)341-25 39 66 - 1
> Funk:       +49 (0)177-73 00 00 3
> E-Mail:     michael.wyraz@evermind.de
>
> HRB: 21586
> Amtsgericht Leipzig
>
> Geschäftsführer:
> Christoph Klemm
> Thomas Grünert
> Michael Wyraz
>
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: dev-unsubscribe@tapestry.**apache.org<de...@tapestry.apache.org>
> For additional commands, e-mail: dev-help@tapestry.apache.org
>
>


-- 
BR
Ivan

Re: Updating form components via ajax - should be possible with small changes to T5

Posted by Michael Wyraz <mi...@evermind.de>.
Will this also apply when the zone is rendered together with the form at 
age loading?
Or will the submissions of the elements in the zone then go to the 
form's t:formdata field?
> In addition to all this FormFragment and Zone components have their own
> implementation of FormSupport service that renders separate t:formdata
> hidden inputs. But to use this functionality on zone you should return
> whole Zone instead of just its body in event handler.
>
> Object onUpdate() {
>      return updateZone;
> }
>
> So, you have a possibility to change/delete all stored process submissions
> for components placed inside this zone.
>
> On Thu, Sep 27, 2012 at 12:08 PM, Michael Wyraz
> <mi...@evermind.de>wrote:
>
>> Hi,
>>
>> yesterday I discussed with a colleague the possibility of replacing T5
>> form components (parts of a form) with ajax zone updates.
>> The basic problem is:
>> - each component registers itself as "process submission" to the form (via
>> formsupport)
>> - the form serializes all those submissions to a hidden field "t:formdata"
>> - during submit the submissions are deserialized and executed
>> So it it not possible to change the submissions without replacing the
>> whole form. There are some workarounds that allows to add new form field by
>> emulating formsupport and add extra t:formdata fields to the form.
>>
>> Yesterday we had an idea for a different approach which I'd like to
>> discuss here. What if each form field would render it's own submission to
>> it's own t:formdata field? In this case it would not require formsupport to
>> register itself to the form. The field would still be handled by the form
>> during submission. But the component itself could then simply be added or
>> removed with ajax.
>>
>> Regards,
>> Michael,
>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: dev-unsubscribe@tapestry.**apache.org<de...@tapestry.apache.org>
>> For additional commands, e-mail: dev-help@tapestry.apache.org
>>
>>
>


-- 
Mit freundlichen Grüßen / Regards

Michael Wyraz

evermind GmbH
Schorlemmerstraße 1
04155 Leipzig

Tel.:       +49 (0)341-25 39 66 - 0
Fax:        +49 (0)341-25 39 66 - 1
Funk:       +49 (0)177-73 00 00 3
E-Mail:     michael.wyraz@evermind.de

HRB: 21586
Amtsgericht Leipzig

Geschäftsführer:
Christoph Klemm
Thomas Grünert
Michael Wyraz


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


Re: Updating form components via ajax - should be possible with small changes to T5

Posted by Ivan Khalopik <ik...@gmail.com>.
In addition to all this FormFragment and Zone components have their own
implementation of FormSupport service that renders separate t:formdata
hidden inputs. But to use this functionality on zone you should return
whole Zone instead of just its body in event handler.

Object onUpdate() {
    return updateZone;
}

So, you have a possibility to change/delete all stored process submissions
for components placed inside this zone.

On Thu, Sep 27, 2012 at 12:08 PM, Michael Wyraz
<mi...@evermind.de>wrote:

> Hi,
>
> yesterday I discussed with a colleague the possibility of replacing T5
> form components (parts of a form) with ajax zone updates.
> The basic problem is:
> - each component registers itself as "process submission" to the form (via
> formsupport)
> - the form serializes all those submissions to a hidden field "t:formdata"
> - during submit the submissions are deserialized and executed
> So it it not possible to change the submissions without replacing the
> whole form. There are some workarounds that allows to add new form field by
> emulating formsupport and add extra t:formdata fields to the form.
>
> Yesterday we had an idea for a different approach which I'd like to
> discuss here. What if each form field would render it's own submission to
> it's own t:formdata field? In this case it would not require formsupport to
> register itself to the form. The field would still be handled by the form
> during submission. But the component itself could then simply be added or
> removed with ajax.
>
> Regards,
> Michael,
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: dev-unsubscribe@tapestry.**apache.org<de...@tapestry.apache.org>
> For additional commands, e-mail: dev-help@tapestry.apache.org
>
>


-- 
BR
Ivan