[ 
https://issues.apache.org/jira/browse/WICKET-7144?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18057978#comment-18057978
 ] 

Johan Stuyts commented on WICKET-7144:
--------------------------------------

[~adelbene], [~bgooren]: I am working on a new attempt. It is not ready yet, 
but I would like to know what you think. So here is a PR on my own repo: 
[https://github.com/jstuyts/wicket/pull/1]

Everything works as expected. The difference in code is most visible in the use 
of `LocalDateTimeField` in 
[https://github.com/jstuyts/wicket/pull/1/changes#diff-730771ec61758e48121f425b2e820cd141f82c2e2ca09fac199ce1e34e79bbc7]

I did have to change the way to indicate that a `FormComponentPanel` wants to 
process its children, as the way `LocalDateTimeField` (and 
`ZonedDateTimeField`) are implemented do not allow using or copying the 
customizations in the anonymous class created by `newDateField(...)` of 
`AbstractDateTimeField`. These are the four ways a flag could be implemented:
 * Inheritance (the regular Wicket way): not possible with sub classes of 
`AbstractDateTimeField`,
 * A flag: possible conflicts with existing sub classes of 
`FormComponentPanel`, and allocation of a limited set of available flags.
 * An additional attribute: I do not see a lot of additional attributes for 
state.
 * A metadata key: I chose this one as this has the least impact and is the 
most compatible.

Note that the introduced method of doing Ajax with `FormComponentPanel`s 
results in excessive requests. I think this should be addressed, but that this 
should be done in a separate change as it will help prevent excessive requests 
in a lot more cases.

Please let me know if using a metadata key is fine, or that a flag or an 
additional attribute is preferred. Other comments and questions are welcome 
too. Thanks in advance.

> Improve Ajax updates of form component panels
> ---------------------------------------------
>
>                 Key: WICKET-7144
>                 URL: https://issues.apache.org/jira/browse/WICKET-7144
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket-core
>    Affects Versions: 10.4.0
>            Reporter: Johan Stuyts
>            Priority: Major
>              Labels: ajax, form
>         Attachments: WICKET-7144-1.patch
>
>
> Using AjaxFormComponentUpdatingBehavior with FormComponentPanels is 
> cumbersome and therefore error-prone: the client needs to create a sub class 
> of the panel, override the factory methods for the nested form components, 
> add a behavior to the nested components, and then call processInput() on the 
> panel.
> In case of a FormComponentPanel with more than 1 nested form component, it 
> still does not work. The behavior added to a nested component will only 
> submit the data for that nested component and not for the others. The panel 
> uses the converted input of its nested components to determine its converted 
> input (which is used to update the model). But the other components wll not 
> have converted input, so the panel cannot determine its own converted input. 
> The model of the panel will not contain the correct value when onUpdate(...) 
> of the behavior is called.
> Ajax updates of FormComponentPanels can be made more developer-friendly by:
>  * Allowing panels (or sub classes) to indicate that they want to their 
> children to process their input in an Ajax update.
>  * Modifying AjaxFormComponentUpdatingBehavior to detect FormComponentPanels 
> that have indicated that their children should process their input, and:
>  ** Enable recursive serialization in the Ajax attributes, so all data of a 
> FormComponentPanel is available in an Ajax update. 
>  ** Telling these panels to tell their children to process their input in an 
> Ajax update.
> The needed changes are attached in a patch, and can be viewed here: 
> [https://github.com/apache/wicket/compare/master...jstuyts:wicket:form-component-panel-ajax-update]
> The changes are backward compatible and won't affect existing code, unless 
> the signatures of the new methods of FormComponentPanel have been used.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to