On 06/01/2015 03:48 PM, Martin Grigorov wrote:

On Mon, Jun 1, 2015 at 3:39 PM, Urbani, Edmund <[email protected] <mailto:[email protected]>> wrote:

    Ah, of course: wicket-datetime.

    Thanks, I'll try that - though I was hoping I would not to have to work
    directly with its sub-components.

    And more out of curiosity:
    Will there be a neater way to do this in Wicket 7 (or perhaps 8)? Right
    now AJAX behaviors that can be applied to FormComponentPanels seem like a
    good idea to me. ;)


No, there is nothing about this in Wicket 7.x.
I don't think there will be something in 8.x too. We are not big fans of auto-magical functionalities. We prefer to give you the facilities (like the factory methods, visitors, etc.) and let you define your application logic.

What I'd do for your use case is to extend OnChangeAjaxBehavior, override its #updateRequestAttributes() with attributes.setChildSelector("input, select, textarea") and attributes.getDynamicExtraParameters("return collectChildrenFormElementsValues(attrs.c)") and then in onChange() read the submitted values and update the form components.
But you will need Wicket 6.x for all this...

I see. Well, maybe not "auto-magical" in the sense that Wicket takes care of that, but in the sense that the component-developer has a way to apply a behavior to a number of sub-components. Right now, I think, that is not possible by overriding add(..), because the same behavior instance cannot be assigned to multiple components AFAIK.

In my case applying the behavior to the individual fields was only part of the solution BTW. I did end up making my own version of the DateTimeField component. Changes to the hour/minutes fields would not cause the model to get updated, so I had to modify setHours() and setMinutes() and access some private stuff (so much for the sub-classing approach... :/ ).

Kind regards,
 Edmund

Reply via email to