<?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; Java</title>
	<atom:link href="http://www.volkomenjuist.nl/blog/category/technology/java-technology/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.volkomenjuist.nl/blog</link>
	<description>Juist! Volkomen Juist!</description>
	<lastBuildDate>Mon, 18 Jul 2011 20:00:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to check whether Javascript is enabled in Wicket</title>
		<link>http://www.volkomenjuist.nl/blog/2010/01/19/how-to-check-whether-javascript-is-enabled-in-wicket/</link>
		<comments>http://www.volkomenjuist.nl/blog/2010/01/19/how-to-check-whether-javascript-is-enabled-in-wicket/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 21:31:49 +0000</pubDate>
		<dc:creator>Stefanovich</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Wicket]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.volkomenjuist.nl/blog/?p=337</guid>
		<description><![CDATA[It is possible, via Wicket, to gather a lot of information regarding the browser/system of your visitor. If you want this you can also turn on some extended information (like javascript is enabled) via the following code: This method works via a redirect to the BrowserInfoPage and finally it goes to your &#8216;original&#8217; page. Because [...]]]></description>
			<content:encoded><![CDATA[<p>It is possible, via Wicket, to gather a lot of information regarding the browser/system of your visitor. If you want this you can also turn on some extended information (like javascript is enabled) via the following code:</p>
<pre class="brush: java; title: ; notranslate">
getRequestCycleSettings().setGatherExtendedBrowserInfo(true);
</pre>
<p>This method works via a redirect to the BrowserInfoPage and finally it goes to your &#8216;original&#8217; page. Because of this it is possible that you see the BrowserInfoPage very shortly especially on slow computers/browsers or internet connections. But what if you don&#8217;t want this and only want to know whether Javascript is enabled? Please read on&#8230;</p>
<p><span id="more-337"></span></p>
<p>When the page is rendered it does a call(back) to Wicket. If  this callback is possible then we can assume Javascipt is enabled.</p>
<h4>How to setup?</h4>
<p>e.g. Login.java (Page)</p>
<pre class="brush: java; title: ; notranslate">
final WebClientInfo clientInfo = (WebClientInfo) WebRequestCycle.get().getClientInfo();
final AbstractDefaultAjaxBehavior behavior = new AbstractDefaultAjaxBehavior()
   @Override
   protected void respond(final AjaxRequestTarget target) {
        if (target != null) {
            clientInfo.getProperties().setJavaEnabled(true);
        }
   }
};
add(behavior);

Label jsEnabledScript = new Label(&quot;jsEnabledScript&quot;, &quot;wicketAjaxGet('&quot;+ behavior.getCallbackUrl() +&quot;', function() { }, function() { });&quot;);
jsEnabledScript.setEscapeModelStrings(false); // do not HTML escape JavaScript code
add(jsEnabledScript);
</pre>
<p>And in your HTML</p>
<pre class="brush: plain; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot; wicket:id=&quot;jsEnabledScript&quot;&gt;&lt;/script&gt;
</pre>
<h4>How to use?</h4>
<pre class="brush: java; title: ; notranslate">
final WebClientInfo clientInfo = (WebClientInfo) WebRequestCycle.get().getClientInfo();
boolean javascriptEnabled = clientInfo.getProperties().isJavaEnabled();
</pre>
<address>Note1: Put this code on one of your first pages like your login page, to do this callback only once.<br />
Note2: I really don&#8217;t have a clue why they called it isJavaEnabled() because Java != Javascript&#8230;.</address>
 <img src="http://www.volkomenjuist.nl/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=337" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://www.volkomenjuist.nl/blog/2010/01/19/how-to-check-whether-javascript-is-enabled-in-wicket/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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; title: ; notranslate">
/**
	 * {@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/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy52b2xrb21lbmp1aXN0Lm5sL2Jsb2cvMjAwOS8xMS8wNS9hamF4dGFiYmVkcGFuZWwtaW4tY29tYmluYXRpb24td2l0aC1hamF4bGF6eWxvYWRwYW5lbC8jbW9yZS0zMjI=">AjaxTabbedPanel and LazyLoading</a></p>
 <img src="http://www.volkomenjuist.nl/blog/wp-content/plugins/wordpress-feed-statistics/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>4</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; title: ; notranslate">
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; title: ; notranslate">
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; title: ; notranslate">
  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; title: ; notranslate">
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/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2phdmF0aG91Z2h0cy5jYXBlc3VnYXJiaXJkLmNvbS8yMDA3LzExL2FqYXgtdGFiYmVkLXBhbmVsLXdpdGgtbGF6eS1sb2FkaW5nLmh0bWw=" target=\"_blank\">here</a></p>
 <img src="http://www.volkomenjuist.nl/blog/wp-content/plugins/wordpress-feed-statistics/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>
		<item>
		<title>Hibernate SQL logging</title>
		<link>http://www.volkomenjuist.nl/blog/2009/08/13/hibernate-sql-logging/</link>
		<comments>http://www.volkomenjuist.nl/blog/2009/08/13/hibernate-sql-logging/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 14:14:46 +0000</pubDate>
		<dc:creator>Stefanovich</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Log4j]]></category>
		<category><![CDATA[Prepared statement]]></category>

		<guid isPermaLink="false">http://www.volkomenjuist.nl/blog/?p=298</guid>
		<description><![CDATA[When you turn on Hibernate&#8217;s SQL&#160;logging during Java development (e.g. log4j.logger.org.hibernate.SQL = debug, console), you won&#8217;t see values (only a ?) which will be/are used in a query. e.g. Now turn on some extra logging (log4j.properties): Now you&#8217;ll see some extra information like the type (StringType / EnumType / etc.) and the value: Note: When [...]]]></description>
			<content:encoded><![CDATA[<p>When you turn on Hibernate&#8217;s SQL&nbsp;logging during Java development (e.g. log4j.logger.org.hibernate.SQL = debug, console), you won&#8217;t see values (only a ?) which will be/are used in a query.<br />
e.g.</p>
<pre class="brush: plain; title: ; notranslate">
select this_.id as ID113_4_ ........ from INCOMINGMESSAGE ... where this_.STATUS=? and this_.FOO=?
</pre>
<p>Now turn on some extra logging (log4j.properties):</p>
<pre class="brush: plain; title: ; notranslate">
log4j.logger.org.hibernate.type = trace, console
</pre>
<p>Now you&#8217;ll see some extra information like the type (StringType / EnumType / etc.) and the value:</p>
<pre class="brush: plain; title: ; notranslate">
select this_.id as ID113_4_ ........ from INCOMINGMESSAGE ... where this_.STATUS=? and this_.FOO=?
DEBUG org.hibernate.type.EnumType  - Binding 'UNHANDLED' to parameter: 1
DEBUG org.hibernate.type.StringType  - Binding 'Bar' to parameter: 2
</pre>
<p>Note: When your application uses big queries then you&#8217;ll get a lot of extra logging\!</p>
 <img src="http://www.volkomenjuist.nl/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=298" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://www.volkomenjuist.nl/blog/2009/08/13/hibernate-sql-logging/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

