e.g.

public class AjaxEvent
{
        private Set<Component> listeners = new HashSet<Component>();

        public void register(Component listener)
        {
                listeners.add(listener);
        }

        public void fire(AjaxRequestTarget request)
        {
                for (Component listener : listeners)
                        request.addComponent(listener);
        }
}

On Thu, May 8, 2008 at 6:07 PM, Scott Swank <[EMAIL PROTECTED]> wrote:
> >  Ajax
>  >
>  >  3. Now im working with more Ajax. What is a good inter component
>  >  communication scheme? Swing has its listeners, but in wicket i tend to 
> call
>  >  methods on dependent components from ajax event handlers. Is this a good
>  >  approach - (it atleast dont feel so good)?
>
>  I try to have my components just be a view of their model.  Then it's
>  just a matter of setting the model(s) appropriately and refreshing the
>  components.
>
>  Alternately, create a AjaxEvent class that you subclass to represent
>  each of the actions in which you're interested.  Put a collection of
>  those on your Page.  Then have allow each component to register itself
>  as a listener of an event.  Then an ajax call would result in
>  SomeAjaxEvent.fire(AjaxTargetRequest) and that would in turn call
>  addComponent() for each registered listener component.
>
>  - Scott
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to