<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>VolkomenJuist.nl &#187; AjaxTabbedPanel</title>
	<atom:link href="http://www.volkomenjuist.nl/blog/tag/ajaxtabbedpanel/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.volkomenjuist.nl/blog</link>
	<description>Juist! Volkomen Juist!</description>
	<lastBuildDate>Mon, 08 Mar 2010 19:58:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>AjaxTabbedPanel &#8211; Store state when switching tabs</title>
		<link>http://www.volkomenjuist.nl/blog/2009/12/01/ajaxtabbedpanel-store-state-when-switching-tabs/</link>
		<comments>http://www.volkomenjuist.nl/blog/2009/12/01/ajaxtabbedpanel-store-state-when-switching-tabs/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 21:48:09 +0000</pubDate>
		<dc:creator>Stefanovich</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Wicket]]></category>
		<category><![CDATA[AjaxTabbedPanel]]></category>

		<guid isPermaLink="false">http://www.volkomenjuist.nl/blog/?p=331</guid>
		<description><![CDATA[Normally when you switch tabs of an AjaxTabbedPanel it won&#8217;t store the state of all your input fields. If you do want this, without pressing a save button, you have to override the newLink(String linkId, final int index) method of the AjaxTabbedPanel class and use an AjaxSubmitLink instead of the default AjaxFallbackLink. Now all values [...]]]></description>
			<content:encoded><![CDATA[<p>Normally when you switch tabs of an AjaxTabbedPanel it won&#8217;t store the state of all your input fields. If you do want this, without pressing a save button, you have to override the <code>newLink(String linkId, final int index)</code> method of the AjaxTabbedPanel class and use an AjaxSubmitLink instead of the default AjaxFallbackLink. Now all values will be stored in the model (not saved to the database). </p>
<p>Keep in mind that all Wicket validations will be validated, so we have to take care of the FeedbackPanel (refreshing) as well.</p>
<p><span id="more-331"></span><br />
Example:</p>
<pre class="brush: java;">
/**
	 * {@inheritDoc}
	 */
	@Override
	protected WebMarkupContainer newLink(String linkId, final int index) {

			return new AjaxSubmitLink(linkId, m_form) {

			@Override
			protected void onSubmit(AjaxRequestTarget target, Form&lt;?&gt; form) {
				setSelectedTab(index);
				if (target != null) {
					target.addComponent(TabbedComponent.this);
				}
				onAjaxUpdate(target);
			}

			@Override
			protected void onError(AjaxRequestTarget target, Form&lt;?&gt; form) {
				target.addComponent(((FeedbackAware) getPage()).getFeedbackPanel());
			}
		};
	}
</pre>
<p>See also my other blog about the <a href="http://www.volkomenjuist.nl/blog/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3d3dy52b2xrb21lbmp1aXN0Lm5sL2Jsb2cvMjAwOS8xMS8wNS9hamF4dGFiYmVkcGFuZWwtaW4tY29tYmluYXRpb24td2l0aC1hamF4bGF6eWxvYWRwYW5lbC8jbW9yZS0zMjI=">AjaxTabbedPanel and LazyLoading</a></p>
 <img src="http://www.volkomenjuist.nl/blog/wp-content/plugins/feed-statistics.php?view=1&post_id=331" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://www.volkomenjuist.nl/blog/2009/12/01/ajaxtabbedpanel-store-state-when-switching-tabs/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>AjaxTabbedPanel in combination with AjaxLazyLoadPanel</title>
		<link>http://www.volkomenjuist.nl/blog/2009/11/05/ajaxtabbedpanel-in-combination-with-ajaxlazyloadpanel/</link>
		<comments>http://www.volkomenjuist.nl/blog/2009/11/05/ajaxtabbedpanel-in-combination-with-ajaxlazyloadpanel/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 22:14:57 +0000</pubDate>
		<dc:creator>Stefanovich</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Wicket]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[AjaxLazyLoadPanel]]></category>
		<category><![CDATA[AjaxTabbedPanel]]></category>

		<guid isPermaLink="false">http://www.volkomenjuist.nl/blog/?p=322</guid>
		<description><![CDATA[Wicket (extensions) offers a AjaxTabbedPanel to take care of your tabs. The constructor of the AjaxTabbedPanel expects a wicket id (obviously) and a list of ITabs. The implementation of this interface should return the panel via getPanel(String panelId) which will be the &#8216;actual&#8217; tab. Out-of-the-box Wicket (extensions) offers an abstract implementation of this interface (AbstractTab). [...]]]></description>
			<content:encoded><![CDATA[<p>Wicket (extensions) offers a AjaxTabbedPanel to take care of your tabs. The constructor of the AjaxTabbedPanel expects a wicket id (obviously) and a list of ITabs. The implementation of this interface should return the panel via <code>getPanel(String panelId)</code> which will be the &#8216;actual&#8217; tab. Out-of-the-box Wicket (extensions) offers an abstract implementation of this interface (AbstractTab).</p>
<p>What I want to achieve is that an AjaxIndicator (loading image) will be shown on the place were the actual panel will come till it is completely loaded. Especially when you have a lot of components to render this can be handy. See image below.</p>
<div id="attachment_324" class="wp-caption aligncenter" style="width: 506px"><img class="size-full wp-image-324" title="example" src="http://www.volkomenjuist.nl/blog/wp-content/uploads/2009/11/example.png" alt="Example" width="496" height="200" /><p class="wp-caption-text">Example</p></div>
<p><span id="more-322"></span><br />
My solution was to create a class (AbstractLazyLoadTab) on top of the AbstractTab (implements ITab) which will take care of this. It will use the AjaxLazyLoadPanel.</p>
<pre class="brush: java;">
public abstract class AbstractLazyLoadTab extends AbstractTab {
         //removed some lines

	@Override
	public Panel getPanel(String panelId) {
		return new AjaxLazyLoadPanel(panelId){

			private static final long serialVersionUID = 1L;

			@Override
			public Component getLazyLoadComponent(String markupId) {
				return getLazyLoadPanel(final String markupId);
			}
		};
	}

        public abstract Panel getLazyLoadPanel(final String markupId);
}
</pre>
<p>Now you can use this class as you normally would do when you use AbstractTab.</p>
<p>When your page (or components higher in the hierarchy) implements IAjaxIndicatorAware to show another loading layer it is possible that you now have two loading layers on top of each other. One on the tab and one which will e.g. block the whole page. To avoid that I created an other class which extends the AjaxTabbedPanel and implements the IAjaxIndicatorAware interface.</p>
<pre class="brush: java;">
public class TabbedComponent extends AjaxTabbedPanel implements IAjaxIndicatorAware{
         //removed some lines
        @Override
	public String getAjaxIndicatorMarkupId() {
		//Our tab will take care of the loading layer, so return null.
		return null;
	}
}
</pre>
<p>Now you can use the classes like this:</p>
<pre class="brush: java;">
  List&lt;ITab&gt; tabs=new ArrayList&lt;ITab&gt;();
    tabs.add(new AbstractLazyLoadTab(new Model(&quot;first tab&quot;)) {
        public Panel getLazyLoadPanel(String panelId) {
           return new TabPanel1(panelId);
        }
    });

    add(new TabbedComponent(&quot;tabs&quot;, tabs)
</pre>
</pre>
<h2>Another solution</h2>
<p>If you prefer to have a waiting icon on the right side of the tab itself, you can override the newLink method of AjaxTabbedPanel and use the IndicatingAjaxFallbackLink instead of the AjaxFallbackLink. You will probably have to add the following code to your css file.</p>
<pre class="brush: css;">
span.wicket-ajax-indicator {
float: left;
}
</pre>
<p>More information about this solution please click <a href="http://www.volkomenjuist.nl/blog/wp-content/plugins/feed-statistics.php?url=aHR0cDovL2phdmF0aG91Z2h0cy5jYXBlc3VnYXJiaXJkLmNvbS8yMDA3LzExL2FqYXgtdGFiYmVkLXBhbmVsLXdpdGgtbGF6eS1sb2FkaW5nLmh0bWw=" target=\"_blank\">here</a></p>
 <img src="http://www.volkomenjuist.nl/blog/wp-content/plugins/feed-statistics.php?view=1&post_id=322" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://www.volkomenjuist.nl/blog/2009/11/05/ajaxtabbedpanel-in-combination-with-ajaxlazyloadpanel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
