Wicket
  1. Wicket
  2. WICKET-5339

Broadcast.EXACT does not notify Behaviors of target Component

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.11.0, 7.0.0-M1
    • Component/s: wicket
    • Labels:
      None

      Description

      As described in IRC I want to "answer" an event by sending an event back to events source using broadcast exact. But that answer should be handled by a Behavior on the component.

      When using any other broadcast type behaviors will be notified too. But not when using exact. Since Behavior does not implement IEventSink I cannot address the behavior directly instead of the component. Even if that works I think it wont be a good practice.

      I'm not sure if this is a bug, since it's a philosophic question if exact broadcast should include behaviors of a component.

      1. broadcast-exact.patch
        11 kB
        Martin Grigorov
      2. event_quickstart.zip
        60 kB
        Martin Sturm
      3. event_quickstart-working.tgz
        31 kB
        Martin Grigorov

        Issue Links

          Activity

          Martin Sturm created issue -
          Hide
          Martin Sturm added a comment -

          Quick start that doesn"t work for me.

          Show
          Martin Sturm added a comment - Quick start that doesn"t work for me.
          Martin Sturm made changes -
          Field Original Value New Value
          Attachment event_quickstart.zip [ 12601149 ]
          Martin Grigorov made changes -
          Assignee Martin Grigorov [ mgrigorov ]
          Hide
          Martin Grigorov added a comment -

          Here is a modified quickstart that workarounds the problem

          The main problem is that Behavior is I*ComponentAware*EventSink, and there is no Component to pass to #onEvent(Component, IEvent).
          So I made your Behavior implementing IEventSink.

          Show
          Martin Grigorov added a comment - Here is a modified quickstart that workarounds the problem The main problem is that Behavior is I*ComponentAware*EventSink, and there is no Component to pass to #onEvent(Component, IEvent). So I made your Behavior implementing IEventSink.
          Martin Grigorov made changes -
          Attachment event_quickstart-working.tgz [ 12601337 ]
          Hide
          Martin Grigorov added a comment -

          A patch that allows to send events to specific IComponentAwareEventSink

          Show
          Martin Grigorov added a comment - A patch that allows to send events to specific IComponentAwareEventSink
          Martin Grigorov made changes -
          Attachment broadcast-exact.patch [ 12601352 ]
          Hide
          Martin Sturm added a comment - - edited

          The patch seems to be ok. I would like it more if my answering component must not know the behaviors implementation or class. Otherwise I could do:

          ((Component)event.getSource()).getBehaviors(MagicBehavior.class).get( ? ).doMagicStuff(...)

          So maybe Behavior needs to implement IEventSource so that I can send the answer directly to the Behavior which I will get from event.getSource() ... ?

          Show
          Martin Sturm added a comment - - edited The patch seems to be ok. I would like it more if my answering component must not know the behaviors implementation or class. Otherwise I could do: ((Component)event.getSource()).getBehaviors(MagicBehavior.class).get( ? ).doMagicStuff(...) So maybe Behavior needs to implement IEventSource so that I can send the answer directly to the Behavior which I will get from event.getSource() ... ?
          Hide
          Martin Sturm added a comment -

          I can pass the Behavior - thats waiting for answer - as payload or attribute of my payload to ...

          Show
          Martin Sturm added a comment - I can pass the Behavior - thats waiting for answer - as payload or attribute of my payload to ...
          Hide
          Martin Grigorov added a comment -

          From now on if the sink is a Component instance then all its behaviors are notified as well.

          Show
          Martin Grigorov added a comment - From now on if the sink is a Component instance then all its behaviors are notified as well.
          Martin Grigorov made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 7.0.0 [ 12322958 ]
          Fix Version/s 6.11.0 [ 12324874 ]
          Resolution Fixed [ 1 ]
          Martin Grigorov made changes -
          Remote Link This issue links to "Mail discussion about the desicion (Web Link)" [ 12624 ]
          Hide
          Martin Sturm added a comment - - edited

          Application.get().getFrameworkSettings().add(new IEventDispatcher() {
          @Override
          public void dispatchEvent(Object sink, IEvent<?> event, Component component) {
          if (sink instanceof Component && Broadcast.EXACT.equals(event.getType())){
          Component componentSink = (Component) sink;
          List<? extends Behavior> behaviors = componentSink.getBehaviors();
          for (Behavior behavior : behaviors)

          { behavior.onEvent(componentSink, event); }

          }
          }
          });

          Did it for me as workaround until release.

          Show
          Martin Sturm added a comment - - edited Application.get().getFrameworkSettings().add(new IEventDispatcher() { @Override public void dispatchEvent(Object sink, IEvent<?> event, Component component) { if (sink instanceof Component && Broadcast.EXACT.equals(event.getType())){ Component componentSink = (Component) sink; List<? extends Behavior> behaviors = componentSink.getBehaviors(); for (Behavior behavior : behaviors) { behavior.onEvent(componentSink, event); } } } }); Did it for me as workaround until release.
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          2d 18h 36m 1 Martin Grigorov 06/Sep/13 08:33

            People

            • Assignee:
              Martin Grigorov
              Reporter:
              Martin Sturm
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development