What I meant was to have a unique timer behavior attached to something like

MyTimerTabbedPanel

<wicket:panel>
  <div wicket:id="timerContext"></div>
 <div wicket:id="tabs"></div>
</wicket:panel>

and you attach your timer to timerContext. Then you create an interface like

ITimerListener {
  boolean hasChnaged();
  Component getComponentToRepaint();
}

Then the (timer) components on the tabs implement this interface and
register themselves on a list of  ITimerListener you keep on
MyTimerTabbedPanel.  Then on the timer event you go through this list
and ask the (visible) components if they have to repaint themselves.
This way you timer will be always attached to the panel.

This is just an idea... that might work;-) Can you create a quickstart
(simplified project) for this?

Best,

Ernesto

On Tue, Jun 8, 2010 at 2:44 PM, Decebal Suiu <decebal.s...@asf.ro> wrote:
>
> I tried your advice and I keep the timer behavior "outside" the tab, in
> MyTabbedPanel. In the refreshable panel  I register a listener with
> MyApplication.get().addRefreshableComponent(Duration,Component). When I
> select the tab with the refreshable panel all works fine but when I switch
> the tab I received the same "PageExpiredException: No behavior listener
> found with behaviorId".
> Did I do something wrong or I misunderstood you?
>
> Below is the java code:
>
> public class MyTabbedPanel extends AjaxTabbedPanel {
>
>        private static final long serialVersionUID = 1L;
>
>        private List<AbstractAjaxTimerBehavior> ajaxTimerBehaviors;
>
>        public ImageTabbedPanel(String id, List<ITab> tabs) {
>                super(id, tabs);
>
>                ajaxTimerBehaviors = new 
> ArrayList<AbstractAjaxTimerBehavior>();
>        }
>
>       �...@override
>        protected WebMarkupContainer newLink(String linkId, final int index) {
>                List<? extends ITab> tabs = getTabs();
>
>                // check for usage of our custom class, if it is not our class,
>                // add as image empty container - this way you can use image 
> only in tabs
> you want
>                ITab currentTab = tabs.get(index);
>                if (currentTab instanceof ImageTab) {
>                        final ImageTab imageTab = (ImageTab) currentTab;
>                        return new ImageTabLink(linkId, imageTab.getImage()) {
>
>                                private static final long serialVersionUID = 
> 1L;
>
>                               �...@override
>                                public void onClick(AjaxRequestTarget target) {
>                                        removeAjaxTimerBehaviors();
>                                        clearRefreshableComponents();
>
>                                        setSelectedTab(index);
>
>                                        createAjaxTimerBehaviors();
>                                        addAjaxTimerBehaviors();
>                                        
> target.addComponent(MyTabbedPanel.this);
>                                }
>
>                        };
>                } else {
>                        WebMarkupContainer link = super.newLink(linkId, index);
>                        link.add(new 
> WebMarkupContainer("image").setVisible(false));
>
>                        return link;
>                }
>        }
>
>    private Map<Duration, List<Component>> getRefreshableComponents() {
>        return MyApplication.get().getRefreshableComponents();
>    }
>
>    private void clearRefreshableComponents() {
>        getRefreshableComponents().clear();
>    }
>
>        private void createAjaxTimerBehaviors() {
>                final Map<Duration, List<Component>> refreshableComponents =
> getRefreshableComponents();
>                Set<Duration> durations = getRefreshableComponents().keySet();
>                for (final Duration duration : durations) {
>                        AbstractAjaxTimerBehavior behavior = new
> AbstractAjaxTimerBehavior(duration) {
>
>                                private static final long serialVersionUID = 
> 1L;
>
>                               �...@override
>                                protected void onTimer(AjaxRequestTarget 
> target) {
>                                        List<Component> components = 
> refreshableComponents.get(duration);
>                                        for (Component component : components) 
> {
>                                                target.addComponent(component);
>                                        }
>                                }
>
>                        };
>                        ajaxTimerBehaviors.add(behavior);
>                }
>        }
>
>        private void addAjaxTimerBehaviors() {
>                for (IBehavior behavior : ajaxTimerBehaviors) {
>                        add(behavior);
>                }
>        }
>
>        private void removeAjaxTimerBehaviors() {
>                for (AbstractAjaxTimerBehavior behavior : ajaxTimerBehaviors) {
>                        behavior.stop();
>                        remove(behavior);
>                }
>
>                ajaxTimerBehaviors.clear();
>        }
>
> }
>
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/TabbedPanel-with-AjaxSelfUpdatingTimerBehavior-tp2243691p2247320.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to