You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by sardo <ma...@power-oasis.com> on 2012/07/19 23:29:30 UTC

Class that extends AjaxTabbedPanel does not remember selected panel on page refresh

Hi,

I have a class that extends AjaxTabbedPanel, it displays a busy indicator
while the ajax call is running (see code below). This all works fine during
these ajax calls; so a busy indicator is displayed and the tab that has been
selected is displayed correctly in the view.  However, if the page is
refreshed the first tab in the group of tabs is shown as being selected and
the app forgets which tab was previously selected.  To me it seems like the
initial page state for the tabs has been preserved and used again on
refreshing the page (a bit like it's a static model). I can't figure out
though what needs to be done to fix.

public class IndicatingAjaxTabbedPanel extends AjaxTabbedPanel {

	private static final long serialVersionUID = 1L;

	public IndicatingAjaxTabbedPanel(String id, List<ITab> tabs) {
		super(id, tabs);
	}

	@SuppressWarnings("unchecked")
	@Override
	protected WebMarkupContainer newLink(String linkId, final int index) {
		return new IndicatingAjaxFallbackLink(linkId) {
			private static final long serialVersionUID = 1L;

			@Override
			public void onClick(AjaxRequestTarget target)
                        {
				setSelectedTab(index);
				if (target != null)
				{
					target.add(IndicatingAjaxTabbedPanel.this);
				}
				onAjaxUpdate(target);
			}
		};
	}
}

Cheers.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Class-that-extends-AjaxTabbedPanel-does-not-remember-selected-panel-on-page-refresh-tp4650642.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Class that extends AjaxTabbedPanel does not remember selected panel on page refresh

Posted by Martin Grigorov <mg...@apache.org>.
The pageId is for a reason in the url.
Without it Wicket doesn't know which page contains the component (in
your case the AjaxTabbedPanel) and recreates a new page instance, thus
recreates the component too and all your state is lost.

The best way to remove the pageId is to make your page stateless. But
that would mean that you cannot use Wicket Ajax in this page, i.e. you
need to use TabbedPanel instead.

On Mon, Jul 23, 2012 at 12:01 PM, sardo <ma...@power-oasis.com> wrote:
>
>
> Good shout Martin that is the problem. I changed it to the following and now
> it's working:
>
> mountPage("/home",      HomePage.class);
>
> You know what's coming next don't you...I've now changed the behavior of the
> url so it's now:
>
> http://localhost:8080/myApp/home?3
>
> Am I stuck with this or is there a way to remove the version bits from the
> url?
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Class-that-extends-AjaxTabbedPanel-does-not-remember-selected-panel-on-page-refresh-tp4650642p4650714.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: Class that extends AjaxTabbedPanel does not remember selected panel on page refresh

Posted by sardo <ma...@power-oasis.com>.
Lucky for us there are plenty of others who would charge us the same :-)



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Class-that-extends-AjaxTabbedPanel-does-not-remember-selected-panel-on-page-refresh-tp4650642p4650720.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Class that extends AjaxTabbedPanel does not remember selected panel on page refresh

Posted by Martin Grigorov <mg...@apache.org>.
On Mon, Jul 23, 2012 at 12:45 PM, sardo <ma...@power-oasis.com> wrote:
>
>
> I think I did suggest something, "It's a shame the state has to be
> maintained by parameters in the url". You are the people responsible for the
> Wicket code I'm a customer...oh how annoying customers can be ;-)

For the budget your company gave us we believe this is the best solution :-)

>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Class-that-extends-AjaxTabbedPanel-does-not-remember-selected-panel-on-page-refresh-tp4650642p4650718.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: Class that extends AjaxTabbedPanel does not remember selected panel on page refresh

Posted by sardo <ma...@power-oasis.com>.

