Willow selections

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Willow selections

eftomi
Hi,

when using selection components in Willow (like single and multiple selection lists), should #currentSelection and #currentSelectionIfNone: be called only within their own affordances? If I use these messages from onTrigger evaluate: of other components (e. g. buttons), then I don't get any selected object back.

Thanks and best wishes,
Tomaz


Reply | Threaded
Open this post in threaded view
|

Re: Willow selections

gcotelli
Hi Tomaz,

First check that your selection component is not created in every render cycle, so it can hold its state between calls. Usually components holding state must be kept in instance variables in the containing component, initialized once and rendered many times.

Second, the selection state needs to be serialized so it's available in the server. Some affordances (like #determineBehaviorByEvaluating:) applied on the selection component automatically serializes the content but others not. You can check it by looking at the affordances you're using and locating the WebInteractionCommand being applied. Each command responds to #requiresSerialization indicating if it will automatically serialize the content of the triggered component or not. (This deserves a better explanation in the docs, I will create an issue to not forget).

In case you're using an affordance not doing automatic serialization or if you want the state to be synchronized  when another component is triggered, you need to use some of the serialization affordances (check WebInteractionInterpreter). Depending on the interactivity level you want is the serialization strategy you should use.

Now in your case it depends on what you are trying to accomplish. If you want the selection to be available as soon as possible, you need to use serializeIt or serializeWithHiddenInputs if no other affordance is doing the automatic serialization when triggering the selection. If you want to do fewer server calls (and for example just send everything on a single call when a button is clicked) you need to serialize the form containing the selection components when triggering the button.

Hope it helps.
Gabriel

On Mon, Jun 8, 2020 at 4:52 AM Tomaž Turk <[hidden email]> wrote:
Hi,

when using selection components in Willow (like single and multiple selection lists), should #currentSelection and #currentSelectionIfNone: be called only within their own affordances? If I use these messages from onTrigger evaluate: of other components (e. g. buttons), then I don't get any selected object back.

Thanks and best wishes,
Tomaz


Reply | Threaded
Open this post in threaded view
|

Re: Willow selections

eftomi
Dear Gabriel,

thanks for the answer, it helps tremendously.

Best wishes,
Tomaž