Search code examples
ajaxtapestrypalette

Tapestry: Events from Palette component


I'm using palette components on a page and I want the available elements in two of them to change depending on what is selected in the first.

What is the best way to achieve this? Which events are thrown by the palette component, that I could listen to, adapt the palette's model and perform a zone update? I thought it would work the same way as for select components doing something like this:

void onValueChanged() {
    // do something
}

Unfortunately that doesn't work for palettes.

I'm using Tapestry 5.4-beta-6, but I guess things haven't changed that much since earlier versions.


Solution

  • I finally used the didChange element together with a similar mixin like the Observe mixin. I put a demo on Github for anyone, who is interested.

    Just a few notes:

    • I used 5.4 beta 6, it already has the necessary client side events.
    • I couldn't make it work using a Tapestry javascript module, so I still use javascriptSupport.addInitializerCall.
    • The remaining problem is, that updating the second palette with a zone update will reset any changes the user has made in this palette, since they are only kept on the client side (in a hidden field). I will still need to look into that, but it is not part of the original question.