I think I did suggest something, "It's a shame the state has to be
maintained by parameters in the url". You are the people responsible for the
Wicket code I'm a customer...oh how annoying customers can be ;-) 



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Class-that-extends-AjaxTabbedPanel-does-not-remember-selected-panel-on-page-refresh-tp4650642p4650718.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Class that extends AjaxTabbedPanel does not remember selected panel on page refresh

Posted by Martin Grigorov <mg...@apache.org>.
On Mon, Jul 23, 2012 at 12:25 PM, sardo <ma...@power-oasis.com> wrote:
>
>
> OK thanks Martin. I'll have to raise this as an issue with my management, as
> it may have knock on affects. It's a shame the state has to be maintained by
> parameters in the url.

Either suggest something or don't whine ;-)

>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Class-that-extends-AjaxTabbedPanel-does-not-remember-selected-panel-on-page-refresh-tp4650642p4650716.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: Class that extends AjaxTabbedPanel does not remember selected panel on page refresh

Posted by sardo <ma...@power-oasis.com>.

OK thanks Martin. I'll have to raise this as an issue with my management, as
it may have knock on affects. It's a shame the state has to be maintained by
parameters in the url.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Class-that-extends-AjaxTabbedPanel-does-not-remember-selected-panel-on-page-refresh-tp4650642p4650716.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Class that extends AjaxTabbedPanel does not remember selected panel on page refresh

Posted by sardo <ma...@power-oasis.com>.

Good shout Martin that is the problem. I changed it to the following and now
it's working:

mountPage("/home", 	HomePage.class);

You know what's coming next don't you...I've now changed the behavior of the
url so it's now:

http://localhost:8080/myApp/home?3

Am I stuck with this or is there a way to remove the version bits from the
url?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Class-that-extends-AjaxTabbedPanel-does-not-remember-selected-panel-on-page-refresh-tp4650642p4650714.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Class that extends AjaxTabbedPanel does not remember selected panel on page refresh

Posted by Martin Grigorov <mg...@apache.org>.
On Mon, Jul 23, 2012 at 11:35 AM, sardo <ma...@power-oasis.com> wrote:
>
>
> BTW. The application has been ported from Wicket 1.4 to 1.5, and it did this
> in 1.4 too. So maybe the  request mapping stuff isn't an issue...

I think it is the issue.
Remove NoVersionMapper temporarily and see.

>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Class-that-extends-AjaxTabbedPanel-does-not-remember-selected-panel-on-page-refresh-tp4650642p4650712.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: Class that extends AjaxTabbedPanel does not remember selected panel on page refresh

Posted by sardo <ma...@power-oasis.com>.

BTW. The application has been ported from Wicket 1.4 to 1.5, and it did this
in 1.4 too. So maybe the  request mapping stuff isn't an issue...



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Class-that-extends-AjaxTabbedPanel-does-not-remember-selected-panel-on-page-refresh-tp4650642p4650712.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Class that extends AjaxTabbedPanel does not remember selected panel on page refresh

Posted by sardo <ma...@power-oasis.com>.
lol. Yes we are indeed tinkering with the custom request mappers. I removed
some code from the code sample above thinking at the time that it wasn't
relevant. Here's the full code (not sure if it helps with the investigation
of the problem or not but since you mentioned it I'll include it anyway): 

mount(new NoVersionMount("/home", HomePage.class));

public class NoVersionMount extends MountedMapper {
    public NoVersionMount(String path, Class<? extends
            IRequestablePage> pageClass) {
        super(path, pageClass, new PageParametersEncoder());
    }

    @Override protected void encodePageComponentInfo(Url url,
                                                     PageComponentInfo info)
{
        // do nothing so that component info does not get
        // rendered in url
    }

    @Override public Url mapHandler(IRequestHandler
                                            requestHandler) {
        if (requestHandler instanceof
                ListenerInterfaceRequestHandler) {
            return null;
        } else {
            return super.mapHandler(requestHandler);
        }
    }
}




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Class-that-extends-AjaxTabbedPanel-does-not-remember-selected-panel-on-page-refresh-tp4650642p4650711.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Class that extends AjaxTabbedPanel does not remember selected panel on page refresh

Posted by Sven Meier <sv...@meiers.net>.
Sure, a new page instance will have a fresh TabbedPanel instance.

Can you compare the URLs of your page and the one in wicket-examples.
Both have the dreaded '?0' suffix, don't they? Or are you tinkering with 
custom request mappers?

Regards
Sven

On 07/22/2012 08:26 PM, sardo wrote:
>
> I can't see any difference between the two...
>
> One thing I have noticed, is that the page's constructor is run when  I
> refresh the page. Would that have anything to do with it? The page is
> defined in the web application class:
>
> mount("/home", 	HomePage.class);
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Class-that-extends-AjaxTabbedPanel-does-not-remember-selected-panel-on-page-refresh-tp4650642p4650701.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


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


Re: Class that extends AjaxTabbedPanel does not remember selected panel on page refresh

Posted by sardo <ma...@power-oasis.com>.

I can't see any difference between the two...

One thing I have noticed, is that the page's constructor is run when  I
refresh the page. Would that have anything to do with it? The page is
defined in the web application class:

mount("/home", 	HomePage.class);



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Class-that-extends-AjaxTabbedPanel-does-not-remember-selected-panel-on-page-refresh-tp4650642p4650701.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Class that extends AjaxTabbedPanel does not remember selected panel on page refresh

Posted by Sven Meier <sv...@meiers.net>.
Please try out org.apache.wicket.examples.ajax.builtin.TabbedPanelPage in
wicket-examples.

I cannot reproduce the problem there.

Sven



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Class-that-extends-AjaxTabbedPanel-does-not-remember-selected-panel-on-page-refresh-tp4650642p4650668.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Class that extends AjaxTabbedPanel does not remember selected panel on page refresh

Posted by sardo <ma...@power-oasis.com>.

Ah yes sorry, the all important version number. It's Wicket 1.5.  

Yes, I *believe* the busy indicator isn't related.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Class-that-extends-AjaxTabbedPanel-does-not-remember-selected-panel-on-page-refresh-tp4650642p4650644.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Class that extends AjaxTabbedPanel does not remember selected panel on page refresh

Posted by Sven Meier <sv...@meiers.net>.
Which Wicket version?

The busy indicator is unrelated to the problem, is it?

Regards
Sven

On 07/19/2012 11:29 PM, sardo wrote:
> Hi,
>
> I have a class that extends AjaxTabbedPanel, it displays a busy indicator
> while the ajax call is running (see code below). This all works fine during
> these ajax calls; so a busy indicator is displayed and the tab that has been
> selected is displayed correctly in the view.  However, if the page is
> refreshed the first tab in the group of tabs is shown as being selected and
> the app forgets which tab was previously selected.  To me it seems like the
> initial page state for the tabs has been preserved and used again on
> refreshing the page (a bit like it's a static model). I can't figure out
> though what needs to be done to fix.
>
> public class IndicatingAjaxTabbedPanel extends AjaxTabbedPanel {
>
> 	private static final long serialVersionUID = 1L;
>
> 	public IndicatingAjaxTabbedPanel(String id, List<ITab> tabs) {
> 		super(id, tabs);
> 	}
>
> 	@SuppressWarnings("unchecked")
> 	@Override
> 	protected WebMarkupContainer newLink(String linkId, final int index) {
> 		return new IndicatingAjaxFallbackLink(linkId) {
> 			private static final long serialVersionUID = 1L;
>
> 			@Override
> 			public void onClick(AjaxRequestTarget target)
>                          {
> 				setSelectedTab(index);
> 				if (target != null)
> 				{
> 					target.add(IndicatingAjaxTabbedPanel.this);
> 				}
> 				onAjaxUpdate(target);
> 			}
> 		};
> 	}
> }
>
> Cheers.
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Class-that-extends-AjaxTabbedPanel-does-not-remember-selected-panel-on-page-refresh-tp4650642.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



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