<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Java Thoughts]]></title><description><![CDATA[Just another Java blog.]]></description><link>https://javathought.github.io</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Mar 2017 22:25:27 GMT</lastBuildDate><atom:link href="https://javathought.github.io/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Heroku : Memo for postgresql]]></title><description><![CDATA[<div class="paragraph">
<p>A little memo to configuration for local testing play2 application develop for Heroku with a PostgreSQL database.</p>
</div>
<div class="paragraph">
<p>As the documentation on heroku site didn&#8217;t work, here is the <code>DATABASE_URL</code> value I use on my env.</p>
</div>
<div class="paragraph">
<p><code>export DATABASE_URL=jdbc:postgresql://localhost/$(whoami)</code></p>
</div>
<div class="paragraph">
<p>And to manually start a local PostgreSQL database (if not automatically started)</p>
</div>
<div class="paragraph">
<p><code>pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start</code></p>
</div>]]></description><link>https://javathought.github.io/2016/12/12/Heroku-Memo-for-postgresql.html</link><guid isPermaLink="true">https://javathought.github.io/2016/12/12/Heroku-Memo-for-postgresql.html</guid><category><![CDATA[play framework]]></category><category><![CDATA[ heroku]]></category><category><![CDATA[ postgresql]]></category><pubDate>Mon, 12 Dec 2016 00:00:00 GMT</pubDate></item><item><title><![CDATA[Living documentation : a maven plugin]]></title><description><![CDATA[<div class="paragraph">
<p>After DevoxxFr 2016 and the talk from Cyrille Martraire (<a href="cyriux"><a href="https://twitter.com/cyriux" class="bare">https://twitter.com/cyriux</a></a>) I decided to implement the principles on my projects and began to code documentation generators based on the source publish by Cyrille on github.
So did Benoît Prioux (<a href="cyriux"><a href="https://twitter.com/binout" class="bare">https://twitter.com/binout</a></a>) the same talk from Cyrille at Bdx/IO 2015. And he made a talk of his living documenation toolbox (<a href="https://binout.github.io/bdxio-2016/livingdoc-toolbox.pdf" class="bare">https://binout.github.io/bdxio-2016/livingdoc-toolbox.pdf</a>) at Bdx/IO 2016.</p>
</div>
<div class="paragraph">
<p>Benoît initiated a github organisation with "A curated list of stuff about Awesome Living Documentation" and a maven plugin. And I joined him, and Cyrille too. So we&#8217;re developing a maven plugin implementing Cyrille&#8217;s principles for living documentation. Cyrille gave is repo <code>dot-diagram</code>, which is a dependency for living-documentation to the organisation.</p>
</div>
<div class="paragraph">
<p>I also recommend link:Cyrille&#8217;s book[<a href="https://leanpub.com/livingdocumentation" class="bare">https://leanpub.com/livingdocumentation</a>]. You can also see link:his talk at Devoxx 2016 on YouTube[<a href="https://www.youtube.com/watch?v=Tw-wcps7WqU" class="bare">https://www.youtube.com/watch?v=Tw-wcps7WqU</a>].</p>
</div>]]></description><link>https://javathought.github.io/2016/11/16/Living-documentation-a-maven-plugin.html</link><guid isPermaLink="true">https://javathought.github.io/2016/11/16/Living-documentation-a-maven-plugin.html</guid><category><![CDATA[java]]></category><category><![CDATA[ maven]]></category><category><![CDATA[ plugin]]></category><category><![CDATA[ documentation]]></category><pubDate>Wed, 16 Nov 2016 00:00:00 GMT</pubDate></item><item><title><![CDATA[Pokemon Go and developer mode on android (make it run on Wiko Highway 4G) : fictive positions]]></title><description><![CDATA[<div class="paragraph">
<p>Pokemon Go is available in France and I started plying with, very well on LG G3.</p>
</div>
<div class="paragraph">
<p>But my wife can&#8217;t play on her Wiko Highway 4G, the game "was not" able to locate the phone by GPS. I didn&#8217;t found why until I asked myself
and try to "hack" the game on my phone with "devloper mode" and "fictive positions". The result is clear : the developers have well done their work and detect the
activation of the "fictive positions" in the developer mode. So you can&#8217;t play and found pokemons.</p>
</div>
<div class="paragraph">
<p>As the result was the same on the wiko, I suspected the "fictive positions" were enabled by default on that phone. An it&#8217;s the case :</p>
</div>
<div class="paragraph">
<p>I activated the developer mode (go in the parameters &gt; about the phone &gt; click 4 times on the "build number"), then go back and enter in the "developer mode" new menu. The "fictives positions" were activated by default. So I unchecked the mark and retry the game.</p>
</div>
<div class="paragraph">
<p>And tada, the game works well now :D</p>
</div>]]></description><link>https://javathought.github.io/2016/07/25/Pokemon-Go-and-developer-mode-on-android-make-it-run-on-Wiko-Highway-4G-fictive-positions.html</link><guid isPermaLink="true">https://javathought.github.io/2016/07/25/Pokemon-Go-and-developer-mode-on-android-make-it-run-on-Wiko-Highway-4G-fictive-positions.html</guid><category><![CDATA[pokemon go]]></category><category><![CDATA[ android]]></category><category><![CDATA[ wiko]]></category><category><![CDATA[ higway]]></category><pubDate>Mon, 25 Jul 2016 00:00:00 GMT</pubDate></item><item><title><![CDATA[Migrate blog from wordpress to github pages with hubpress]]></title><description><![CDATA[<div class="paragraph">
<p>This is done : I&#8217;ve migrated my blog from wordpress.com to gh-pages. It&#8217;s under <a href="http://hubpress.io/">hubpress</a>.</p>
</div>
<div class="paragraph">
<p>I&#8217;ve it with the help of this <a href="https://github.com/binout/wordpress-exit">conversion tool</a>, but <a href="https://github.com/javathought/wordpress-exit">modified it</a> a little to add :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>management of tags (line :hp-tags are generated, not the case in the original tool)</p>
</li>
<li>
<p>management of images link (there are modified ot link to images if there are also migration to images folder on github)</p>
</li>
<li>
<p>management of blocks of codes (those blocks are modified to generate [source,&lt;langage&gt;] markup, not done before</p>
</li>
<li>
<p>modify the export to import the comments in <a href="https://disqus.com/">disqus</a> with threads linking to gh-pages (and generate link in hubpress format : ended with .html when wordpress posts have no extension.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The tool is not perfect but as it has to be used only one time, it&#8217;s enough to migrate the blog with less manually operations after the migration :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>some posts url are not the same on special characters in titles between wordpress and hubpress (for example 2/3 in title will have a 2-3 url in wordpress and 23 in hubpress: you&#8217;ll have to modify those (you can use disqus mapping tool : <a href="https://&lt;account&gt;.disqus.com/admin/tools/migrate-map/?p=migrate" class="bare">https://&lt;account&gt;.disqus.com/admin/tools/migrate-map/?p=migrate</a>).</p>
</li>
<li>
<p>not all images are recognized</p>
</li>
<li>
<p>this is more a hubpress bug, but my last version for managing source code blocks, hubpress freezes on admin page if I push the generated asciidoc pages. I&#8217;ll have to manually create a post and copy-paste the generated post. It&#8217;s still faster to convert those posts with the last version rather then pushing files generated with previous version.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The last thing to do is to log in your hubpress admin page and publish your posts one by one, and the migration is done.</p>
</div>]]></description><link>https://javathought.github.io/2015/11/11/Migrate-blog-from-wordpress-to-github-pages-with-hubpress.html</link><guid isPermaLink="true">https://javathought.github.io/2015/11/11/Migrate-blog-from-wordpress-to-github-pages-with-hubpress.html</guid><category><![CDATA[blog]]></category><category><![CDATA[ wordpress]]></category><category><![CDATA[ gh-pages]]></category><category><![CDATA[ github]]></category><category><![CDATA[ hubpress]]></category><pubDate>Wed, 11 Nov 2015 00:00:00 GMT</pubDate></item><item><title><![CDATA[Migrating to HubPress]]></title><description><![CDATA[<div class="paragraph">
<p>Hi, I&#8217;m migrating my blog to gh-pages with <a href="http://hubpress.io" class="bare">http://hubpress.io</a>. My next ticket will be about the migration from wordpress (hope I&#8217;ll success).</p>
</div>]]></description><link>https://javathought.github.io/2015/02/12/Migrating-to-HubPress.html</link><guid isPermaLink="true">https://javathought.github.io/2015/02/12/Migrating-to-HubPress.html</guid><category><![CDATA[blogging]]></category><pubDate>Thu, 12 Feb 2015 00:00:00 GMT</pubDate></item><item><title><![CDATA[Play!> Routes : url segment as a single parameter]]></title><description><![CDATA[<div class="paragraph">
<p>This post is mainly a note for myself.</p>
</div>
<div class="paragraph">
<p>I was searching how to get a segment of an url (including some / characters) into a single parameter. <a href="http://stackoverflow.com/questions/8186834/how-to-turn-a-url-segment-into-a-single-parameter-in-play-framework">The response is on stack overflow</a> : use a regex.</p>
</div>
<div class="paragraph">
<p>The goal for me is to reroute a subset of RESTFUL call to the server really implementing the services.</p>
</div>]]></description><link>https://javathought.github.io/2014/09/11/Playgreater-Routes-url-segment-as-a-single-parameter.html</link><guid isPermaLink="true">https://javathought.github.io/2014/09/11/Playgreater-Routes-url-segment-as-a-single-parameter.html</guid><category><![CDATA[play framework]]></category><category><![CDATA[ REST]]></category><category><![CDATA[ routes]]></category><pubDate>Thu, 11 Sep 2014 00:00:00 GMT</pubDate></item><item><title><![CDATA[Receive file on MacOs via bluetooth]]></title><description><![CDATA[<div class="paragraph">
<p>A usefull link to a tip (in French) on MacOs :</p>
</div>
<div class="paragraph">
<p><a href="http://www.journaldulapin.com/2012/11/15/recevoir-des-fichiers-en-bluetooth-sur-un-mac/" class="bare">http://www.journaldulapin.com/2012/11/15/recevoir-des-fichiers-en-bluetooth-sur-un-mac/</a></p>
</div>
<div class="paragraph">
<p>By default, you can&#8217;t receive files via BT on MacOs. You have to activate it in System Preferences/share.</p>
</div>]]></description><link>https://javathought.github.io/2014/06/22/Receive-file-on-MacOs-via-bluetooth.html</link><guid isPermaLink="true">https://javathought.github.io/2014/06/22/Receive-file-on-MacOs-via-bluetooth.html</guid><category><![CDATA[Bluetooth]]></category><category><![CDATA[ MacOs]]></category><pubDate>Sun, 22 Jun 2014 00:00:00 GMT</pubDate></item><item><title><![CDATA[Play!> framework design pattern #3 : Avoid Anemic Domain Model]]></title><description><![CDATA[<div class="paragraph">
<p>In my last <a href="http://javathought.github.io/2012/12/27/play-framework-tips-for-templates-to-ensure-integrity/">post about data integrity</a>, I noticed that with the MVC model of Play, you tend to put many logic in the controller, even a part of the domain model, thus creating an <a href="http://www.martinfowler.com/bliki/AnemicDomainModel.html">Anemic Domain Model</a> as described by Martin Fowler.</p>
</div>
<div class="paragraph">
<p>And it&#8217;s what I made in my Codebaord Project to test Play! Framework. In my model, I have a class <code>Domain</code> that is only a database wrapper (with only annotations), and a controller <code>Domains</code> that has code that should be in the model (see <a href="https://github.com/javathought/Code-Board/blob/699086fb0860a0c14b53e32b092f5a3ccfe1c29d/app/controllers/Domains.java">old controller source</a> with this wrong choice).</p>
</div>
<div class="paragraph">
<p>So, I started replace domain code in the domain classes.</p>
</div>
<div class="paragraph">
<p>Now the controller class is lighter :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">public class Domains extends Admin \{

public static void list() \{

List&lt;Domain&gt; domains = Domain.find("order by position asc").fetch();

render(domains);

}

public static void create() \{

Domain domain = new Domain();

render("@edit", domain);

}

public static void edit(Long id) \{

Domain domain = Domain.findById(id);

render(domain);

}

public static void setDefault(Long id) \{

Domain domain = Domain.findById(id);

domain.setDefault();

Map summary = new HashMap();

summary.put(0, 1);

summary.put(1, Messages.get("domain_as_default"));

summary.put(2, id);

renderJSON(summary);

}

public static void save(@Valid Domain domain) \{

if (Validation.hasErrors()) \{

params.flash(); // add http parameters to the flash scope

validation.keep(); // keep the errors for the next request

render("@edit", domain);

}

domain.save();

list();

}

public static void delete(Long id) \{

Domain domain_to_delete = Domain.findById(id);

Map summary = new HashMap();

try \{

domain_to_delete.delete();

summary.put(0, 1);

summary.put(1, Messages.get("domain_deleted"));

summary.put(2, domain_to_delete.id);

} catch (UnsupportedOperationException e) \{

summary.put(0, 0);

summary.put(1, Messages.get(e.getMessage()));

summary.put(2, domain_to_delete.id);

}

renderJSON(summary);

}

public static void move(Long id) \{

String to = params.get("move_to");

Domain domain_to_move = Domain.findById(id);

domain_to_move.move(to);

Map summary = new HashMap();

summary.put(0, Messages.get("domain_moved"));

summary.put(1, domain_to_move.id);

summary.put(2, domain_to_move.position);

renderJSON(summary);

}

}</code></pre>
</div>
</div>
<div class="paragraph">
<p>and the model class is no more "empty" :</p>
</div>
<div class="paragraph">
<p>@Entity</p>
</div>
<div class="paragraph">
<p>public class Domain extends Model \{</p>
</div>
<div class="paragraph">
<p>public String name;</p>
</div>
<div class="paragraph">
<p>public long position;</p>
</div>
<div class="paragraph">
<p>public boolean isPublic;</p>
</div>
<div class="paragraph">
<p>public boolean isDefault;</p>
</div>
<div class="paragraph">
<p>public String toString() \{</p>
</div>
<div class="paragraph">
<p>return name;</p>
</div>
<div class="paragraph">
<p>}</p>
</div>
<div class="paragraph">
<p>public Domain delete() \{</p>
</div>
<div class="paragraph">
<p>if (! isDefault) \{</p>
</div>
<div class="paragraph">
<p>super.delete();</p>
</div>
<div class="paragraph">
<p>} else \{</p>
</div>
<div class="paragraph">
<p>throw new UnsupportedOperationException("dont_delete_default");</p>
</div>
<div class="paragraph">
<p>}</p>
</div>
<div class="paragraph">
<p>List&lt;Domain&gt; domains = Domain.find("position &gt; ?", position).fetch();</p>
</div>
<div class="paragraph">
<p>for (Iterator iterator = domains.iterator(); iterator.hasNext(); ) \{</p>
</div>
<div class="paragraph">
<p>Domain domain = (Domain) iterator.next();</p>
</div>
<div class="paragraph">
<p>domain.position = domain.position - 1;</p>
</div>
<div class="paragraph">
<p>domain.save();</p>
</div>
<div class="paragraph">
<p>}</p>
</div>
<div class="paragraph">
<p>return this;</p>
</div>
<div class="paragraph">
<p>}</p>
</div>
<div class="paragraph">
<p>public Domain setDefault() \{</p>
</div>
<div class="paragraph">
<p>Domain defaultDomain = Domain.find("isDefault = ?", true).first();</p>
</div>
<div class="paragraph">
<p>if (defaultDomain != null) \{</p>
</div>
<div class="paragraph">
<p>defaultDomain.isDefault = false;</p>
</div>
<div class="paragraph">
<p>defaultDomain.save();</p>
</div>
<div class="paragraph">
<p>}</p>
</div>
<div class="paragraph">
<p>isDefault = true;</p>
</div>
<div class="paragraph">
<p>save();</p>
</div>
<div class="paragraph">
<p>return this;</p>
</div>
<div class="paragraph">
<p>}</p>
</div>
<div class="paragraph">
<p>public void move(String to) \{</p>
</div>
<div class="paragraph">
<p>if (to.equals("highest")) \{</p>
</div>
<div class="paragraph">
<p>List&lt;Domain&gt; domains = Domain.find("position &lt; ?", position).fetch();</p>
</div>
<div class="paragraph">
<p>for (Iterator iterator = domains.iterator(); iterator.hasNext();) \{</p>
</div>
<div class="paragraph">
<p>Domain domain = (Domain) iterator.next();</p>
</div>
<div class="paragraph">
<p>domain.position = domain.position +1;</p>
</div>
<div class="paragraph">
<p>domain.save();</p>
</div>
<div class="paragraph">
<p>}</p>
</div>
<div class="paragraph">
<p>position = 1;</p>
</div>
<div class="paragraph">
<p>} else if (to.equals("higher")) \{</p>
</div>
<div class="paragraph">
<p>Domain domain_to_swap = Domain.find("position = ?", position - 1).first();</p>
</div>
<div class="paragraph">
<p>domain_to_swap.position = position;</p>
</div>
<div class="paragraph">
<p>position = position - 1;</p>
</div>
<div class="paragraph">
<p>domain_to_swap.save();</p>
</div>
<div class="paragraph">
<p>} else if (to.equals("lower")) \{</p>
</div>
<div class="paragraph">
<p>Domain domain_to_swap = Domain.find("position = ?", position + 1).first();</p>
</div>
<div class="paragraph">
<p>domain_to_swap.position = position;</p>
</div>
<div class="paragraph">
<p>position = position + 1;</p>
</div>
<div class="paragraph">
<p>domain_to_swap.save();</p>
</div>
<div class="paragraph">
<p>} else if (to.equals("lowest")) \{</p>
</div>
<div class="paragraph">
<p>List&lt;Domain&gt; domains = Domain.find("position &gt; ?", position).fetch();</p>
</div>
<div class="paragraph">
<p>for (Iterator iterator = domains.iterator(); iterator.hasNext();) \{</p>
</div>
<div class="paragraph">
<p>Domain domain = (Domain) iterator.next();</p>
</div>
<div class="paragraph">
<p>domain.position = domain.position - 1;</p>
</div>
<div class="paragraph">
<p>domain.save();</p>
</div>
<div class="paragraph">
<p>}</p>
</div>
<div class="paragraph">
<p>position = Domain.count();</p>
</div>
<div class="paragraph">
<p>}</p>
</div>
<div class="paragraph">
<p>save();</p>
</div>
<div class="paragraph">
<p>}</p>
</div>
<div class="paragraph">
<p>}</p>
</div>
<div class="paragraph">
<p>[/code]</p>
</div>]]></description><link>https://javathought.github.io/2013/01/20/Playgreater-framework-design-pattern-3-Avoid-Anemic-Domain-Model.html</link><guid isPermaLink="true">https://javathought.github.io/2013/01/20/Playgreater-framework-design-pattern-3-Avoid-Anemic-Domain-Model.html</guid><category><![CDATA[AnemicDomainModel]]></category><category><![CDATA[ design patterns]]></category><category><![CDATA[ java]]></category><category><![CDATA[ play framework]]></category><pubDate>Sun, 20 Jan 2013 00:00:00 GMT</pubDate></item><item><title><![CDATA[Play !> framework - tips for templates to ensure integrity]]></title><description><![CDATA[<div class="paragraph">
<p><a href="https://github.com/javathought/Code-Board">codeboard</a> has a configuration with use of default values. If these default values are not present, errors can occur on some pages. The example of the tips are on the model class Domain. To ensure that this default values are always present in the configuration, I use 3 tips to be sure defaults datas are always present in the database :</p>
</div>
<div class="paragraph">
<p>\1. it&#8217;s not possible to delete defaults datas</p>
</div>
<div class="paragraph">
<p>The <code>delete</code> button is not present if the object is the default one.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">#\{if !domain.isDefault}

&lt;a href="/admin/domains/$\{domain.id}" class="icon icon-del delete" &gt;&amp;\{'delete'}&lt;/a&gt;

#\{/if}</code></pre>
</div>
</div>
<div class="paragraph">
<p>\2. it is not possible to uncheck a default value</p>
</div>
<div class="paragraph">
<p>Editing an object, the default attribute is read-only (shown with an image in my code) if it&#8217;s a default one; else a standard default check box is shown.</p>
</div>
<div class="paragraph">
<p>#\{if domain.isDefault }</p>
</div>
<div class="paragraph">
<p>&lt;img alt="Toggle_check" src="@\{'/public/images/toggle_check.png'}" /&gt;</p>
</div>
<div class="paragraph">
<p>#\{/if}</p>
</div>
<div class="paragraph">
<p>#{else}</p>
</div>
<div class="paragraph">
<p>&lt;input type="checkbox" id="domain_isDefault" name="domain.isDefault" value="true" $\{domain?.isDefault ? 'checked':''} /&gt;</p>
</div>
<div class="paragraph">
<p>&lt;input type="hidden" name="domain.isDefault" value="false" /&gt;</p>
</div>
<div class="paragraph">
<p>&lt;span class="errorExplanation"&gt;#\{error 'admin' /}&lt;/span&gt;&lt;/p&gt;</p>
</div>
<div class="paragraph">
<p>#\{/else}</p>
</div>
<div class="paragraph">
<p>[/code]</p>
</div>
<div class="paragraph">
<p>To complete these tips on template, a third tip</p>
</div>
<div class="paragraph">
<p>\3. it is not possible to have twice object being checked as default</p>
</div>
<div class="paragraph">
<p>So if we&#8217;re setting an object to default, we must uncheck the old one. This control is done in the controller (and not in templates).</p>
</div>
<div class="paragraph">
<p>if (domain.isDefault) \{</p>
</div>
<div class="paragraph">
<p>Domain defaultDomain = Domain.find("isDefault = ?", true).first();</p>
</div>
<div class="paragraph">
<p>if (defaultDomain != null) \{</p>
</div>
<div class="paragraph">
<p>defaultDomain.isDefault = false;</p>
</div>
<div class="paragraph">
<p>defaultDomain.save();</p>
</div>
<div class="paragraph">
<p>}</p>
</div>
<div class="paragraph">
<p>}</p>
</div>
<div class="paragraph">
<p>domain.save();</p>
</div>
<div class="paragraph">
<p>[/code]</p>
</div>
<div class="paragraph">
<p><strong>[to be continued &#8230;&#8203;]</strong></p>
</div>]]></description><link>https://javathought.github.io/2012/12/27/Play-greater-framework-tips-for-templates-to-ensure-integrity.html</link><guid isPermaLink="true">https://javathought.github.io/2012/12/27/Play-greater-framework-tips-for-templates-to-ensure-integrity.html</guid><category><![CDATA[data integrity]]></category><category><![CDATA[ play framework]]></category><category><![CDATA[ templates]]></category><pubDate>Thu, 27 Dec 2012 00:00:00 GMT</pubDate></item><item><title><![CDATA[SD card, RAW and Ubuntu]]></title><description><![CDATA[<div class="paragraph">
<p>I wanted to upload some photos on my Dell XPS 17, but encountered some issues to view them</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>The SD card is not detected when inserting it in the reader.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>The trick is simple :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">sudo su -l
echo 1 &gt; /sys/bus/pci/rescan</code></pre>
</div>
</div>
<div class="olist arabic">
<ol class="arabic" start="2">
<li>
<p>RAW are not readable</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>I had to actions to do it :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>install the package : <code>gnome-raw-thumbnailer</code> (By the way, unable to add <code>apt://</code> link in Wordpress :-( )</p>
</li>
<li>
<p>if missing create the following file &lt;code&gt;/usr/share/thumbnailers/raw.thumbnailer&lt;/code&gt;, that seems not included in the package, with this content :</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-text" data-lang="text">[Thumbnailer Entry]
Exec=/usr/bin/gnome-raw-thumbnailer -s %s %u %o
MimeType=image/x-3fr;image/x-adobe-dng;image/x-arw;image/x-bay;image/x-canon-cr2;image/x-canon-crw;image/x-cap;image/x-cr2;image/x-crw;image/x-dcr;image/x-dcraw;image/x-dcs;image/x-dng;image/x-drf;image/x-eip;image/x-erf;image/x-fff;image/x-fuji-raf;image/x-iiq;image/x-k25;image/x-kdc;image/x-mef;image/x-minolta-mrw;image/x-mos;image/x-mrw;image/x-nef;image/x-nikon-nef;image/x-nrw;image/x-olympus-orf;image/x-orf;image/x-panasonic-raw;image/x-pef;image/x-pentax-pef;image/x-ptx;image/x-pxn;image/x-r3d;image/x-raf;image/x-raw;image/x-rw2;image/x-rwl;image/x-rwz;image/x-sigma-x3f;image/x-sony-arw;image/x-sony-sr2;image/x-sony-srf;image/x-sr2;image/x-srf;image/x-x3f;</code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>then restart Nautilus via the menu (File &#8594; Close all windows) or <code>nautilus -q</code></p>
</li>
</ul>
</div>]]></description><link>https://javathought.github.io/2012/12/25/SD-card-RAW-and-Ubuntu.html</link><guid isPermaLink="true">https://javathought.github.io/2012/12/25/SD-card-RAW-and-Ubuntu.html</guid><category><![CDATA[linux]]></category><category><![CDATA[ nautilus]]></category><category><![CDATA[ raw]]></category><category><![CDATA[ SD card]]></category><category><![CDATA[ ubuntu]]></category><pubDate>Tue, 25 Dec 2012 00:00:00 GMT</pubDate></item><item><title><![CDATA[Play!> framework design pattern #2 reviewed]]></title><description><![CDATA[<div class="paragraph">
<p><a href="http://javathought.github.io/2012/02/18/play-framework-design-pattern-2/">I</a>n this <a href="http://javathought.github.io/2012/02/18/play-framework-design-pattern-2/">post</a> I write about a pattern to avoid code duplication for rendering the same objects (like combo boxes and so) in different views (a view to create an item or a view to edit existing ones). It has 2 things that couldn&#8217;t be done with the example code :</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>use the objects on the view of different objects (2 methods rendering different objects) thus needing different template (the existing example uses 2 views, creation and edition on the same template)</p>
</li>
<li>
<p>change the view of an object on rules in the code, for example on ACL (Access Control List) a user will not have the same view or will not have access to the datas.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>To enable the two behaviours, the use of the <code>render</code> method, that needed to identify a template, is replace by the <code>renderArgs.put</code> that is independant of the template.</p>
</div>
<div class="paragraph">
<p>So here is the example updated to enable rendering the objects on view of different datas of on different templates of the same datas</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">    @SuppressWarnings("unused")
    @Before(only={"newIssue", "editIssue"})
    private static void loadCombos() {
        renderArgs.put("trackers", Tracker.find("order by position asc").fetch());
        renderArgs.put("users", User.find("login &lt;&gt; 'root' order by login").fetch());
        renderArgs.put("states", State.find("order by position").fetch());
        renderArgs.put("priorities", Enumeration.find("byType", Enumeration.ISSUE_PRIORITY_TYPE).fetch());
    }

    @SuppressWarnings("unused")
    @Before(only={"myIssues"})
    private static void checkAccess() {
        if (Security.connected() == null)
            try {
                Secure.login();
            } catch (Throwable e) {
                Logger.error(e, "Error loading Login page");
            }
    }

    public static void newIssue(String identifier) {
        Project project = Project.find("identifier", identifier).first();
        Issue issue = new Issue(project);
        render("@issue", issue);er
    }

    public static void editIssue(Long id) {
        Issue issue = Issue.findById(id);

        if (! issue.project.isVisible()) {
            render("@deny", issue);
        } else {
            render("@issue", issue);
        }

    }</code></pre>
</div>
</div>
<div class="paragraph">
<p>In the example, due to ACL, if the user have no rights to view an issue, an "Access denied" page is shown in place of the standard view to edit the issue.</p>
</div>]]></description><link>https://javathought.github.io/2012/12/11/Playgreater-framework-design-pattern-2-reviewed.html</link><guid isPermaLink="true">https://javathought.github.io/2012/12/11/Playgreater-framework-design-pattern-2-reviewed.html</guid><category><![CDATA[design patterns]]></category><category><![CDATA[ play framework]]></category><pubDate>Tue, 11 Dec 2012 00:00:00 GMT</pubDate></item><item><title><![CDATA[Play !> and 3-tier, n-tier architecture - Part II]]></title><description><![CDATA[<div class="paragraph">
<p>In <a href="http://javathought.github.io/2012/07/04/play-and-3-tier-n-tier-architecture-part-i/">Part I</a>, I introduced the use of Play! framework on 3-tier architecture. In this one, we will see how to use the native  features of Play! to implement a 3-tier application.</p>
</div>
<div class="paragraph">
<p>As we saw, the implementation of the <strong>Logic tier</strong> is easy with Play!. In this implementation, you can remove <a href="http://javathought.github.io/2011/12/04/cross-origin-resource-sharing-with-play-framework/">CORS</a> on the tier.</p>
</div>
<div class="paragraph">
<p>The <strong>Presentation tier</strong> will also be relatively easy; the Logic tier will be considered as the model of the Presentation tier : the diagram below illustrated the architecture.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/3tier_play.png" alt="image">
</div>
<div class="title">Figure 1. 3tier_play</div>
</div>
<div class="paragraph">
<p>Play! on a 3-tier architecture</p>
</div>
<div class="paragraph">
<p>Instead of making calls to a classic Play! model (such as &lt;code&gt;Account.findAll()&lt;/code&gt;), the  controller will  call the REST API of the logic tier, and render a view as a response :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">public static void accounts() {
 String url = "http://localhost:9011/api/accounts";
 HttpResponse response = WS.url(url).get();
JsonElement accounts = response.getJson();

render(accounts);</code></pre>
</div>
</div>
<div class="paragraph">
<p>The view code will be a classic html template code. There&#8217;s just a trick, as strings will be surrounded by quotes ("). The code will be &lt;code&gt;$\{object.property.getAsString()}&lt;/code&gt; instead of &lt;code&gt;$\{object.property.getAsString()}&lt;/code&gt;.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-groovy" data-lang="groovy">${account.number.getAsString()}</code></pre>
</div>
</div>
<div class="paragraph">
<p>And that&#8217;s all. Really simple to make a 3-tier application with Play!</p>
</div>
<div class="paragraph">
<p>Related articles</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="http://dotnetspice.wordpress.com/2012/06/12/2-tier-architecture-vs-3-tier-architecture-4/">2 Tier architecture Vs 3 Tier architecture</a> (dotnetspice.wordpress.com)</p>
</li>
</ul>
</div>]]></description><link>https://javathought.github.io/2012/07/04/Play-greater-and-3-tier-n-tier-architecture-Part-II.html</link><guid isPermaLink="true">https://javathought.github.io/2012/07/04/Play-greater-and-3-tier-n-tier-architecture-Part-II.html</guid><category><![CDATA[Application programming interface]]></category><category><![CDATA[ java]]></category><category><![CDATA[ json]]></category><category><![CDATA[ Multitier architecture]]></category><category><![CDATA[ play framework]]></category><pubDate>Wed, 04 Jul 2012 00:00:00 GMT</pubDate></item><item><title><![CDATA[Play !> and 3-tier, n-tier architecture - Part I]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>Play!► is based on the <a href="http://www.playframework.org/documentation/1.2.4/main#mvc">MVC application model</a>. This model, as named, is an application model, but in an enterprise ecosystem, you&#8217;ll have to integrate your application with the Information System, and apply 3-tier physical architecture, or <a href="http://en.wikipedia.org/wiki/Multitier_architecture">n-tier architecture</a></p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/3tier.png" alt="image">
</div>
<div class="title">Figure 1. 3tier</div>
</div>
<div class="paragraph">
<p>The 3-tier architecture</p>
</div>
<div class="paragraph">
<p>The 3-tier architecture can be imposed by architects and/or <a href="http://en.wikipedia.org/wiki/Chief_information_security_officer">CISO</a> for scalability and security reasons. The 3-tier is briefly described in the diagram below, each tier having to be hosted in a separated server. As you can see, there&#8217;s no exchange between the Presentation tier and the Data tier.</p>
</div>
<div class="paragraph">
<p>You&#8217;ll can also have to build a n-tier application, as your application has to be integrates differents service of the enterprise, such as legacy database and so one.  An e-commerce web site for example, the service provided to the client will need the services of a Stock application (the products available), a Billing application (to charge the client), an Order application (to prepare and send the order).</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/n-tier.png" alt="image">
</div>
<div class="title">Figure 2. n-tier e-commerce web site</div>
</div>
<div class="paragraph">
<p>An e-commerce n-tier architecture</p>
</div>
<div class="paragraph">
<p>In these 2 cases, the top most level of the application are very similar ; it calls services to other tiers. In the case of a 3-tier application, you&#8217;ll have also the Logic tier to develop.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_the_logic_tier">the Logic tier</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Building a logic tier with <a href="http://www.playframework.org">Play! framework</a> is really easy. All you have to do is use the appropriate view to deliver a service (render as xml or json for example). The easiest os to render as json, as there&#8217;s no template to code, just a call to <code>renderJSON</code>.</p>
</div>
<div class="paragraph">
<p>So the work is on the Presentation tier</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_the_presentation_tier">the Presentation tier</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This tier will be explained on a service returning the list of accounts (see <a href="http://javathought.github.io/2012/06/24/play-json-how-to-select-fields-to-expose-exclusionstrategy/">this article on Json and Java</a> about the model). One possibility, as the services of the logic tier is performed, is to make an Ajax application, with javascript calls to the logic tier (with JQuery for example).</p>
</div>
<div class="paragraph">
<p>The code will then be somethong similar to this : a part in the view to present the action</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">&lt;div id="accounts" class="btn primary"&gt;Get accounts&lt;/div&gt;
&lt;div id="accounts_list"&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>And a JQuery code to perform the request and render the response :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">$("#accounts").click(function(){

$('#accounts_list').html('&lt;p&gt;&lt;img src="@{'/public/images/ajax-loader.gif'}" width="220" height="19" /&gt;&lt;/p&gt;');

$.getJSON('http://localhost:9011/api/accounts', function(accounts) {
// $("#results").empty();
var textToInsert = [];
var i = 0;
$("#accounts_list").empty();
$("#accounts_list").append('&lt;table id="account_table" class="table-bordered table-condensed table-striped"&gt; ' +
'&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Account number&lt;/th&gt;&lt;th&gt;Balance&lt;/th&gt;&lt;th&gt;Label&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;/tbody&gt;&lt;/table&gt;');

$.each(accounts, function(title, acc) {
console.log(acc);
//$("#results").append('&lt;p&gt;'+acc.number+'&lt;/p&gt;');
textToInsert[i++] = '&lt;tr&gt;&lt;td &gt;&lt;a href="#" class="acc_ref" onclick="account_details('+ acc.id +')" &gt;'+acc.number+'&lt;/a&gt;&lt;/td&gt;&lt;td&gt;'+
acc.balance+'&lt;/td&gt;&lt;td&gt;'+acc.label+'&lt;/td&gt;&lt;/tr&gt;';
});
$("#account_table").append(textToInsert.join(''));
});
});</code></pre>
</div>
</div>
<div class="paragraph">
<p>As you can see, the code is verbose, not easily maintainable and it will be heavy to do this for all the services in the Logic tier (or the services performed by others applications).</p>
</div>
<div class="paragraph">
<p>In addition, you&#8217;l have to allow <a href="http://javathought.github.io/2011/12/04/cross-origin-resource-sharing-with-play-framework/">Cross-Origin Resource Sharing</a> on the logic tier.</p>
</div>
<div class="paragraph">
<p>Moreover, this solution is prohibited by the 3-tier architecture, as the thin client makes calls to the logic tier, and probably will not work as there will be a firewall in front of the application that will authorize only request to the presentation.</p>
</div>
<div class="paragraph">
<p>The <a href="http://javathought.github.io/2012/07/04/play-and-3-tier-n-tier-architecture-part-ii/">part II</a> will explain how to do the Presentation tier with the MVC application model of Play! framework and respect the 3-tier architecture with no need of CORS.</p>
</div>
</div>
</div>]]></description><link>https://javathought.github.io/2012/07/04/Play-greater-and-3-tier-n-tier-architecture-Part-I.html</link><guid isPermaLink="true">https://javathought.github.io/2012/07/04/Play-greater-and-3-tier-n-tier-architecture-Part-I.html</guid><category><![CDATA[AJAX]]></category><category><![CDATA[ JQuery]]></category><category><![CDATA[ json]]></category><category><![CDATA[ Multitier architecture]]></category><category><![CDATA[ play framework]]></category><pubDate>Wed, 04 Jul 2012 00:00:00 GMT</pubDate></item><item><title><![CDATA[ubuntu 12.10 precise pangolin breaks my redmine and tomcat7 installation]]></title><description><![CDATA[<div class="paragraph">
<p>My redmine installation was broken when I installed Precise pangolin. The home screen was ok, but I has errors when navigating on the app. I didn&#8217;t search much but found easyli the solution when I tried to install a package. I had errors when running <em>sudo apt-get install &#8230;&#8203;</em>. These errors where about the command <em>rake db:migrate</em> and the tomcat file tomcat-users.xml.</p>
</div>
<div class="paragraph">
<p>So the action about ruby was easy :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">sudo gem install --remote rake</code></pre>
</div>
</div>
<div class="paragraph">
<p>For tomcat 7, I had a previous manual installation on ubuntu 11. As tomcat 7 is embedded with precise pangolin, I just had to copy the file missing fomr my previous manual installation :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">sudo cp /opt/tomcat7/conf/tomcat-users.xml /etc/tomcat7</code></pre>
</div>
</div>]]></description><link>https://javathought.github.io/2012/06/27/ubuntu-1210-precise-pangolin-breaks-my-redmine-and-tomcat7-installation.html</link><guid isPermaLink="true">https://javathought.github.io/2012/06/27/ubuntu-1210-precise-pangolin-breaks-my-redmine-and-tomcat7-installation.html</guid><category><![CDATA[redmine]]></category><category><![CDATA[ tomcat]]></category><category><![CDATA[ ubuntu]]></category><pubDate>Wed, 27 Jun 2012 00:00:00 GMT</pubDate></item><item><title><![CDATA[Play!> & JSon : How-to select fields to expose (ExclusionStrategy)]]></title><description><![CDATA[<div class="paragraph">
<p>Using JSON as data language to build an API for your Play application, the default behaviour is to render all fields of a class, and this recursively. This means render the fields of a</p>
</div>
<div class="paragraph">
<p>Here a sample model example that could occurs in a bank application :</p>
</div>
<div class="paragraph">
<p>A client is specified with this model, that includes the password of the client.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">@Entity
public class Client extends Model {
    public String firstname;
    public String lastname;
    public  String password;

    public String toString() {
        return firstname + " " + lastname;
    }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>This client has accounts in the bank, so a simple model would be :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">@Entity
public class Account extends Model {
    @ManyToOne
    public Client owner;
    public String number;
    public Double balance;
    public String label;

    public String toString() {
        return number;
    }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>One of the first service of the application when a client connects to the application is to show the list of his accounts :</p>
</div>
<div class="paragraph">
<p>The route is :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>GET /api/accounts Operations.listAccounts</code></pre>
</div>
</div>
<div class="paragraph">
<p>And the code of the controller is :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">public class Operations extends Controller {
    public static void listAccounts() {
        List&lt;Account&gt; accounts = Account.find("order by number").fetch();
        renderJSON(accounts);
    }

}</code></pre>
</div>
</div>
<div class="paragraph">
<p>This code will expose the following json datas :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>[\{"owner":\{"firstname":"xxx","lastname":"xxx","password":"yyyy","id":1},"number":"001","balance":999.99,"label":"ACCOUNT X","id":1},...]</code></pre>
</div>
</div>
<div class="paragraph">
<p>Oh, the password is visible.</p>
</div>
<div class="paragraph">
<p>So what we will do is to extend Play! with a new Controller class that will use add a Strategy to gson :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">package ext;

import play.mvc.Controller;
import play.mvc.Util;
import play.mvc.results.RenderJson;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;


public abstract class NoExposeStrategyController extends Controller {
    private static final Gson gson;

    static {

        gson = new GsonBuilder()
        .addSerializationExclusionStrategy(new NoExposeExclusionStrategy())
        .create();

    }

    @Util
    public static void renderJSON(Object object) {
        throw new RenderJson(gson.toJson(object));
    }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now, we will wrtie this strategy. The goal is to exclude fiels annoted (we will use the tag @NoExpose) in the json output.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">package ext;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;

public class NoExposeExclusionStrategy implements ExclusionStrategy {

    @Retention(RetentionPolicy.RUNTIME)
    @Target({ ElementType.FIELD })
    public @interface NoExpose {
        // Field tag only annotation
    }

    public NoExposeExclusionStrategy() {
    }

    public boolean shouldSkipClass(Class&lt;?&gt; clazz) {
        return (false);
    }

    public boolean shouldSkipField(FieldAttributes f) {
        return f.getAnnotation(NoExpose.class) != null;
    }

}</code></pre>
</div>
</div>
<div class="paragraph">
<p>You can notice that with exclude fields, but that we can also exclude Classes. This can also be very interesting to exclude a model (so all datas of a particular table).</p>
</div>
<div class="paragraph">
<p>The main code is done. All we have to do now is just two basic actions.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>change the declaration of our controller(s) :</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">public class Operations extends NoExposeStrategyController {</code></pre>
</div>
</div>
<div class="paragraph">
<p>-annotate the fields we want to exclude :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">    @NoExpose
    public  String password;</code></pre>
</div>
</div>]]></description><link>https://javathought.github.io/2012/06/24/Playgreater-and-JSon-How-to-select-fields-to-expose-ExclusionStrategy.html</link><guid isPermaLink="true">https://javathought.github.io/2012/06/24/Playgreater-and-JSon-How-to-select-fields-to-expose-ExclusionStrategy.html</guid><category><![CDATA[ExclusionStrategy]]></category><category><![CDATA[ json]]></category><category><![CDATA[ play framework]]></category><pubDate>Sun, 24 Jun 2012 00:00:00 GMT</pubDate></item><item><title><![CDATA[Play!> 2.0 Install it to /opt anyway]]></title><description><![CDATA[<div class="paragraph">
<p>I don&#8217;t understand the new install of play!&gt; framework 2.0</p>
</div>
<div class="paragraph">
<p>The documentation says :</p>
</div>
<div class="quoteblock">
<blockquote>
<div class="paragraph">
<p>[&#8230;&#8203;]extract the archive to a location where you have both read and write access. (Running play writes some files to directories within the archive, so don’t install to /opt, /usr/local or anywhere else you’d need special permission to write to.)</p>
</div>
</blockquote>
</div>
<div class="paragraph">
<p>For example, the 'play' command writes a lock file in dir.</p>
</div>
<div class="paragraph">
<p>WHY ?</p>
</div>
<div class="paragraph">
<p>So how do you share the installation between users ? How do you ensure nobody broke the installation ? I don&#8217;t like that choice. Here are the commands to still install to <code>/opt</code> (or other irectory of you choice).</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">&gt; groupadd play
&gt; sudo chgrp play play-2.0
&gt; sudo chmod -R g+w play-2.0/
&gt; sudo usermod -a -G play username</code></pre>
</div>
</div>
<div class="paragraph">
<p>What I&#8217;d like from the play team :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>the pros and cons of the choice</p>
</li>
<li>
<p>a release strategy explanation :</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Play 2.0 is out but 1.x branch is not dead. Really ?</p>
</div>
<div class="paragraph">
<p>Issue #1304 is, in my opinion, a critical defect (absolutely impossible to use version 1.2.4 with PotgreSQL). It was opened on December 7th, 2011 and resolved on December 12th, 2011 : but no new release as been published since.</p>
</div>
<div class="paragraph">
<p>What kind of support of the framework can an enterprise expect ?</p>
</div>
<div class="paragraph">
<p>Play! is a great framework, but must have a clearer and better support policy for enterprise that use it in critical businesses.</p>
</div>]]></description><link>https://javathought.github.io/2012/03/14/Playgreater-20-Install-it-to-opt-anyway.html</link><guid isPermaLink="true">https://javathought.github.io/2012/03/14/Playgreater-20-Install-it-to-opt-anyway.html</guid><category><![CDATA[play framework]]></category><category><![CDATA[ ubuntu]]></category><pubDate>Wed, 14 Mar 2012 00:00:00 GMT</pubDate></item><item><title><![CDATA[Play!> framework How-To : binding @ManyToMany to views (without CRUD) and differents UI]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>This is a little How-To for binding @ManyToMany relationship in Play!&gt; views. The model for this very simple : a Domain model , and a User model. Users can belong to many domains and domains can have many models.</p>
</div>
<div class="paragraph">
<p>So, the Models are simple :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">@Entity
public class Domain extends Model {
    public String name;


    public String toString() {
        return name;
    }

}</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">@Entity
public class User extends Model {
    @Required
    public String firstname;
    @Required
    public String lastname;
    @ManyToMany
    public List&lt;Domain&gt; domains = new ArrayList&lt;Domain&gt;();

    public String toString() {
        return firstname + " " + lastname;
    }

}</code></pre>
</div>
</div>
<div class="paragraph">
<p>The relationship will be handle by the User view : the deafult component to handle this is the &lt;select&gt; form tag. So here is the basic code to make the binding.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">    #{form @Users.save(), id:'userCreationForm', enctype:'multipart/form-data'}
        &lt;input name='user.id' id='id-${user?.id}' type='hidden' value="${user?.id}"/&gt;
        #{input for:'user.firstname', id:'firstname-${user.id}' /}
        #{input for:'user.lastname', id:'lastname-${user.id}' /}

        &lt;select id="user_domains" name="user.domains.id" value="" size="1" id="select" multiple&gt;
        #{list domains, as:'domain'}
            &lt;option value="${domain.id}" ${user.domains.contains(domain) ? 'selected' : ''} &gt;${domain.name}&lt;/option&gt;
        #{/list}
        &lt;/select&gt;

        &lt;input type="submit" value="Save"&gt;
    #{/form }</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will reproduce the same UI as in CRUDSs views. Note this two importants things :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>the <code>name</code> of the <code>select</code> tag is : user.domains.id</p>
</li>
<li>
<p>to bind selected domains in the options, use the ternary operator and the <code>contains</code> method : $\{user.domains.contains(domain) ? 'selected' : ''}</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_changing_the_ui">Changing the UI</h3>
<div class="paragraph">
<p>I don&#8217;t really like this UI choice. As in the Yabe blog demo, we can change the UI of this view : we will user the same design as on the demo. We will use the same styles and javascript :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">&lt;style type="text/css"&gt;
       .domains-list .domain {
           cursor: pointer;
           padding: 1px 4px;
       }
       .domains-list .selected {
           background: #222;
           color: #fff;
       }
&lt;/style&gt;
&lt;script type="text/javascript"&gt;
       var toggle = function(domainEl) {
           var input = document.getElementById('h'+domainEl.id);
           if(domainEl.className.indexOf('selected') &gt; -1) {
               domainEl.className = 'domain';
               input.value = '';
           } else {
               domainEl.className = 'domain selected';
               input.value = domainEl.id;
           }
       }
&lt;/script&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>And then adapt the form components :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">    &lt;div class="domains-list"&gt;
       #{list domains, as:'domain'}
           &lt;span id="${domain.id}" onclick="toggle(this)"
                class="domain ${user.domains.contains(domain) ? 'selected' : ''}"&gt;
               ${domain}
           &lt;/span&gt;
           &lt;input id="h${domain.id}" type="hidden" name="user.domains.id"
                    value="${user.domains.contains(domain) ? domain.id : ''}" /&gt;
        #{/list}
    &lt;/div&gt;</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_using_checkboxes">USing checkboxes</h3>
<div class="paragraph">
<p>Another choice is to use checkboxes. The use is really simple. The important thing is the same, use the good name on the form component : <code>name="user.domains.id"</code></p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">    #{list domains, as:'domain'}
    &lt;input id="${domain.id}" type="checkbox" name="user.domains.id"
             ${user.domains.contains(domain) ? 'checked' : ''} value=${domain.id}&gt;${domain}&lt;/input&gt;
    #{/list}
    &lt;input type="hidden" name="user.domains.id" value="" /&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>Updated</strong> : It&#8217;s important to not forgot the last <code>&lt;input /&gt;</code> to handle when no checkbox is selected, otherwise no changes will be made.</p>
</div>
</div>]]></description><link>https://javathought.github.io/2012/03/03/Playgreater-framework-How-To-binding-ManyToMany-to-views-without-CRUD-and-differents-UI.html</link><guid isPermaLink="true">https://javathought.github.io/2012/03/03/Playgreater-framework-How-To-binding-ManyToMany-to-views-without-CRUD-and-differents-UI.html</guid><category><![CDATA[data binding]]></category><category><![CDATA[ HowTo]]></category><category><![CDATA[ JPA]]></category><category><![CDATA[ ManyToMany]]></category><category><![CDATA[ play framework]]></category><pubDate>Sat, 03 Mar 2012 00:00:00 GMT</pubDate></item><item><title><![CDATA[Play!> framework : binding checkbox to POJO]]></title><description><![CDATA[<div class="paragraph">
<p>I&#8217;ve been quite a long time to find the good way to bind checkboxes in my views to boolean properties of my POJO. The only way I was able to handle the checkboxes was to pass explicitly the field to the save method of the controller and explicitly set the property to the value of the argument in the controller. Otherwise, only changes from unset to set were save to the model.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">    #{form @Domains.save(isPublic), id:'form', method:'POST', enctype:'multipart/form-data'}
    ...
    &lt;input type="checkbox" id="domain_isPublic" name="isPublic" ${domain?.isPublic ? 'checked':''} /&gt;
    ...
    #{form}</code></pre>
</div>
</div>
<div class="paragraph">
<p>and this additional line is present in the <em>save</em> of the controller :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">    domain.isPublic = isPublic;</code></pre>
</div>
</div>
<div class="paragraph">
<p>I finally found the solution in <a href="http://groups.google.com/group/play-framework/browse_thread/thread/1f2810b981776bc1">this discussion of the play-framework group</a>. As said by</p>
</div>
<div class="paragraph">
<p>Guillaume Bort, an hidden field must be added <strong>after</strong> the checkbox field to have the binding done when the checkbox is unset : when unset, the value is null and so no binding is done. So the hidden field is used to binf the false value.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">    #{form @Domains.save(), id:'form', method:'POST', enctype:'multipart/form-data'}
        ...
    &lt;input type="checkbox" id="domain_isPublic" name="domain.isPublic" value="true" ${domain?.isPublic ? 'checked':''} /&gt;
    &lt;input type="hidden" name="domain.isPublic" value="false" /&gt;
    ...
    #{form}</code></pre>
</div>
</div>
<div class="paragraph">
<p>And you can now remove the setting of the boolean field in your controller.</p>
</div>]]></description><link>https://javathought.github.io/2012/02/26/Playgreater-framework-binding-checkbox-to-POJO.html</link><guid isPermaLink="true">https://javathought.github.io/2012/02/26/Playgreater-framework-binding-checkbox-to-POJO.html</guid><category><![CDATA[boolean field]]></category><category><![CDATA[ controller code]]></category><category><![CDATA[ data binding]]></category><category><![CDATA[ play framework]]></category><pubDate>Sun, 26 Feb 2012 00:00:00 GMT</pubDate></item><item><title><![CDATA[Play!> framework design pattern #2 : avoid code duplication to render same objects in differents views]]></title><description><![CDATA[<div class="paragraph">
<p>If you have common code in your controllers to render objects in differents views, you&#8217;ll duplicate your code to instanciate your java objects in each method and pass them to the render method.</p>
</div>
<div class="paragraph">
<p>The goal of this pattern is to avoid code duplication using the @Before/@After annotations even for objects to be rendered. The trick is that these methods can also contains calls to the render method !</p>
</div>
<div class="paragraph">
<p>To avoid code duplication, you must use the @After annotation to a private method which will have the common code of your controllers and call render on these objects. And the "main" controller method of each view will render the specific objects of the view.</p>
</div>
<div class="paragraph">
<p>The example below render the same view on edition and creation of an object ( of <a href="http://javathought.github.io/2012/02/16/play-framework-design-pattern-1/">design pattern #1</a>), nut could be used on different views.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">    @After(only={"newIssue", "editIssue"})
    private static void loadCombos() {
        List&lt;Tracker&gt; trackers = Tracker.find("order by position asc").fetch();
        List&lt;User&gt; users = User.find("login &lt;&gt; 'root' order by login").fetch();
        List&lt;State&gt; states = State.find("order by position").fetch();
        List&lt;Enumeration&gt; priorities = Enumeration.find("byType", Enumeration.ISSUE_PRIORITY_TYPE).fetch();

        render("@issue", trackers, users, states, priorities);
}

    public static void newIssue(String identifier) {
        Project project = Project.find("identifier", identifier).first();
        Issue issue = new Issue(project);

        render("@issue", issue);
    }

    public static void editIssue(Long id) {
        Issue issue = Issue.findById(id);

        render("@issue", issue);
    }</code></pre>
</div>
</div>
<div class="paragraph">
<p>As you can see in this example, this pattern is particularly useful for combos that can appear in many views of an application.</p>
</div>]]></description><link>https://javathought.github.io/2012/02/18/Playgreater-framework-design-pattern-2-avoid-code-duplication-to-render-same-objects-in-differents-views.html</link><guid isPermaLink="true">https://javathought.github.io/2012/02/18/Playgreater-framework-design-pattern-2-avoid-code-duplication-to-render-same-objects-in-differents-views.html</guid><category><![CDATA[design patterns]]></category><category><![CDATA[ play framework]]></category><pubDate>Sat, 18 Feb 2012 00:00:00 GMT</pubDate></item><item><title><![CDATA[Play!> framework design pattern #1]]></title><description><![CDATA[<div class="paragraph">
<p>A bad pattern is to handle different code to manage edition of items and creation of new items in the forms.</p>
</div>
<div class="paragraph">
<p>Typically you&#8217;ll pass an issue to the form when editing an existing one, and no one for the form to create new ones. Taking codeboard as an example, this would result in the following code in the controller and the template :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>you don&#8217;t pass an issue object to the Play!&gt; render method in newIssue() of the controller.</p>
</li>
<li>
<p>you pass an issue object to the render on issue() method (edition)</p>
</li>
<li>
<p>you handle behaviour of your form in the groovy template, particully managing default value which is not trivial for drop down list for example</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">    public static void newIssue(String identifier) {
            List&lt;Tracker&gt; trackers = Tracker.find("order by position asc").fetch();
            Project project = Project.find("identifier", identifier).first();
            List&lt;User&gt; users = User.find("order by login").fetch();
            List&lt;State&gt; states = State.find("order by position").fetch();
            List&lt;Enumeration&gt; priorities = Enumeration.find("byType", "IssuePriority").fetch();
            render("@issue", trackers, project, users, states, priorities);
    }

    public static void issue(Long id) {
            Issue issue = Issue.findById(id);
            Project project = issue.project;
            List&lt;Tracker&gt; trackers = Tracker.find("order by position asc").fetch();
            List&lt;User&gt; users = User.find("order by login").fetch();
            List&lt;State&gt; states = State.find("order by position").fetch();
            List&lt;Enumeration&gt; priorities = Enumeration.find("byType", "IssuePriority").fetch();
            render(issue, project, trackers, users, states, priorities);
           }</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">    #{if issue?.priority?.id}
    #{select 'priorityId', items:priorities, valueProperty:'id', labelProperty:'name', id:'priority', value:"${issue?.priority?.id}" /}
    #{/if}
    #{else}
    #{select 'priorityId', items:priorities, valueProperty:'id', labelProperty:'name', id:'priority', value:"2" /}
    #{/else}</code></pre>
</div>
</div>
<div class="paragraph">
<p>This is not the better way to handle the form :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>you have distinct code for edition and creation</p>
</li>
<li>
<p>you template handle default value (line 5 of the template sample code above), and the code is no more valid if you have an administration page to change default values (as it is possible in codebaord)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The good pattern is to create a new instance of the object in the model class :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>the object will be passed to the form, thus not difference between edition and creation in forms</p>
</li>
<li>
<p>the model will handle default values or examples, which can be changed by administrators, and therefore be dynamic</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The example below show the Issue model with management of default values that can be modified in others forms :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">        public Issue(Project project) {
         this.project = project;
                this.state = State.find("isDefault = ?", true).first();

                this.priority = Enumeration.find("type = ? and is_default = ?", Enumeration.ISSUE_PRIORITY_TYPE, true).first();

        }</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now the difference between the method of creation and edition in the controller are just different by the initialisation of the issue object passed to the renderer :</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>on edition, find the object by id (passed by the url)</p>
</li>
<li>
<p>on creation, create a new issue</p>
</li>
</ol>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">    public static void newIssue(String identifier) {
        Project project = Project.find("identifier", identifier).first();
        Issue issue = new Issue(project);

        List&lt;Tracker&gt; trackers = Tracker.find("order by position asc").fetch();
        List&lt;User&gt; users = User.find("login &lt;&gt; 'root' order by login").fetch();
        List&lt;State&gt; states = State.find("order by position").fetch();
        List&lt;Enumeration&gt; priorities = Enumeration.find("byType", Enumeration.ISSUE_PRIORITY_TYPE).fetch();

        render("@issue", issue, trackers, users, states, priorities);
    }

    public static void editIssue(Long id) {
        Issue issue = Issue.findById(id);

        List&lt;Tracker&gt; trackers = Tracker.find("order by position asc").fetch();
        List&lt;User&gt; users = User.find("login &lt;&gt; 'root' order by login").fetch();
        List&lt;State&gt; states = State.find("order by position").fetch();
        List&lt;Enumeration&gt; priorities = Enumeration.find("byType", Enumeration.ISSUE_PRIORITY_TYPE).fetch();

        render("@issue", issue, trackers, users, states, priorities);
    }</code></pre>
</div>
</div>
<div class="paragraph">
<p>Then the code for the drop down list in groovy is just <strong>1 line of code</strong> now !</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">#{select 'issue.priority.id', items:priorities, valueProperty:'id', labelProperty:'name', id:'priority', value:"${issue?.priority?.id}" /}</code></pre>
</div>
</div>]]></description><link>https://javathought.github.io/2012/02/16/Playgreater-framework-design-pattern-1.html</link><guid isPermaLink="true">https://javathought.github.io/2012/02/16/Playgreater-framework-design-pattern-1.html</guid><category><![CDATA[design patterns]]></category><category><![CDATA[ play framework]]></category><pubDate>Thu, 16 Feb 2012 00:00:00 GMT</pubDate></item><item><title><![CDATA[Cross-Origin Resource Sharing with Play! framework]]></title><description><![CDATA[<div class="paragraph">
<p>I was trying to develop with play! framework for a 3-tier achitecture. So I run 2 applications on the same machine but on 2 differents ports (the front on 9010 and the back application on 9011 that has access to the database).</p>
</div>
<div class="paragraph">
<p>Trying to call WS services (with JSON format) from the front controllers is transparent.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">public static void index() {
    HttpResponse response = WS.url("http://localhost:9011/api/accounts").get();
    JsonElement json = response.getJson();

    render(json);
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>But trying to make dynamic pages with JQuery querying from the front page the the back controller, the results were blocked due tothe <a href="http://en.wikipedia.org/wiki/Same_origin_policy">Same Origin Policy</a>. So I had to specify the <a href="http://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing">Cross-Origin Resource Sharing</a> on the back controller.</p>
</div>
<div class="paragraph">
<p>Here is the code to add on the controller of the backapplication : this will add the header to allow the caller to access the service :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">public static void listAccounts() {
    List&lt;Account&gt; accounts = Account.findAll();
    Http.Header hd = new Http.Header();
    hd.name = "Access-Control-Allow-Origin";
    hd.values = new ArrayList&lt;String&gt;();
    hd.values.add("http://localhost:9010");
    Http.Response.current().headers.put("Access-Control-Allow-Origin",hd);
    renderJSON(accounts);

}</code></pre>
</div>
</div>
<div class="paragraph">
<p>You can sepecify a list of domains to accept as origin, or set it to <em>*</em> to allow all domains to call your service.</p>
</div>
<div class="paragraph">
<p>And the JQuery call :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">$("#accounts").click(function(){

    $.getJSON('http://localhost:9011/api/accounts', function(accounts) {
        var items = [];

        $.each(accounts, function(title, acc) {
            console.log(acc);
            $("#results").append('&lt;p&gt;'+acc.number+'&lt;/p&gt;');
        });
    });

});</code></pre>
</div>
</div>
<div class="paragraph">
<p>You can generalize the CORS setting with the @Before annotation, so all your services in a class will be accessible :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">    @Before
    public static void setCORS() {
        Http.Header hd = new Http.Header();
        hd.name = "Access-Control-Allow-Origin";
        hd.values = new ArrayList&lt;String&gt;();
        hd.values.add("http://localhost:9010");
        Http.Response.current().headers.put("Access-Control-Allow-Origin",hd);

    }</code></pre>
</div>
</div>
<div class="paragraph">
<p>Then your services coding in the controller is wery simple :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">    public static void listAccounts() {
        List&lt;Account&gt; accounts = Account.findAll();
        renderJSON(accounts);

    }</code></pre>
</div>
</div>]]></description><link>https://javathought.github.io/2011/12/04/Cross-Origin-Resource-Sharing-with-Play-framework.html</link><guid isPermaLink="true">https://javathought.github.io/2011/12/04/Cross-Origin-Resource-Sharing-with-Play-framework.html</guid><category><![CDATA[CORS]]></category><category><![CDATA[ Cross-Origin Resource Sharing]]></category><category><![CDATA[ playframework]]></category><pubDate>Sun, 04 Dec 2011 00:00:00 GMT</pubDate></item><item><title><![CDATA[Sonar & Ant]]></title><description><![CDATA[<div class="paragraph">
<p>Sonar is made for maven. Nothing to do and it works.</p>
</div>
<div class="paragraph">
<p>There&#8217;s now a ant task to use sonar on your project build by ant. You&#8217;ll have the same results, except that by default, you will not have the results of your tests (passed/failed) and the coverage of your tests. To add them in your sonar pass, you have to :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>add a cobertura task in your ant task (just follow cobertura how to, installation and adding the task). With maven, the coverage is automatically calculated when sonar is launched (mvn sonar:sonar).</p>
</li>
<li>
<p>add 2 properties (&lt;code&gt;sonar.cobertura.reportPath&lt;/code&gt; and &lt;code&gt;sonar.surefire.reportsPath&lt;/code&gt;) in the sonar task to include reports (test and coverage) generated by junit and cobertura tasks. They must point to the reports generated.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Here&#8217;s the sonar task that will include the two reports generated by <em>junit</em> and <em>cobertura</em>  tasks :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">&lt;taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml"&gt;
    &lt;!-- classpath path="path/to/sonar/ant/task/lib" / --&gt;
    &lt;!-- This sonar Ant task library can also be put in the ${ANT_HOME\}/lib directory--&gt;
    &lt;!-- In such case this classpath node is no more mandatory --&gt;
&lt;/taskdef&gt;

&lt;!-- Out-of-the-box those parameters are optional --&gt;
&lt;!-- EXAMPLE FOR MYSQL --&gt;
&lt;property name="sonar.jdbc.url" value="jdbc:mysql://192.168.1.3:3306/sonar?useUnicode=true&amp;amp;characterEncoding=utf8" /&gt;
&lt;property name="sonar.jdbc.driverClassName" value="com.mysql.jdbc.Driver" /&gt;
&lt;property name="sonar.jdbc.username" value="sonar" /&gt;
&lt;property name="sonar.jdbc.password" value="sonar" /&gt;

&lt;target name="sonar"&gt;
    &lt;!-- list of mandatories Sonar properties --&gt;
    &lt;property name="sonar.sources" value="src" /&gt;

    &lt;!-- list of optional Sonar properties --&gt;
    &lt;!-- property name="sonar.projectName" value="this value overrides the name defined in Ant root node" / --&gt;
    &lt;!-- property name="sonar.binaries" value="list of directories which contain for example the Java bytecode" / --&gt;
    &lt;!-- property name="sonar.tests" value="unittest" / --&gt;
    &lt;!-- property name="sonar.libraries" value="list of paths to libraries separated by a comma (These libraries are for example used by the Sonar Findbugs plugin)" / --&gt;
    &lt;property name="sonar.cobertura.reportPath" value="${cobertura.report.dir}/coverage.xml"/&gt;
    &lt;property name="sonar.surefire.reportsPath" value="${build.test.dir}" /&gt;

    &lt;sonar:sonar key="groupId:aretefactId version="0.1-SNAPSHOT" xmlns:sonar="antlib:org.sonar.ant"&gt;
        &lt;tests&gt;
            &lt;path location="test" /&gt;
        &lt;/tests&gt;
    &lt;/sonar:sonar&gt;
&lt;/target&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>I&#8217;ve put the jar of the sonar plugin in ant library directory, so the classpath to sonar is left blank. And if you&#8217;ve install the sonar plugin in eclipse, you&#8217;ll have to remember the groupId and artefactId to link the project with the sonar results. And the advantage is that you&#8217;ll have the link betwwen the violations and the source line directly in eclipse.</p>
</div>]]></description><link>https://javathought.github.io/2011/11/12/Sonar-and-Ant.html</link><guid isPermaLink="true">https://javathought.github.io/2011/11/12/Sonar-and-Ant.html</guid><category><![CDATA[ant]]></category><category><![CDATA[ cobertura]]></category><category><![CDATA[ continuous integration]]></category><category><![CDATA[ jenkins]]></category><pubDate>Sat, 12 Nov 2011 00:00:00 GMT</pubDate></item><item><title><![CDATA[Professional Android 2 development - Error in Chapter 5]]></title><description><![CDATA[<div class="paragraph">
<p>If you encountered an error  in this chapter, calling the managedQuery function, the easy to find <a href="http://p2p.wrox.com/book-professional-android-2-application-development/82392-chapter-5-contact-picker-example.html">correction is mentioned here</a> on editor "p2p" (programmer to programmer) site.</p>
</div>
<div class="paragraph">
<p>More interesting info is the replacement of the use of the deprecated class People.</p>
</div>
<div class="paragraph">
<p>But this don&#8217;t mention the correction for the "Force close" when launching the app on Android 2.3.3.</p>
</div>]]></description><link>https://javathought.github.io/2011/08/07/Professional-Android-2-development-Error-in-Chapter-5.html</link><guid isPermaLink="true">https://javathought.github.io/2011/08/07/Professional-Android-2-development-Error-in-Chapter-5.html</guid><category><![CDATA[Android]]></category><category><![CDATA[ contact pick]]></category><category><![CDATA[ Force close]]></category><category><![CDATA[ Programming]]></category><pubDate>Sun, 07 Aug 2011 00:00:00 GMT</pubDate></item><item><title><![CDATA[get hostname in ant easily]]></title><description><![CDATA[<div class="paragraph">
<p>After searching a while, here is the best way I found to get the hostname in a propert. Just use exec task :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">&lt;exec dir="${basedir}" executable="hostname" outputproperty="host.name"&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>The trick is the attribute outputpropety of the exec task. You can then use ${host.name} variable to use the hostname in your ant scripts.</p>
</div>]]></description><link>https://javathought.github.io/2011/08/02/get-hostname-in-ant-easily.html</link><guid isPermaLink="true">https://javathought.github.io/2011/08/02/get-hostname-in-ant-easily.html</guid><category><![CDATA[ant]]></category><category><![CDATA[ hostname]]></category><pubDate>Tue, 02 Aug 2011 00:00:00 GMT</pubDate></item><item><title><![CDATA[Ubuntu, XFS and Buffalo NAS - Part 2]]></title><description><![CDATA[<div class="paragraph">
<p>In part 1, I explained how to mount the drive one time, but you&#8217;ll have to comment the params in <a href="http://en.wikipedia.org/wiki/Fstab">/etc/fstab</a> in order to disabled a block at startup when the drive is not present, and as an USB drive, if the number of drives connected at boot time is not the same, the drive will not have the same partition definition (the /dev/sdd will perhaps be /dev/sdc next time).</p>
</div>
<div class="paragraph">
<p>So a better option is to use the UUID of the drive and set the auto mount option. To gert the UUID, launch <a href="http://gparted.sourceforge.net">gparted</a> again and right click on the partition. In the dialog box you&#8217;ll have a item will the UUID of the partition. Just copy the value. Edit again /etc/fstab and set the line of mount point the the code below this time :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-text" data-lang="text">UUID=&lt;value copied&gt;       /media/MyXFSDrive xfs user,auto 0 0</code></pre>
</div>
</div>
<div class="paragraph">
<p>Related articles</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="http://sandeepbhalla.wordpress.com/2011/05/21/uuids-in-ubuntu-unix-tutorial/">UUIDs in Ubuntu | Unix Tutorial</a> (sandeepbhalla.wordpress.com)</p>
</li>
<li>
<p><a href="http://computerandu.wordpress.com/2011/05/12/how-to-mount-a-windows-partition-on-linux-automatically-on-each-start-up/">How to mount a windows partition on Linux automatically on each start up</a> (computerandu.wordpress.com)</p>
</li>
</ul>
</div>]]></description><link>https://javathought.github.io/2011/07/01/Ubuntu-XFS-and-Buffalo-NAS-Part-2.html</link><guid isPermaLink="true">https://javathought.github.io/2011/07/01/Ubuntu-XFS-and-Buffalo-NAS-Part-2.html</guid><category><![CDATA[Fstab]]></category><category><![CDATA[ GParted]]></category><category><![CDATA[ Mount]]></category><category><![CDATA[ ubuntu]]></category><category><![CDATA[ Universally unique identifier]]></category><pubDate>Fri, 01 Jul 2011 00:00:00 GMT</pubDate></item><item><title><![CDATA[Where's Asphalt 5 in Samsung Apps]]></title><description><![CDATA[<div class="paragraph">
<p>As said in my previous post, I&#8217;ve made a factory reset to my Galaxy S. So I want to reinstall my apps &#8230;&#8203; and Aspahtl 5 from SamsungApps. But it&#8217;s not in the list of apps.</p>
</div>
<div class="paragraph">
<p>In fact, it&#8217;s a bit hidden. You have to go to Menu &#8594; Download, and you&#8217;ll see previous installed apps, included Aspahalt 5.</p>
</div>
<div class="paragraph">
<p><strong>Edit</strong> : by the way, I found it now on the market and there&#8217;s a free version !</p>
</div>]]></description><link>https://javathought.github.io/2011/06/26/Wheres-Asphalt-5-in-Samsung-Apps.html</link><guid isPermaLink="true">https://javathought.github.io/2011/06/26/Wheres-Asphalt-5-in-Samsung-Apps.html</guid><category><![CDATA[Android]]></category><category><![CDATA[ asphalt]]></category><category><![CDATA[ free]]></category><category><![CDATA[ game]]></category><category><![CDATA[ gameloft]]></category><pubDate>Sun, 26 Jun 2011 00:00:00 GMT</pubDate></item><item><title><![CDATA[Nice borders for lightroom]]></title><description><![CDATA[<div class="paragraph">
<p><a href="http://www.tipsquirrel.com/index.php/2010/09/5-creative-borders-for-lightroom/" class="bare">http://www.tipsquirrel.com/index.php/2010/09/5-creative-borders-for-lightroom/</a></p>
</div>]]></description><link>https://javathought.github.io/2011/06/26/Nice-borders-for-lightroom.html</link><guid isPermaLink="true">https://javathought.github.io/2011/06/26/Nice-borders-for-lightroom.html</guid><category><![CDATA[lightroom]]></category><pubDate>Sun, 26 Jun 2011 00:00:00 GMT</pubDate></item><item><title><![CDATA[My favorite clock on Android]]></title><description><![CDATA[<div class="paragraph">
<p>As I&#8217;ve to do a factory reset, I&#8217;m re-installing my apps and widgets. Searching my clock&#8217;s widget, I (re)discovered that it was not on the market.</p>
</div>
<div class="paragraph">
<p>So, if as me your favorite clock is TypoClock, here it is (as a reminder for me) : <a href="http://forum.xda-developers.com/showthread.php?t=814054">the thread on xda</a></p>
</div>
<div class="paragraph">
<p>Related articles</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="http://www.androidguys.com/2011/04/06/review-typo-clock-widget/">Review: Typo Clock (Widget)</a> (androidguys.com)</p>
</li>
</ul>
</div>]]></description><link>https://javathought.github.io/2011/06/19/My-favorite-clock-on-Android.html</link><guid isPermaLink="true">https://javathought.github.io/2011/06/19/My-favorite-clock-on-Android.html</guid><category><![CDATA[Android]]></category><category><![CDATA[ typocock]]></category><category><![CDATA[ widget]]></category><pubDate>Sun, 19 Jun 2011 00:00:00 GMT</pubDate></item><item><title><![CDATA[Ubuntu, XFS and Buffalo NAS]]></title><description><![CDATA[<div class="imageblock">
<div class="content">
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Hdd.jpg/300px-Hdd.jpg" alt="Image of a Western Digital 250Gb SATA Hard Dri...">
</div>
<div class="title">Figure 1. Image of a Western Digital 250Gb SATA Hard Dri&#8230;&#8203;</div>
</div>
<div class="paragraph">
<p>I use a NAS as my main drive to maintain my datas shared against my computers (and to not have to make copies when changing it). But my Buffallo crashed a disk for the second time (the same one,  I think it&#8217;s corrupted and I&#8217;ll try to have it replaced by the support).</p>
</div>
<div class="paragraph">
<p>But before sending it back to consumer&#8217;s service, I want to have my datas back on a rescue disk. So I wanted to use the safe disk to copy files on a third drive. The problem is that the disks use <a href="http://en.wikipedia.org/wiki/XFS">XFS</a> filesystem. No way to copy files from Winows. Fortunately, I have a dual boot with <a href="http://www.ubuntu.com/">Ubuntu</a>, that natively can read XFS ;) . so below are the steps to achieve the copy process :</p>
</div>
<div class="paragraph">
<p>Get the packages to support XFS :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">&gt; sudo apt-get install xfsprogs
&gt; sudo apt-get install xfsdump
&gt; sudo apt-get install gparted</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now you have to identify the partition to mount : use gparted</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/screenshot-dev-sdd-gparted.png" alt="image">
</div>
<div class="title">Figure 2. Screenshot&#8212;&#8203;dev-sdd - GParted</div>
</div>
<div class="paragraph">
<p>You can use the drop down list on the top right to select your hard drive, then you&#8217;ll see the list of partition; just identify your partition with XFS filesystem (/dev/sdd6 in my case).</p>
</div>
<div class="paragraph">
<p>So next step is  to edit /etc/fstab to specify the mount characteristic (filesystem type : xfs and associated <a href="http://en.wikipedia.org/wiki/Mount_%28computing%29">mount point</a> : /media/whatYouWant ) ; just add the line above</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-text" data-lang="text">/dev/sdd6    /media/MyXFSDrive xfs defaults 0 0</code></pre>
</div>
</div>
<div class="paragraph">
<p>No create the mount point for your drive and mount it :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">&gt; sudo mkdir/media/MyXFSDrive
&gt; sudo mount /dev/sdd6</code></pre>
</div>
</div>
<div class="paragraph">
<p>It&#8217;s finished, you can access your drive and make your backups.</p>
</div>]]></description><link>https://javathought.github.io/2011/06/18/Ubuntu-XFS-and-Buffalo-NAS.html</link><guid isPermaLink="true">https://javathought.github.io/2011/06/18/Ubuntu-XFS-and-Buffalo-NAS.html</guid><pubDate>Sat, 18 Jun 2011 00:00:00 GMT</pubDate></item><item><title><![CDATA[Ubuntu server & keyboard]]></title><description><![CDATA[<div class="paragraph">
<p>I installed ubuntu 11.04 server but the keyboard was 'us'. Not quite efficient with my french one.</p>
</div>
<div class="paragraph">
<p>Searching on the web, it&#8217;s often said to use :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">dpkg-reconfigure console-setup</code></pre>
</div>
</div>
<div class="paragraph">
<p>But in fact, I didn&#8217;t found a keyboard option.</p>
</div>
<div class="paragraph">
<p>Just launch :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">sudo loadkeys fr</code></pre>
</div>
</div>]]></description><link>https://javathought.github.io/2011/06/17/Ubuntu-server-and-keyboard.html</link><guid isPermaLink="true">https://javathought.github.io/2011/06/17/Ubuntu-server-and-keyboard.html</guid><category><![CDATA[ubuntu]]></category><pubDate>Fri, 17 Jun 2011 00:00:00 GMT</pubDate></item><item><title><![CDATA[Ubuntu Unity and VirtualBox]]></title><description><![CDATA[<div class="paragraph">
<p>I have a dual boot Windows7 / Ubuntu 11 on my recent laptop and I started enjoying Unity. I also installed VirtualBox on W7 to make tests on n-tier servers.</p>
</div>
<div class="paragraph">
<p>On these virtual installations of Ubuntu I couldn&#8217;t have the Unity interface : the reason is simple, Unity need graphic acceleration, so do not forget to check the graphic acceleration in the configuration of your virtual machine.</p>
</div>]]></description><link>https://javathought.github.io/2011/06/15/Ubuntu-Unity-and-VirtualBox.html</link><guid isPermaLink="true">https://javathought.github.io/2011/06/15/Ubuntu-Unity-and-VirtualBox.html</guid><category><![CDATA[ubuntu]]></category><category><![CDATA[ unity]]></category><category><![CDATA[ virtualbox]]></category><pubDate>Wed, 15 Jun 2011 00:00:00 GMT</pubDate></item><item><title><![CDATA[No rotation on Samsung Galaxy S Froyo 2.2.1  : how to restore it]]></title><description><![CDATA[<div class="paragraph">
<p>I recently lost the rotation auto on my Galaxy S, and it was not to toggle on the button "rotation auto" in the status bar. Even "calling" the <strong><mark>0</strong></mark> menu to Sensor item did not detected the sensor. So, thanks <a href="http://forum.xda-developers.com/showthread.php?t=816131&amp;page=2">xda-developers for the solution</a>. The hard part was to foun a way to get root on a 2.2.1 SGS.</p>
</div>
<div class="paragraph">
<p>The full answer is :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Set the USB debug mode on your phone and connect it to your PC</p>
</li>
<li>
<p>you&#8217;ll have to be root to restore it : the problem is that firmware 2.2.1 check the signature of update.zip files. So I can&#8217;t install them with adb. The solution was to install <a href="http://forum.xda-developers.com/showthread.php?t=803682">SuperOneClickv1.9.1-ShortFuse (again on xda)</a> to get the phone rooted.It will also install busybox if not found</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Then you can run a terminal and call <strong>su</strong>. Now you can run the last two steps in the shell</p>
</div>
<div class="ulist">
<ul>
<li>
<p>the second step is to remove (or rename) the file in <strong>/data/system/ms3c_yamaha.cfg</strong></p>
</li>
<li>
<p>the third is to run <strong>/system/bin/sensorcalibutil_yamaha</strong></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>And Voilà! No reboot.  You&#8217;ll have the rotation on Google, the compass will work again and you&#8217;ll can play your favorites games (eg car race games). And personally, my clock I launch when I go to bed (it&#8217;s the way I noticed there was no more auto rotation).</p>
</div>]]></description><link>https://javathought.github.io/2011/05/23/No-rotation-on-Samsung-Galaxy-S-Froyo-221-how-to-restore-it.html</link><guid isPermaLink="true">https://javathought.github.io/2011/05/23/No-rotation-on-Samsung-Galaxy-S-Froyo-221-how-to-restore-it.html</guid><category><![CDATA[Android]]></category><category><![CDATA[ root]]></category><category><![CDATA[ rotation]]></category><category><![CDATA[ Samsung Galaxy S]]></category><pubDate>Mon, 23 May 2011 00:00:00 GMT</pubDate></item><item><title><![CDATA[Set up a ftp server in windows 7]]></title><description><![CDATA[<div class="paragraph">
<p>To make tests on my application, I needed a ftp server. On my previous desktop with XP, I installed a free frtp server. So I thought I&#8217;ll make on my new Windows 7 computer. But there&#8217;s an embedded server in Windows 7.</p>
</div>
<div class="paragraph">
<p>Just go to "<strong>Control panel</strong>" then "<strong>Programs</strong>" and "<strong>Turn windows features on or off</strong>". You&#8217;ll just have to go down to "<strong>Internet Information Services</strong>" (or IIS) and select <strong>FTP Server</strong> AND <strong>IIS management console</strong>. See the screenshot below (in french) :</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/win7_ftp1.png?w=300" alt="image">
</div>
<div class="title">Figure 1. Win7_ftp</div>
</div>
<div class="paragraph">
<p>Then you have to administrate your IIS : in control panel, click <strong>System and Security</strong>, and then click <strong>Administrative Tools</strong> and launch <strong>IIS Manager</strong>. There just add a FTP site (right click on the <strong>Sites</strong> folder).</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/win7_ftp_iismanager.png?w=300" alt="image">
</div>
<div class="title">Figure 2. Win7_ftp_IISManager</div>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Enter a name for the site and the file path to the directory that will host your site</p>
</li>
</ol>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/win7_ftp_site1.png?w=300" alt="image">
</div>
<div class="title">Figure 3. Win7_ftp_site1</div>
</div>
<div class="olist arabic">
<ol class="arabic" start="2">
<li>
<p>Enter the properties for the connection to the site</p>
</li>
</ol>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/win7_ftp_site2.png?w=300" alt="image">
</div>
<div class="title">Figure 4. Win7_ftp_site2</div>
</div>
<div class="olist arabic">
<ol class="arabic" start="3">
<li>
<p>Enter the authentifications rules (authentification mode, anonymous connection, read/write access)</p>
</li>
</ol>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/win7_ftp_site3.png?w=300" alt="image">
</div>
<div class="title">Figure 5. Win7_ftp_site3</div>
</div>
<div class="paragraph">
<p>And you&#8217;re gone with your ftp site : no download, run as a service; the hard part is to know it&#8217;s included in Windows 7 and where to find it.</p>
</div>]]></description><link>https://javathought.github.io/2011/05/22/Set-up-a-ftp-server-in-windows-7.html</link><guid isPermaLink="true">https://javathought.github.io/2011/05/22/Set-up-a-ftp-server-in-windows-7.html</guid><pubDate>Sun, 22 May 2011 00:00:00 GMT</pubDate></item><item><title><![CDATA[My personal home on my smartphone]]></title><description><![CDATA[<div class="paragraph">
<p>My personal home on my <a href="http://en.wikipedia.org/wiki/Samsung_Galaxy_S">Galaxy S</a> (WIP) :</p>
</div>
<div class="paragraph">
<p><strong>Details</strong> : Go Launcher with 3 more icons (for a total of 15) made by me for the dock (GTalk, TweetDeck &amp; Facebook) - Wallpaper from LP.</p>
</div>
<div class="paragraph">
<p>- Screen 1 : TypoClockText - Battery Widget (may be later replaced by BattStatt) - MinimalistText</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Screen 2 : Google widgetCalWidget</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>- Screen 3 : Smooth Calendar - Games icons (from iPhone theme) resized by me - Go LauncherImage folders - Dektop Visualizer (contact link) - 4 icons for apps by me</p>
</div>
<div class="imageblock">
<div class="content">
<img src="http://banks.free.fr/images/Home1-Screen1.png" alt="image">
</div>
<div class="title">Figure 1. Screen 1</div>
</div>
<div class="imageblock">
<div class="content">
<img src="http://banks.free.fr/images/Home1-Screen2.png" alt="image">
</div>
<div class="title">Figure 2. Screen 2</div>
</div>
<div class="imageblock">
<div class="content">
<img src="http://banks.free.fr/images/Home1-Screen3.png" alt="image">
</div>
<div class="title">Figure 3. Screen 3</div>
</div>]]></description><link>https://javathought.github.io/2011/05/19/My-personal-home-on-my-smartphone.html</link><guid isPermaLink="true">https://javathought.github.io/2011/05/19/My-personal-home-on-my-smartphone.html</guid><category><![CDATA[Android]]></category><category><![CDATA[ Galaxy S]]></category><category><![CDATA[ Samsung]]></category><category><![CDATA[ UI]]></category><pubDate>Thu, 19 May 2011 00:00:00 GMT</pubDate></item><item><title><![CDATA[Activate telnet on Windows 7]]></title><description><![CDATA[<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/21545v2-max-450x450.png" alt="Image representing Windows as depicted in Crun...">
</div>
<div class="title">Figure 1. Image representing Windows as depicted in Crun&#8230;&#8203;</div>
</div>
<div class="paragraph">
<p>By default Telnet is not available in Windows 7. Just type the two following commands and the command will be "back" in your new Windows version :</p>
</div>
<div class="paragraph">
<p>pkgmgr /iu:TelnetClient
pkgmgr /iu:TelnetServer</p>
</div>
<div class="paragraph">
<p>[/sourcecode]</p>
</div>]]></description><link>https://javathought.github.io/2011/05/10/Activate-telnet-on-Windows-7.html</link><guid isPermaLink="true">https://javathought.github.io/2011/05/10/Activate-telnet-on-Windows-7.html</guid><pubDate>Tue, 10 May 2011 00:00:00 GMT</pubDate></item><item><title><![CDATA[My Samsung Galaxy S and Android froyo 2.2]]></title><description><![CDATA[<div class="paragraph">
<p>I&#8217;ve just upgraded my android phone with the froyo 2.2 version.</p>
</div>
<div class="paragraph">
<p>Though you can see the <a href="http://developer.android.com/sdk/android-2.2-highlights.html" class="bare">http://developer.android.com/sdk/android-2.2-highlights.html</a>, there&#8217;s a number of interesting new features I noticed. Some are from the Samsung user interface "TouchWiz".</p>
</div>
<div class="paragraph">
<p>The first one is the stamp on sms, e-mail with the numbber of unread items.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/device-1.png?w=180" alt="image">
</div>
<div class="title">Figure 1. TouchWiz home screen</div>
</div>
<div class="paragraph">
<p>The management of the seven home screens is also reviewed : with the pinch gesture, you can have a view of the 7 small screen you can arrange with drag and drop and delete dragging to the  dust bin.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/device-16.png?w=180" alt="image">
</div>
<div class="title">Figure 2. device-16</div>
</div>
<div class="paragraph">
<p>On my first home screen, I&#8217;ve put :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>the new fancy widget with the comic weather theme (yes, themes are available now, and a pro version too)</p>
</li>
<li>
<p>google navigation shortcuts (I&#8217;ll write a review soon, with the enhancement I&#8217;m awaiting to make it the perfect tool for navigation)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>There&#8217;s some new standard applications too :</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/device-2b.png?w=180" alt="image">
</div>
<div class="title">Figure 3. Home screen</div>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/device-3.png?w=180" alt="image">
</div>
<div class="title">Figure 4. a new application</div>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/device-15.png?w=180" alt="image">
</div>
<div class="title">Figure 5. the main application management screen</div>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/device-14.png?w=180" alt="image">
</div>
<div class="title">Figure 6. move to SD-Card</div>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/device-5.png?w=180" alt="image">
</div>
<div class="title">Figure 7. unavailable service</div>
</div>
<div class="paragraph">
<p>Yes, Press Reader is new and not "online" for the moment.</p>
</div>
<div class="paragraph">
<p>The management of applications has changed too :</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/device-4.png?w=180" alt="image">
</div>
<div class="title">Figure 8. Suppress an application</div>
</div>
<div class="paragraph">
<p>and the market comes with his new features :</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/device-12.png?w=180" alt="image">
</div>
<div class="title">Figure 9. batch upgrade</div>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/device-13.png?w=180" alt="image">
</div>
<div class="title">Figure 10. Auto upgrade</div>
</div>
<div class="paragraph">
<p>A great enhancement is the new feature of text selection, copy/cut/paste :</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/device-7.png?w=180" alt="image">
</div>
<div class="title">Figure 11. Text selection</div>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/device-8.png?w=180" alt="image">
</div>
<div class="title">Figure 12. drag to select</div>
</div>
<div class="paragraph">
<p>Once you have already made a copy or cut, there&#8217;s also  a paste icon available.</p>
</div>
<div class="paragraph">
<p>The newq notification bar have new toggle buttons :</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/device-9.png?w=180" alt="image">
</div>
<div class="title">Figure 13. new buttons</div>
</div>
<div class="paragraph">
<p>The goggle enhanced search tool :</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/device-11.png?w=180" alt="image">
</div>
<div class="title">Figure 14. google search</div>
</div>
<div class="paragraph">
<p>It&#8217;s nothing but a little change in the colors :</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/device-10.png?w=180" alt="image">
</div>
<div class="title">Figure 15. popup dialog</div>
</div>
<div class="paragraph">
<p>And some more colors again :</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/device-6.png?w=180" alt="image">
</div>
<div class="title">Figure 16. new menu colors</div>
</div>]]></description><link>https://javathought.github.io/2010/11/27/My-Samsung-Galaxy-S-and-Android-froyo-22.html</link><guid isPermaLink="true">https://javathought.github.io/2010/11/27/My-Samsung-Galaxy-S-and-Android-froyo-22.html</guid><category><![CDATA[froyo]]></category><category><![CDATA[ Galaxy S]]></category><pubDate>Sat, 27 Nov 2010 00:00:00 GMT</pubDate></item><item><title><![CDATA[Photo of hd]]></title><description><![CDATA[<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/wpid-2010-10-25-23-48-15.jpg" alt="wpid 2010 10 25 23 48 15.jpg">
</div>
</div>
<div class="paragraph">
<p>Posted from WordPress for Android</p>
</div>]]></description><link>https://javathought.github.io/2010/10/25/Photo-of-hd.html</link><guid isPermaLink="true">https://javathought.github.io/2010/10/25/Photo-of-hd.html</guid><pubDate>Mon, 25 Oct 2010 00:00:00 GMT</pubDate></item><item><title><![CDATA[HD is up]]></title><description><![CDATA[<div class="paragraph">
<p>That was just the SATA-USB2 adapter that was KO. Just open the WD box, extract the HDD, extract the usb card from the sata port. You can view many videos of these steps on youtube :</p>
</div>
<div class="videoblock">
<div class="content">
<iframe src="https://www.youtube.com/embed/cQ0bgz3tyNk?rel=0" frameborder="0" allowfullscreen></iframe>
</div>
</div>
<div class="paragraph">
<p>Then put it back in a nice new box (mine can host odd and sata) and plug the new plug via USB : you WD passport is back with all tour datas.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/wpid-2010-10-25-23-48-15.jpg" alt="image">
</div>
<div class="title">Figure 1. wpid-2010-10-25-23.48.15.jpg</div>
</div>
<div class="paragraph">
<p>Posted from WordPress for Android</p>
</div>]]></description><link>https://javathought.github.io/2010/10/25/HD-is-up.html</link><guid isPermaLink="true">https://javathought.github.io/2010/10/25/HD-is-up.html</guid><category><![CDATA[Passport]]></category><category><![CDATA[ Western Digital]]></category><pubDate>Mon, 25 Oct 2010 00:00:00 GMT</pubDate></item><item><title><![CDATA[Wordpress for android]]></title><description><![CDATA[<div class="paragraph">
<p>I just installed Wordpress for Android : really great app, a good example of android ui.</p>
</div>
<div class="paragraph">
<p>Posted from WordPress for Android</p>
</div>]]></description><link>https://javathought.github.io/2010/10/17/Wordpress-for-android.html</link><guid isPermaLink="true">https://javathought.github.io/2010/10/17/Wordpress-for-android.html</guid><category><![CDATA[Java; android;]]></category><pubDate>Sun, 17 Oct 2010 00:00:00 GMT</pubDate></item><item><title><![CDATA[HD out of service]]></title><description><![CDATA[<div class="paragraph">
<p>My external HD with the tutorials does not work any more. I&#8217;ll try with a double USB cable to verify if this is due to insufficient electric power. Otherwise, I&#8217;ll have to admit that it is definitly Out Of Order :-(</p>
</div>]]></description><link>https://javathought.github.io/2010/10/13/HD-out-of-service.html</link><guid isPermaLink="true">https://javathought.github.io/2010/10/13/HD-out-of-service.html</guid><category><![CDATA[Passport]]></category><category><![CDATA[ Western Digital]]></category><pubDate>Wed, 13 Oct 2010 00:00:00 GMT</pubDate></item><item><title><![CDATA[Play! how to make master-detail views]]></title><description><![CDATA[<div class="paragraph">
<p>Continuing the taks tutorial project, we will add details to tasks. The detail will be a list of events on a task to make an history of what happened.</p>
</div>
<div class="paragraph">
<p>First we will add the Event class. If you use Eclipse and the Play! plugin, you can use the new play! menu :</p>
</div>
<div class="paragraph">
<p>image::screenshot-23.jpg[image,title="Play! Eclipse plugin"]]</p>
</div>
<div class="paragraph">
<p>The class will be very simple for this how-to :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">package models;

import play.*;
import play.db.jpa.*;

import javax.persistence.*;
import java.util.*;

@Entity
public class Event extends Model {
    public String status;
    public Date eventDate;
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Then we add the link between Task and Event; add this property to Task :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">    @OneToMany
    public List&lt;Event&gt; events;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now we will add a link in the current view to show the detail view, add a column with a html link :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">            &lt;td&gt;&lt;a href="@{task(task.id)}"&gt;&amp;gt;&lt;/a&gt;&lt;/td&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now we have to had the controller action task in Application :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">    public static void task(Long id) {
        Task task = Task.findById(id);
        render(task);
    }</code></pre>
</div>
</div>
<div class="paragraph">
<p>Last action is to write the task.html template. It will be very similar to the index template, except we will use the template tag on the <em>events</em> property of the rendered task object :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">#{extends 'main.html' /}
#{set title:'task history' /}

&lt;table&gt;
    &lt;thead&gt;
        &lt;tr&gt;
            &lt;th class="event"&gt;status&lt;/th&gt;
            &lt;th class="date"&gt;when&lt;/th&gt;
        &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
        #{list task.events, as:'event'}


        &lt;tr class="event" transferId="${event.id}" &gt;
            &lt;td id="status-${event.id}"&gt;${event.status}&lt;/td&gt;
            &lt;td id="when-${event.id}"&gt;${event.eventDate}&lt;/td&gt;
        &lt;/tr&gt;

        #{/list}
        &lt;tr&gt;
            #{form @saveEvent(task.id)}
            &lt;td&gt;&lt;input type="text" name="event.status"&gt;&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="event.when"&gt;&lt;/td&gt;
            &lt;td&gt;&lt;input type="submit" value="+"&gt;&lt;/td&gt;
            #{/form}
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>The important part is the save action; here we pass the id of the master object as it will be used in the save action in the controller. So here is the save action in Application :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">    public static void saveEvent(Long id, final Event event) {
        Task task = Task.findById(id);
        event.save();
        task.events.add(event);
        task.save();
        task(id);
    }</code></pre>
</div>
</div>
<div class="paragraph">
<p>In the controller,</p>
</div>
<div class="paragraph">
<p>we get back a reference to the master object (via the id passed from the view),</p>
</div>
<div class="paragraph">
<p>we save the event entered in the form</p>
</div>
<div class="paragraph">
<p>we add it to the events list property of the master</p>
</div>
<div class="paragraph">
<p>we then save the master object</p>
</div>
<div class="paragraph">
<p>and we call again the action to show the detail of the task.</p>
</div>
<div class="paragraph">
<p>So here is our master-detail views how to finished</p>
</div>
<div class="paragraph">
<p>.</p>
</div>]]></description><link>https://javathought.github.io/2010/10/06/Play-how-to-make-master-detail-views.html</link><guid isPermaLink="true">https://javathought.github.io/2010/10/06/Play-how-to-make-master-detail-views.html</guid><pubDate>Wed, 06 Oct 2010 00:00:00 GMT</pubDate></item><item><title><![CDATA[Play! edit your dates with JQuery (editinplace + datepicker) 2/2]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>So, continue this tutorial.</p>
</div>
<div class="paragraph">
<p>First we&#8217;ll add <a href="http://code.google.com/p/jquery-in-place-editor/">JQuery edit in place</a> to our task action. Download it from the google code site and extract it from the lib folder of the zip file. Copy it ito the javascripts folder (under public).</p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_add_an_editable_field">Add an editable field</h3>
<div class="paragraph">
<p>We can now add an editable field to our project. First modify main.html to include the script, adding this line :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">        &lt;script src="@{'public/javascripts/jquery.editinplace.js'}" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Then modify the templacte index.html. We will add some class tag to identify the field on which to apply edit in place capability. We will also an an id on the tag (it will be explained below). Is his the news record template :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">        &lt;tr class="task"&gt;
            &lt;td class="editable"  id="action-${task.id}"&gt;${task.action}&lt;/td&gt;
            &lt;td&gt;${task.due?.format('dd-MM-yyyy')}&lt;/td&gt;
            &lt;td&gt;&amp;gt;&lt;/td&gt;
        &lt;/tr&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>We&#8217;ve also tagged the <em>tr</em> tag : a goog practice to anticipate the presence of other datas in rows int the same screen. Next step is to apply the capability to the field, with a default callback function (no save to the model), in the script section of the template :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">         // In place edition
        $(".task td.editable").editInPlace({
            bg_over: 'transparent',
            callback: function(unused, enteredText) { return enteredText; }
        });</code></pre>
</div>
</div>
<div class="paragraph">
<p>Try the modify an action in a row : it&#8217;s ok but refresh the screen, the previous value is showned and your modification is lost.But we want to save our changes to the model (and so to be persistence). So we will modify the callback function to save data with AJAX.</p>
</div>
<div class="paragraph">
<p>We will try to be generic, making a single JQuery editinplace <em>declaration</em> to handled multiple data property (more than one column) been saved with one script.</p>
</div>
<div class="paragraph">
<p>What we have to do is</p>
</div>
<div class="ulist">
<ul>
<li>
<p>get the new value</p>
</li>
<li>
<p>get the internal identifier of the object displayed (remember we&#8217;ve add an id with the groovy tag $\{task.id})</p>
</li>
<li>
<p>post the data a fonction to save modifications.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Here is the new script code :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">        // In place edition
        $(".task td.editable").editInPlace({
            bg_over: 'transparent',
            callback: function(el, enteredText, o) {
                var m = /([a-z]+)-(\d+)/.exec(el), data = {}
                data['task.id'] = m[2]
                data['task.' + m[1]] = enteredText

                // Save result
                $.ajax({
                    url: '@{add()}',
                    type: 'POST',
                    data: data,
                    success: function() {$('#' + el).html(n)},
                    error: function() {$('#' + el).html(o)}
                })

                return true
            }
        });</code></pre>
</div>
</div>
<div class="paragraph">
<p>A little explaination of the callback function :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>the <em>enteredText</em> parameter is the text entered</p>
</li>
<li>
<p>the <em>el</em> is the element id of the html tag. So it is action-$\{task.id}.so we extract the data identifier with a regular expression (m = &#8230;&#8203;) and the id is in m[2], and m[1] is the field modified : so tag all your field in a row with fieldname-object.id to handle all your fields.</p>
</li>
<li>
<p>we construct a map of the values of the task object data[task.id]=m[2] and data[task.<em>fieldname</em>=m[1]</p>
</li>
<li>
<p>and send them with call to $.ajax. Just call our already created method in Application : add. You see that we can use the same method to add a new object or to save a modified object. We could have named it save, which is nearer of the role of the method.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>and we have a success and error actions to give feedback to the user.</p>
</div>
<div class="paragraph">
<p>image::screenshot-20.jpg[image,title="Edit-in-place in action"]]</p>
</div>
</div>
<div class="sect2">
<h3 id="_combine_edit_in_place_and_datepicker">Combine edit-in-place and datepicker</h3>
<div class="paragraph">
<p>Now, ashttp://anibalpacheco.com/blog/post/p-47-jquery-ui-datepicker-jquery-editinplace/[suggested here], we will make the date field editable and add a separate field (an hidden input) to handle the datepicker.</p>
</div>
<div class="paragraph">
<p>First we add a class to the date field, different from the previous (<em>editable</em>) as we will have an additionnal action from the standard editable behaviour (refresh the datepicker value when the date is update) :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">&lt;td class="date-editable" id="due-${task.id}"&gt;${task.due?.format('dd-MM-yyyy')}&lt;/td&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>and make it editable</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">    $(".task td.date-editable").editInPlace({
        bg_over: 'transparent',
    element_id: 'element_id',
    callback: function(el, n, o) {
            var m = /([a-z]+)-(\d+)/.exec(el), data = {}
            data['task.id'] = m[2]
            data['task.' + m[1]] = n

            // Save result
            $.ajax({
                url: '@{add()}',
                type: 'POST',
                data: data,
                success: function() {$('#' + el).html(n)},
                error: function() {$('#' + el).html(o)}
            })
            return true
        }
    });</code></pre>
</div>
</div>
<div class="paragraph">
<p>Here is the new behaviour :</p>
</div>
<div class="paragraph">
<p>image::screenshot-21.jpg[image,title="edit-in-place for the date"]]</p>
</div>
<div class="paragraph">
<p>Now add the datepicker; So we will replace the column value <em>&gt;</em> with an icon to call the datepicker :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">&lt;td&gt;  &lt;input type="hidden" class="datepicker" id="datepicker-${task.id}" value="${task.due?.format('dd-MM-yyyy')}" /&gt;&lt;/td&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>and add the associated JQuery code :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">        $(".datepicker").datepicker({dateFormat:'dd-mm-yy', showAnim:'fadeIn',
            showOn: 'button',
            buttonImage: '/public/images/calendar.png',
            buttonImageOnly: true,

        onClose: function(dateText, inst){
            var m = /([a-z]+)-(\d+)/.exec($(this).attr('id'));

            sp = $('#due-'+m[2]); // take the editInPlace widget
            sp.text(dateText);

                        // Make the Ajax call : should fire blur on origibal field
            var data = {};
            data['task.id'] = m[2];
            data['task.due'] = dateText;
            $.ajax({
                url: '@{add()}',
                 type: 'POST',
                data: data,
                success: function() {$('#' + el).html(n)},
                error: function() {$('#' + el).html(o)}
            });
            }

        })</code></pre>
</div>
</div>
<div class="paragraph">
<p>After copying the value selected in the date picker to the original date field, I make an ajax call.</p>
</div>
<div class="paragraph">
<p>On this datepicker, we should not make an ajax call, but update the date field and click then blur to activate the ajax call on the field value (and so write once the ajax call). But I have some problems make it run it this how-to, though it works prefectly in one of my projects. Here the code of my prject when it runs :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">            sp = $('#due-'+m[2]); // take the editInPlace widget
            sp.text(dateText).click(); // set the date and trigger a click
            $(':input', sp).blur();</code></pre>
</div>
</div>
<div class="paragraph">
<p>The code is far shorter and factorized. I&#8217;ve post event if I can&#8217;t make it run on my how-to project to share it and I&#8217;ll updated this post when I&#8217;ll find the problem.</p>
</div>
</div>]]></description><link>https://javathought.github.io/2010/10/01/Play-edit-your-dates-with-JQuery-editinplace-datepicker-22.html</link><guid isPermaLink="true">https://javathought.github.io/2010/10/01/Play-edit-your-dates-with-JQuery-editinplace-datepicker-22.html</guid><pubDate>Fri, 01 Oct 2010 00:00:00 GMT</pubDate></item><item><title><![CDATA[Playing with sass and fancy-buttons]]></title><description><![CDATA[<div class="paragraph">
<p>Before giving the second part of [my last post, a quick how-to to add great looking buttons in your applications with <a href="http://sass-lang.com/">sass</a> (an extension of CSS3) and <a href="http://brandonmathis.com/blog/2009/11/19/fancy-buttons-are-here/">fancy-buttons</a> (an easy way to design CSS buttons in seconds) .</p>
</div>
<div class="paragraph">
<p>there a sass module in play. Just type the following line to get the module. It comes with fancy-buttons embedded.</p>
</div>
<div class="listingblock">
<div class="content">
<pre>play install sass</pre>
</div>
</div>
<div class="paragraph">
<p>Don&#8217;t forget to run eclipsify (or the command of your IDE) again and refresh Eclipse (your IDE). I&#8217;ll make this how-to on my datepicker project (from previous post).</p>
</div>
<div class="paragraph">
<p>Add the module to your application in conf/application.conf :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-ini" data-lang="ini">module.sass=${play.path}/modules/sass-head</code></pre>
</div>
</div>
<div class="paragraph">
<p>Not you just have two files to modify.</p>
</div>
<div class="paragraph">
<p>Create the sass stylesheet (main.sass) in /public/stylesheets. Import fancy-buttons and "style" your submit button :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-css" data-lang="css">@import fancy_buttons.sass

input[type=&amp;quot;submit&amp;quot;]
    +fancy-button</code></pre>
</div>
</div>
<div class="paragraph">
<p>Really simple, isn&#8217;t it ?</p>
</div>
<div class="paragraph">
<p>Add the call to the stylesheet in main.html :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">&lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;@{'public/stylesheets/main.sass'}&amp;quot; type=&amp;quot;text/css&amp;quot;&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>And, <em>voilà</em> :</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/screenshot-12.jpg" alt="image">
</div>
<div class="title">Figure 1. A form with fancy-buttons</div>
</div>
<div class="paragraph">
<p>I&#8217;ll let your change the look : <a href="http://brandonmathis.com/projects/fancy-buttons/">see more on author site</a>.</p>
</div>]]></description><link>https://javathought.github.io/2010/09/23/Playing-with-sass-and-fancy-buttons.html</link><guid isPermaLink="true">https://javathought.github.io/2010/09/23/Playing-with-sass-and-fancy-buttons.html</guid><category><![CDATA[play framework]]></category><category><![CDATA[ sass]]></category><pubDate>Thu, 23 Sep 2010 00:00:00 GMT</pubDate></item><item><title><![CDATA[Play! edit your dates with JQuery (editinplace + datepicker) 1/2]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>On my first tweet, I posted a link on a sniplet (<a href="http://anibalpacheco.com/blog/post/p-47-jquery-ui-datepicker-jquery-editinplace/" class="bare">http://anibalpacheco.com/blog/post/p-47-jquery-ui-datepicker-jquery-editinplace/</a>) explaining how to mix editinplace and datepicker in JQuery.</p>
</div>
<div class="paragraph">
<p>Here, I&#8217;ll explain how to finish the job of ths sniplet (update the date picker on date field update) and integrate it in a Play! application listing a set of object (each having a date field - a very simple task example).</p>
</div>
<div class="paragraph">
<p>Create a Task model :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">package models;

import play.*;
import play.db.jpa.*;

import javax.persistence.*;
import java.util.*;

@Entity
public class Task extends Model {
    public String action;
    public Date due;
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Review the index method in Application</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">    public static void index() {
        List tasks = Task.findAll();
        render(tasks);
    }</code></pre>
</div>
</div>
<div class="paragraph">
<p>And list the tasks in a table (modifiy the template : view/index.html) with a form to add a new task (last line of the table)</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">#{extends 'main.html' /}
#{set title:'Home' /}

&lt;table&gt;
    &lt;thead&gt;
        &lt;tr&gt;
            &lt;th&gt;Action&lt;/th&gt;
            &lt;th&gt;Due date&lt;/th&gt;
            &lt;th&gt;&lt;/th&gt;
        &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
    #{list tasks, as:'task'}
        &lt;tr&gt;
            &lt;td&gt;${task.action}&lt;/td&gt;
            &lt;td&gt;${task.due}&lt;/td&gt;
            &lt;td&gt;&amp;gt;&lt;/td&gt;
        &lt;/tr&gt;

    #{/list}
    &lt;tr&gt;              #{form @add()}
            &lt;td&gt;&lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;task.action&amp;quot;&gt;&lt;/td&gt;
            &lt;td&gt;&lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;task.due&amp;quot;&gt;&lt;/td&gt;
            &lt;td&gt;&lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;+&amp;quot;&gt;&lt;/td&gt;
            #{/form}
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>And add the add action in Application</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">    public static void add(final Task task) {
        task.save();
        index();
    }</code></pre>
</div>
</div>
<div class="paragraph">
<p>and don&#8217;t forget to activate the database settings in conf/application.conf</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-text" data-lang="text">db=mem</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now you have a basic play! application to save tasks.</p>
</div>
<div class="paragraph">
<p>image::screenshot-4.jpg[image,title="Tasks in action"]]</p>
</div>
<div class="paragraph">
<p>Looking at the state, the date field is not well formated. Just replace the field showing the date with the following code and we&#8217;ll just see the day part of the date without time.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">&lt;td&gt;${task.due.format('dd-MM-yyyy')}&lt;/td&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>image::screenshot-5.jpg[image,title="Tasks with a formatted due date"]]</p>
</div>
<div class="paragraph">
<p>Let&#8217;s begin adding our Ajax behaviour.</p>
</div>
<div class="paragraph">
<p>Look at /public/javascripts : there&#8217;s already JQuery installed (jquery-1.4.2.min.js, which is now the lastest version; You&#8217;ll can <a href="http://docs.jquery.com/Downloading_jQuery">get latest version of JQuery</a> to upgrade your site later). Now look at the main.html template (under app/views), the script is already included.</p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_adding_a_datepicker">Adding a datepicker</h3>
<div class="paragraph">
<p>To add a datepicker, we need to <a href="http://jqueryui.com/download">getJQuery UI</a>.</p>
</div>
<div class="paragraph">
<p>The page is well designed :</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>you choose the components you want to included, so you can just pick the ones you want for your site and have a lightweight version that just fits your needs. For this example, we just need the core (obviously) and datepicker in Widget section.</p>
</li>
<li>
<p>you can choose the theme you want to embed in your package, on the right of the page. I&#8217;ve choose <em>smoothness</em>.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Once you&#8217;ve downloaded the pack, get the script (jquery-ui-1.8.5.custom.min.js) from the js folder and put it on public/javascripts one of your application and get your theme folder (the whole folder) under css in the package and copy it to /public/stylesheets.</p>
</div>
<div class="paragraph">
<p>Add the following lines just below the ones of JQuery (css and javascript ones) in app/views/main.html :
&lt;div&gt;[source,html]</p>
</div>
<div class="listingblock">
<div class="content">
<pre>      &lt;link rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; href=&amp;quot;@{'public/stylesheets/smoothness/jquery-ui-1.8.5.custom.css'}&amp;quot; /&gt;
        &lt;script src=&amp;quot;@{'/public/javascripts/jquery-ui-1.8.5.custom.min.js'}&amp;quot; type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&gt;&lt;/script&gt;</pre>
</div>
</div>
<div class="paragraph">
<p>Your main.html template should now look like this :</p>
</div>
<div class="paragraph">
<p>&lt;div&gt;[source,html]</p>
</div>
<div class="listingblock">
<div class="content">
<pre>&lt;!DOCTYPE html&gt;

&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;#{get 'title' /}&lt;/title&gt;
        &lt;meta http-equiv=&amp;quot;Content-Type&amp;quot; content=&amp;quot;text/html; charset=utf-8&amp;quot;&gt;
        &lt;link rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; href=&amp;quot;@{'/public/stylesheets/main.css'}&amp;quot;&gt;
        &lt;link rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot; href=&amp;quot;@{'public/stylesheets/smoothness/jquery-ui-1.8.5.custom.css'}&amp;quot; /&gt;

        #{get 'moreStyles' /}
        &lt;link rel=&amp;quot;shortcut icon&amp;quot; type=&amp;quot;image/png&amp;quot; href=&amp;quot;@{'/public/images/favicon.png'}&amp;quot;&gt;
        &lt;script src=&amp;quot;@{'/public/javascripts/jquery-1.4.2.min.js'}&amp;quot; type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&gt;&lt;/script&gt;
        &lt;script src=&amp;quot;@{'/public/javascripts/jquery-ui-1.8.5.custom.min.js'}&amp;quot; type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&gt;&lt;/script&gt;
        #{get 'moreScripts' /}
    &lt;/head&gt;
    &lt;body&gt;
        #{doLayout /}
    &lt;/body&gt;
&lt;/html&gt;</pre>
</div>
</div>
<div class="paragraph">
<p>Now we have to associate a datepicker with the field date in the form : first add a class tag the the field :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">            &lt;td&gt;&lt;input class=&amp;quot;due&amp;quot; type=&amp;quot;text&amp;quot; name=&amp;quot;task.due&amp;quot;&gt;&lt;/td&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>and add the JQuery code to associate it with a datepicker :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">&lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&gt;
        $(&amp;quot;.due&amp;quot;).datepicker({dateFormat:'dd-mm-yy', showAnim:'fadeIn'})
&lt;/script&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now you have the basic application with a datepicker.</p>
</div>
<div class="paragraph">
<p>image::screenshot-6.jpg[image,title="task with datepicker"]]</p>
</div>
<div class="paragraph">
<p>Next step is to add editinplace on existing tasks and associate a datepicker on thme for the date. All this in next post&#8230;&#8203;</p>
</div>
</div>]]></description><link>https://javathought.github.io/2010/09/21/Play-edit-your-dates-with-JQuery-editinplace-datepicker-12.html</link><guid isPermaLink="true">https://javathought.github.io/2010/09/21/Play-edit-your-dates-with-JQuery-editinplace-datepicker-12.html</guid><category><![CDATA[AJAX]]></category><category><![CDATA[ datepicker]]></category><category><![CDATA[ editinplace]]></category><category><![CDATA[ JQuery]]></category><category><![CDATA[ play framework]]></category><pubDate>Tue, 21 Sep 2010 00:00:00 GMT</pubDate></item><item><title><![CDATA[My twitter account opened]]></title><description><![CDATA[<div class="paragraph">
<p>I&#8217;ve opened a twitter account, you&#8217;ll find my tweets at the bottom where I&#8217;ll send small messages like links related to subject I talk about here.</p>
</div>]]></description><link>https://javathought.github.io/2010/09/18/My-twitter-account-opened.html</link><guid isPermaLink="true">https://javathought.github.io/2010/09/18/My-twitter-account-opened.html</guid><category><![CDATA[java]]></category><category><![CDATA[ twitter]]></category><pubDate>Sat, 18 Sep 2010 00:00:00 GMT</pubDate></item><item><title><![CDATA[Let's play!]]></title><description><![CDATA[<div class="paragraph">
<p><span class="image"><img src="http://www.playframework.org/images/play.png" alt="image" title="Play! framework"></span></p>
</div>
<div class="paragraph">
<p>Working on a personal project, I was looking for a java framework to develop a web interface. I didn&#8217;t want to use a "full stack" java framework and searched for a RAD  approach and found some information on wicket and trapestry and finally found <a href="http://www.playframework.org/">Play!</a>.</p>
</div>
<div class="paragraph">
<p>I first take a look at the live coding demo and was impressed : exactly (or almost) what I was looking for. Java and simple page templates (with groovy). Watch the video and take a look at the samples in the package and you&#8217;ll have a good idea of the power of the framework.</p>
</div>
<div class="paragraph">
<p>I&#8217;m just trying it since a week and can already create some application : I&#8217;ve already one done (just having to add some entities but the core is already done).</p>
</div>
<div class="paragraph">
<p>Most of my work was learning <a href="http://jquery.com/">JQuery</a> (that I didn&#8217;t know before) to make a dynamic web application : edit in place, ajax, &#8230;&#8203; I&#8217;ve for example mix an editinplace on a date with a datepicker. So Play! made me discover JQuery I already heard but never get a try in the forest a javascript frameworks (<a href="http://http://www.prototypejs.org/">prototype</a>, <a href="http://mootools.net">mootools</a>, <a href="http://script.aculo.us">script. aculo.us</a>, &#8230;&#8203; didn&#8217;t know where to begin).</p>
</div>
<div class="paragraph">
<p>There already some great modules as CRUD and Secure, to make the admin part of your application for example, as in the blog sample.</p>
</div>
<div class="paragraph">
<p>Perhaps more about Play! and JQuery soon ?</p>
</div>]]></description><link>https://javathought.github.io/2010/09/15/Lets-play.html</link><guid isPermaLink="true">https://javathought.github.io/2010/09/15/Lets-play.html</guid><category><![CDATA[java]]></category><category><![CDATA[ JavaScript]]></category><category><![CDATA[ JQuery]]></category><category><![CDATA[ play framework]]></category><pubDate>Wed, 15 Sep 2010 00:00:00 GMT</pubDate></item><item><title><![CDATA[More about reusable ant scripts]]></title><description><![CDATA[<div class="paragraph">
<p>As I promised in July,  a little note to write better ant scripts.</p>
</div>
<div class="paragraph">
<p>Following comments on my previous post (<a href="http://javathought.github.io/2009/06/09/reusable-ant-build-file/" class="bare">http://javathought.github.io/2009/06/09/reusable-ant-build-file/</a>), I finally arrived on this <a href="http://developers.sun.com/learning/javaoneonline/j1sessn.jsp?sessn=TS-4166&amp;yr=2009&amp;track=javase">excellent presentation</a> from Douglas Bullard at JavaOne 2009. Read it, it will really improve you scripts.</p>
</div>
<div class="paragraph">
<p>The basis is to use the import.</p>
</div>
<div class="paragraph">
<p>PS :</p>
</div>
<div class="paragraph">
<p><em>Sorry for the delay of this post. I&#8217;ve moved my home, so I was packing all my stuff this summer.</em></p>
</div>]]></description><link>https://javathought.github.io/2010/09/07/More-about-reusable-ant-scripts.html</link><guid isPermaLink="true">https://javathought.github.io/2010/09/07/More-about-reusable-ant-scripts.html</guid><category><![CDATA[ant]]></category><pubDate>Tue, 07 Sep 2010 00:00:00 GMT</pubDate></item><item><title><![CDATA[brb]]></title><description><![CDATA[<div class="paragraph">
<p>I&#8217;ve been away for quite a long moment due to my new job. I began with the new year and had no time to post, due to the new route.</p>
</div>
<div class="paragraph">
<p>I&#8217;ll post again soon, the next subject will be about <em>ant</em></p>
</div>]]></description><link>https://javathought.github.io/2010/07/27/brb.html</link><guid isPermaLink="true">https://javathought.github.io/2010/07/27/brb.html</guid><category><![CDATA[brb job]]></category><pubDate>Tue, 27 Jul 2010 00:00:00 GMT</pubDate></item><item><title><![CDATA[Hudson and accessibility : don't use green ball plugin]]></title><description><![CDATA[<div class="paragraph">
<p>Generally, and not only in Hudson, you should install a plugin to a tool you use only if it really brings a feature.</p>
</div>
<div class="paragraph">
<p>About Green ball plugin, not only, there&#8217;s no feature enhancement, but it&#8217;s an accessibility regression : color blind person don&#8217;t easily differentiate red and green. To have an idea of how blid color persons "see" this two colors, just take a look at this post : <a href="http://community.devexpress.com/blogs/markmiller/archive/2009/02/26/great-ui-clarity-and-color-on-the-presentation-layer.aspx">Great UI: Clarity and Color on the Presentation Layer</a>, and learn good use of colors for your UIs.</p>
</div>
<div class="paragraph">
<p>So, just keep Hudson with blue ball and really useful plugins.</p>
</div>]]></description><link>https://javathought.github.io/2009/12/04/Hudson-and-accessibility-dont-use-green-ball-plugin.html</link><guid isPermaLink="true">https://javathought.github.io/2009/12/04/Hudson-and-accessibility-dont-use-green-ball-plugin.html</guid><category><![CDATA[accessibility]]></category><category><![CDATA[ continuous integration]]></category><category><![CDATA[ GUI]]></category><category><![CDATA[ hudson]]></category><category><![CDATA[ plugin]]></category><pubDate>Fri, 04 Dec 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[First step after installing Eclipse]]></title><description><![CDATA[<div class="paragraph">
<p>Do you know what you should do, immediatly after installing Eclipse ?</p>
</div>
<div class="paragraph">
<p>Setting your file ecnoding charset : by default, Eclipse uses cp1252, wihch is not quite ideal if you have to deal with internationalisation and character manipulation in your datas with differents charset.</p>
</div>
<div class="paragraph">
<p>Just go to the <em>window- preferences</em> menu and select General - Workspace in the tree. Then change the "Text file encoding" parameter :</p>
</div>
<div class="paragraph">
<p><a href="http://javathought.files.wordpress.com/2009/12/eclipse-charset.png"><span class="image"><img src="http://javathought.files.wordpress.com/2009/12/eclipse-charset.png" alt="Default charset under eclipse" title="eclipse-charset"></span></a></p>
</div>
<div class="paragraph">
<p>Then select Other and choose UTF-8.</p>
</div>
<div class="paragraph">
<p>Don&#8217;t forget to set the encoding parameter to your javac javadoc target in your ant tasks :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">&lt;javac srcdir="${src.dir}" destdir="${build.dir}" encoding="UTF-8" &gt;
&lt;classpath&gt;
&lt;fileset dir="${lib.dir}"&gt;
&lt;include name="**/*.jar"/&gt;
&lt;/fileset&gt;
&lt;/classpath&gt;
&lt;/javac&gt;

&lt;javadoc encoding="UTF-8" .../&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>That&#8217;s all.</p>
</div>]]></description><link>https://javathought.github.io/2009/12/03/First-step-after-installing-Eclipse.html</link><guid isPermaLink="true">https://javathought.github.io/2009/12/03/First-step-after-installing-Eclipse.html</guid><category><![CDATA[ant]]></category><category><![CDATA[ Eclipse]]></category><pubDate>Thu, 03 Dec 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[JAXB and ObservableList]]></title><description><![CDATA[<div class="paragraph">
<p>If you don&#8217;t customize your schemas with JAXB, your generated classes will not handle correctly the list in your UI (using beans binding functionnality).</p>
</div>
<div class="paragraph">
<p>If you have lists in your xml, you&#8217;ll probably handle them with Jtable or JList in your UI. Modifications of objects (from the edition form if you don&#8217;t edit directly in your list) will be seen in your table, but creation or deletion of an element in the list will not be seen. To see creation or deletion events in your UI lists, your object list have to be observable, i.e. implements ObservableList.</p>
</div>
<div class="paragraph">
<p>JAXB generate the following code for xml lists :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">protected List&lt;E&gt; listElements = new ArrayList&lt;E&gt;();</code></pre>
</div>
</div>
<div class="paragraph">
<p>The way to create an an observable list is below; beans binding library contains a factory :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">org.jdesktop.observablecollections.ObservableCollections.observableList(new ArrayList&lt;E&gt;());</code></pre>
</div>
</div>
<div class="paragraph">
<p>I would appreciate a way to modify the creation method in JAXB, but didn&#8217;t find it. So I created a class which implements the ObservableList interface (with an almost Decorator Pattern) and specify to JAXB to use this class to handle lists :</p>
</div>
<div class="paragraph">
<p>So, first step, create your own class for lists, that implements all method of ObservableList :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">package my.package;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

import org.jdesktop.observablecollections.ObservableCollections;
import org.jdesktop.observablecollections.ObservableList;
import org.jdesktop.observablecollections.ObservableListListener;

public class MyObservableList&lt;E&gt; implements
        ObservableList&lt;E&gt; {

    private ObservableList&lt;E&gt; l= ObservableCollections.observableList(new ArrayList&lt;E&gt;());



    public AdretObservableList() {

    }

    public void addObservableListListener(ObservableListListener arg0) {
        l.addObservableListListener(arg0);
    }


    public void removeObservableListListener(ObservableListListener arg0) {
        l.removeObservableListListener(arg0);
    }

//... and so one for all methods
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Then specify xjc to use a custom bindings settings. Use -b file.xjb, the file containing the following instructions :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">&lt;bindings xmlns=&amp;quot;http://java.sun.com/xml/ns/jaxb&amp;quot; version=&amp;quot;2.0&amp;quot; xmlns:xs=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&gt;

  &lt;globalBindings
  collectionType=&amp;quot;my.package.MyObservableList&amp;quot; &gt;
  &lt;/globalBindings&gt;

&lt;/bindings&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>This way, JAXB will call</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">protected List&lt;E&gt; listElements = new MyObservableList&lt;E&gt;();</code></pre>
</div>
</div>
<div class="paragraph">
<p>The <a href="http://www.no0ne.org/">plugin from no0ne</a> handle this UI requirement (with the library CollectionBeanProperty).</p>
</div>]]></description><link>https://javathought.github.io/2009/11/30/JAXB-and-ObservableList.html</link><guid isPermaLink="true">https://javathought.github.io/2009/11/30/JAXB-and-ObservableList.html</guid><category><![CDATA[beans binding]]></category><category><![CDATA[ design patterns]]></category><category><![CDATA[ GUI]]></category><category><![CDATA[ jaxb]]></category><category><![CDATA[ xml binding]]></category><pubDate>Mon, 30 Nov 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[More on JAXB plugin]]></title><description><![CDATA[<div class="paragraph">
<p>I&#8217;ve been talking about Java beans binding with JAXB on <a href="http://javathought.github.io/2009/04/27/xml-binding-with-jaxb-33-plugins/">my old post</a>. But trying it on my professionnal project, I&#8217;ve not been able to make it work. I encountered the following error :unrecognized parameter -Xinject-prop-listeners.</p>
</div>
<div class="paragraph">
<p>So I used another plugin, a mod of the original from jaxb-commons found on <a href="http://moscaville.com/jaxb2-commons/index.html">http://moscaville.com/</a>. This one replace the vetoable events by fireChange events. It is less complete than the one from <a href="http://www.no0ne.org/general-purpose/index.html">http://www.no0ne.org/</a>, but interesting for learning more on JAXB.</p>
</div>
<div class="paragraph">
<p>First, this plugin has a two bugs :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>boolean fields do not more generate <em>is</em> method but <em>get</em> method in the generated java source. Not very smart</p>
</li>
<li>
<p>it does not generate the firePropertyChange on <em>int</em> fields but only on <em>Integer</em>. This is more annoying : from xml <em>xsd:int</em> type, both int or Integer fields can be generated in Java : int are generated on required fields (minOccurence &gt;= 1) and Integer are generated on optionnal field (minOccurence = 0). So you have to set minOccurence = 0 to your int fields in your schemas, even if in real case, there is always one occurence of the field.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Then, this plugin does not handle the lists (what the plugin of noOne does). This will be the subject of the next post.</p>
</div>]]></description><link>https://javathought.github.io/2009/11/25/More-on-JAXB-plugin.html</link><guid isPermaLink="true">https://javathought.github.io/2009/11/25/More-on-JAXB-plugin.html</guid><category><![CDATA[beans binding]]></category><category><![CDATA[ jaxb]]></category><pubDate>Wed, 25 Nov 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[Back from vacation and to the business]]></title><description><![CDATA[<div class="paragraph">
<p>It&#8217;s a while since my last post (July). I&#8217;ve been on vacation on August and due to a new objective and the deadline of my project, I didn&#8217;t have much time to share more on the blog.</p>
</div>
<div class="paragraph">
<p>However, I&#8217;ve been using Java and XML on the prject and experienced more on JAXB. So, I&#8217;ll tell more soon.</p>
</div>]]></description><link>https://javathought.github.io/2009/11/22/Back-from-vacation-and-to-the-business.html</link><guid isPermaLink="true">https://javathought.github.io/2009/11/22/Back-from-vacation-and-to-the-business.html</guid><pubDate>Sun, 22 Nov 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[JTable row highlighting and Decorator design pattern]]></title><description><![CDATA[<div class="paragraph">
<p>I&#8217;ve been looking a moment to find how add row highlighting on JTables. To modify the behaviour of the cell rendering, you&#8217;ll have to set a new CellRenderer to JTable for each data types you want to show in the table.</p>
</div>
<div class="paragraph">
<p>The way I use is to apply the Decorator pattern.</p>
</div>
<div class="paragraph">
<p>The reason is that  we only want to add row highlighting behaviour to existing cell renderer, and not to recode all the behaviour of cell renderers. This is particularly right for booleans values, which are shown by check boxes in JTable. With this pattern, you won&#8217;t have to rewrite the behaviour of the cell renderer.</p>
</div>
<div class="paragraph">
<p>So here is the code of our new cell renderer. It inherits of DefaultTableRenderer. It will apply a background to a cell depending of :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>the row is selected : then apply default background for selected rows</p>
</li>
<li>
<p>the row is even or not : apply an alternate background color</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import org.jdesktop.swingx.renderer.DefaultTableRenderer;

/**
 * This is just a basic extension of the DefaultTableCellRender from the current L&amp;F
 */
public class AlternateCellRenderer extends DefaultTableRenderer {

    private TableCellRenderer cellRenderer;

    public AlternateCellRenderer(TableCellRenderer cellRenderer) {
        if (cellRenderer == this || cellRenderer == null) {
            throw new IllegalArgumentException();
        }
        this.cellRenderer = cellRenderer;
    }

    /**
     * Fetch the component which renders the cell ordinarily
     * @param JTable The current JTable the cell is in
     * @param Object The value in the cell
     * @param boolean If the cell is in the selected row
     * @param boolean If the cell is in focus
     * @param int The row number of the cell
     * @param int The column number of the cell
     * @return Component
     */
    public Component getTableCellRendererComponent(JTable tbl, Object v, boolean isSelected, boolean isFocused, int row, int col) {
        Component c = cellRenderer.getTableCellRendererComponent(tbl, v, isSelected, isFocused, row, col);
        if (isSelected) {
            c.setBackground(
                    UIManager.getLookAndFeelDefaults().getColor("Table.selectionBackground"));
        } else if ((row % 2) == 0 &amp;&amp; !isSelected) {
            c.setBackground(
                    UIManager.getLookAndFeelDefaults().getColor("ScrollBar.thumb")
                    );
        } else {
            c.setBackground(new Color((float) 1.0, (float) 1.0, (float) 1.0));
        }
        return c;
    }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Then all we have to do to use this cell renderer is to get existing cell renderers from the table, apply our decorator on them and set this new renderers to the JTable.</p>
</div>
<div class="paragraph">
<p>Look at the second one : we keep the behaviour of the cells showing booleans as we apply our new renderer upon the existing one : the check boxes are kept to show booleans values in the JTable.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">eTable1.setDefaultRenderer(Object.class, new AlternateCellRenderer(eTable1.getDefaultRenderer(Object.class)));
eTable1.setDefaultRenderer(Boolean.class, new AlternateCellRenderer(eTable1.getDefaultRenderer(Boolean.class)));</code></pre>
</div>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/jtableh.png" alt="CellRenderer Decorator in action">
</div>
<div class="title">Figure 1. JTableH</div>
</div>]]></description><link>https://javathought.github.io/2009/07/08/JTable-row-highlighting-and-Decorator-design-pattern.html</link><guid isPermaLink="true">https://javathought.github.io/2009/07/08/JTable-row-highlighting-and-Decorator-design-pattern.html</guid><category><![CDATA[design patterns]]></category><category><![CDATA[ GUI]]></category><category><![CDATA[ JTable]]></category><category><![CDATA[ swing]]></category><pubDate>Wed, 08 Jul 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[Design Patterns Quick Reference (and others)]]></title><description><![CDATA[<div class="paragraph">
<p>Ever wanted a poster of Design Patterns ? Here is <a href="Jason%20McDonald">one for free on Jason McDonald&#8217;s blog</a>.</p>
</div>
<div class="paragraph">
<p>You can also find many useful poster or <a href="http://refcardz.dzone.com/">"Refcardz" on dzone.com</a>. The Design Patterns one is also made by Jason. ou&#8217;ll find others on Java, Netbeans, eclipse or others.</p>
</div>
<div class="paragraph">
<p>Take onaother look at devirtuoso.com to find <a href="http://www.devirtuoso.com/2009/07/10-must-have-cheat-sheets-for-developers/">9 more ones quick card</a> with one on subversion (from  <a href="http://www.addedbytes.com/" class="bare">http://www.addedbytes.com/</a>)</p>
</div>]]></description><link>https://javathought.github.io/2009/07/07/Design-Patterns-Quick-Reference-and-others.html</link><guid isPermaLink="true">https://javathought.github.io/2009/07/07/Design-Patterns-Quick-Reference-and-others.html</guid><category><![CDATA[design patterns]]></category><category><![CDATA[ Eclipse]]></category><category><![CDATA[ Netbeans]]></category><category><![CDATA[ svn]]></category><pubDate>Tue, 07 Jul 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[Hudson blue ball]]></title><description><![CDATA[<div class="paragraph">
<p>The Hudson choice of a blue ball for successful build isn&#8217;t a classic choice. You&#8217;d prefer a class green ball (like traffic light) : just use <a href="http://wiki.hudson-ci.org/display/HUDSON/Green+Balls">green ball plugin</a> !</p>
</div>
<div class="paragraph">
<p>To have a <a href="http://wiki.hudson-ci.org/display/HUDSON/Plugins">list of Hudson plugin</a>, just visit the <a href="http://wiki.hudson-ci.org/display/HUDSON/Home">hudson wiki</a>.</p>
</div>]]></description><link>https://javathought.github.io/2009/06/29/Hudson-blue-ball.html</link><guid isPermaLink="true">https://javathought.github.io/2009/06/29/Hudson-blue-ball.html</guid><category><![CDATA[continuous integration]]></category><category><![CDATA[ hudson]]></category><category><![CDATA[ plugin]]></category><category><![CDATA[ tip]]></category><pubDate>Mon, 29 Jun 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[hudson and Serena Dimensions : easy integration]]></title><description><![CDATA[<div class="paragraph">
<p>Though there is a Hudson plugin for PVCS, there&#8217;s none for Serena Dimensions. I searched how to use Hudson and Dimensions together but didn&#8217;t find a,ything on Internet. So here&#8217;s the solution I use.</p>
</div>
<div class="paragraph">
<p>Fortunaltely, there&#8217;s a quick and easy way to add a project in Hudson with source control under Dimensions. Just add a step to the build with shell script or Windows batch command and use the Dimensions command line <code>dmcli</code> :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml"> dmcli -user &lt;user&gt; -pass
&lt;pass&gt; -host &lt;host:port&gt; -dbname &lt;dbname&gt; -dsn &lt;SID&gt; download /WORKSET=CATAL:WS_PHONEBOOK /DIRECTORY=Phonebook</code></pre>
</div>
</div>
<div class="paragraph">
<p>You should be able to use the option -file also (which i didn&#8217;t try) : see <a href="http://community.serena.com/posts/54287b495d">this post on Serena forum</a> for more information.</p>
</div>
<div class="paragraph">
<p>To get more help on dmcli option, just call dmcli without command and use help to get more information on internal commands. The cons of this is that you won&#8217;t have changes informations in the hudson change log :(.</p>
</div>
<div class="paragraph">
<p>On Windows, if you use Hudson as a service, the dmcli command won&#8217;t work directly : I suppose you must update the path before calling dmcli (or enter the full path to the command, but didn&#8217;t check it.</p>
</div>]]></description><link>https://javathought.github.io/2009/06/27/hudson-and-Serena-Dimensions-easy-integration.html</link><guid isPermaLink="true">https://javathought.github.io/2009/06/27/hudson-and-Serena-Dimensions-easy-integration.html</guid><category><![CDATA[continuous integration]]></category><category><![CDATA[ hudson]]></category><category><![CDATA[ SCM]]></category><pubDate>Sat, 27 Jun 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[Swing or SWT]]></title><description><![CDATA[<div class="paragraph">
<p>When programming GUI with Java, the question of the choice between Swing and SWT .</p>
</div>
<div class="paragraph">
<p>My personal choice is Swing, first af all because I use it for a while. For example, I worked on a simple application in 2003 to created thumbnails images for <a href="http://jimmac.musichall.cz/original.php3">original</a> (a web photo gallery) written by <a href="http://jimmac.musichall.cz/">jimmac</a>.</p>
</div>
<div class="paragraph">
<p>Developing this application, I developed some Swing widgets (a splashscreen, status bar, a toolbar with outlook behaviour) you can find on <a href="http://banks.free.fr/stuff/java.php">my old java page</a> and <a href="http://banks.free.fr/stuff/java.php">download here</a>.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/ss_components.png" alt="Enhanced Swing components">
</div>
<div class="title">Figure 1. ss_components</div>
</div>
<div class="paragraph">
<p>So, I prefer Swing because :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>I know it&#8217;s API. I should learn SWT, and what I saw of it make me think it won&#8217;t be simple.</p>
</li>
<li>
<p>You can make enhanced widgets with Swing and even impressive UI. You can read <a href="http://www.curious-creature.org/category/swing/">old posts on Romain Guy&#8217;s web page</a> about Swing : really good stuff to learn. He now work for google on Android.</p>
</li>
<li>
<p>Netbeans can help you quickly develop your GUI with it&#8217;s GUI builder (previously called Matisse). I really appreciate the way it helps you place components on you UI. I also enhanced components (one from Romain Guy&#8217;s) to be full Java beans Swing components to be able to use them with Matisse (I&#8217;ll talk about them later).</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The last reason will definitly confirm my choice of Swing. And really take a look at Romain&#8217;s blog to his impressive Swing GUI notes (and even his photos).</p>
</div>]]></description><link>https://javathought.github.io/2009/06/19/Swing-or-SWT.html</link><guid isPermaLink="true">https://javathought.github.io/2009/06/19/Swing-or-SWT.html</guid><category><![CDATA[matisse]]></category><category><![CDATA[ Netbeans]]></category><category><![CDATA[ swing]]></category><category><![CDATA[ swt]]></category><pubDate>Fri, 19 Jun 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[Reusable Ant build file]]></title><description><![CDATA[<div class="paragraph">
<p>Hello,</p>
</div>
<div class="paragraph">
<p>I&#8217;m back from some vacations.</p>
</div>
<div class="paragraph">
<p>The topic I want to discuss this time is the use of ant build files. I don&#8217;t like the build files generated by netbeans. Why ? Working in a professional environment, you have to master all your building chain : know what happens in the continuous integration process, know exactly what you deliver to your production team (in a professional environment developers package the release and deliver it to production team; only production authorized team deploy the package on production systems), &#8230;&#8203;.</p>
</div>
<div class="paragraph">
<p>So I don&#8217;t like the maze of ant files generated by Netbeans. Here is the reusable ant file I used. you can rapidly use it back in a new project with fex modification (mainly the project name).</p>
</div>
<div class="paragraph">
<p>This file contains targets for :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>compilation (at least what a build file must do)</p>
</li>
<li>
<p>generate the javadoc  (documentation is important, don&#8217;t forget it)</p>
</li>
<li>
<p>creating the distribution jar file</p>
</li>
<li>
<p>run target to launch your application, based on the generated jar (this one is an example you&#8217;ll have to modify the command line parameters)</p>
</li>
<li>
<p>test your application (with junit), which is important to automate in the case of continuous integration</p>
</li>
<li>
<p>generation of code with jaxb : this can be suppressed (in this case, you can suppress the corresponding mkdir task in prebuild target.</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">&lt;?xml version="1.0" ?&gt;
&lt;project name="phonebook" basedir="." default="main"&gt;
&lt;property name="dist.dir" value="dist"/&gt;
&lt;property name="src.dir" value="src"/&gt;
&lt;property name="src-generated.dir" value="generated-src"/&gt;
&lt;property name="build.dir" value="build"/&gt;
&lt;property name="lib.dir" value="lib"/&gt;
&lt;property name="javadoc.dir" value="${dist.dir}/doc"/&gt;
&lt;property name="version" value="1.1.2"/&gt;
&lt;property name="MainClass" value="fr.free.banks." /&gt;
&lt;path id="lib.path"&gt;
        &lt;fileset dir="${lib.dir}" includes="**/*.jar"/&gt;
    &lt;/path&gt;
&lt;pathconvert property="lib.classpath" pathsep=" " dirsep="/"&gt;
&lt;path refid="lib.path"&gt;&lt;/path&gt;
      &lt;map from="${basedir}/lib" to="lib"/&gt;
    &lt;/pathconvert&gt;

&lt;taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask"&gt;
  &lt;classpath&gt;
    &lt;fileset dir="${lib.dir}" includes="*.jar" /&gt;
  &lt;/classpath&gt;
&lt;/taskdef&gt;

    &lt;target name="clean"&gt;
        &lt;delete dir="${build.dir}"/&gt;
        &lt;delete dir="${dist.dir}"/&gt;
        &lt;delete dir="${src-generated.dir}" /&gt;
    &lt;/target&gt;

    &lt;target name="prebuild"&gt;
        &lt;mkdir dir="${build.dir}" /&gt;
        &lt;mkdir dir="${dist.dir}" /&gt;
        &lt;mkdir dir="${src-generated.dir}" /&gt;
    &lt;/target&gt;

    &lt;target name="main" description="Build complet" depends="clean,create-jar"&gt;
        &lt;copy todir="${dist.dir}/lib"&gt;
          &lt;fileset dir="${lib.dir}"&gt;
            &lt;include name="**/*.jar"/&gt;
          &lt;/fileset&gt;
        &lt;/copy&gt;
        &lt;copy todir="${dist.dir}"&gt;
          &lt;fileset dir="${basedir}"&gt;
            &lt;include name="*.xsd"/&gt;
          &lt;/fileset&gt;
        &lt;/copy&gt;
        &lt;!--copy todir="${dist.dir}/doc"&gt;
          &lt;fileset dir="${basedir}/doc"&gt;
            &lt;include name="**/*.doc"/&gt;
          &lt;/fileset&gt;
        &lt;/copy--&gt;
        &lt;zip destfile="${ant.project.name}.zip"&gt;
            &lt;zipfileset dir="dist" /&gt;
        &lt;/zip&gt;
    &lt;/target&gt;

    &lt;target name="compile" description="Compile classes" depends="prebuild,generate-xjc"&gt;
        &lt;javac srcdir="${src.dir}:${src-generated.dir}" destdir="${build.dir}"&gt;
            &lt;classpath&gt;
                &lt;fileset dir="${lib.dir}"&gt;
                    &lt;include name="**/*.jar"/&gt;
                &lt;/fileset&gt;
            &lt;/classpath&gt;
        &lt;/javac&gt;
    &lt;/target&gt;

    &lt;target name="generate-xjc" description="Generate classes with JAXB"&gt;
        &lt;xjc package="fr.free.banks.phonebook.xml" destdir="${src-generated.dir}" &gt;
            &lt;classpath&gt;
&lt;pathelement location="${src.dir}"/&gt;
&lt;pathelement path="${jaxbwiz.xjcrun.classpath}"/&gt;
            &lt;/classpath&gt;
            &lt;arg value="-xmlschema"/&gt;
            &lt;arg value="-extension"/&gt;
            &lt;!--arg value="-Xinject-listener-code" /--&gt;
            &lt;schema file="${src.dir}/phonebook.xsd"/&gt;
&lt;produces dir="${src-generated.dir}"/&gt;
        &lt;/xjc&gt;
    &lt;/target&gt;

    &lt;target name="create-jar" description="Create jar file" depends="compile"&gt;
        &lt;copy todir="${build.dir}"&gt;
          &lt;fileset dir="${src.dir}"&gt;
            &lt;include name="**/log4j.xml"/&gt;
          &lt;/fileset&gt;
        &lt;/copy&gt;
        &lt;jar jarfile="${dist.dir}/${ant.project.name}.jar" basedir="${build.dir}" includes="**/*.class log4j.xml" &gt;
            &lt;manifest&gt;
                &lt;section name="${ant.project.name}"&gt;
                  &lt;attribute name="Specification-Version" value="${version}"/&gt;
                  &lt;attribute name="Implementation-Version" value="${version}"/&gt;
                &lt;/section&gt;
                &lt;attribute name="Main-Class" value="${MainClass}"/&gt;
                &lt;attribute name="Class-Path" value="${lib.classpath}"/&gt;
            &lt;/manifest&gt;

        &lt;/jar&gt;
    &lt;/target&gt;

    &lt;target name="compile.test" description="Compile test classes"&gt;
        &lt;mkdir dir="${build.test.dir}" /&gt;
        &lt;copy todir="${build.dir}"&gt;
            &lt;fileset dir="${basedir}"&gt;
                &lt;include name="k.properties" /&gt;
            &lt;/fileset&gt;
        &lt;/copy&gt;
        &lt;javac srcdir="${tst.dir}" destdir="${build.test.dir}" encoding="UTF-8"&gt;
            &lt;classpath&gt;
&lt;pathelement location="${junit4.dir}/junit.jar" /&gt;
&lt;pathelement location="${build.dir}" /&gt;
            &lt;/classpath&gt;
        &lt;/javac&gt;
    &lt;/target&gt;

    &lt;target name="test" depends="compile.test"&gt;
        &lt;junit&gt;
            &lt;classpath refid="classpath.test" /&gt;

            &lt;formatter type="brief"  /&gt;
            &lt;!--test name="com.bnpparibas.itp.qm.qos.anonymiser.test.AnonymiserTest" haltonfailure="no" outfile="result"&gt;
                &lt;formatter type="xml"/&gt;
            &lt;/test--&gt;

              &lt;batchtest fork="yes" todir="buildtest"&gt;
                &lt;fileset dir="${tst.dir}"&gt;
                  &lt;include name="**/*Test*.java"/&gt;
                &lt;/fileset&gt;
              &lt;/batchtest&gt;

        &lt;/junit&gt;
    &lt;/target&gt;

    &lt;target name="javadoc"&gt;
        &lt;javadoc access="public" author="true" classpath="lib/log4j-1.2.15.jar;C:\Sauvegarde\eclipse-cpp-plugin\eclipse\plugins\org.junit4_4.3.1\junit.jar" destdir="${javadoc.dir}" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" source="1.5" sourcepath="${src.dir}" splitindex="true" use="true" version="true"/&gt;
    &lt;/target&gt;

    &lt;target name="run"&gt;
        &lt;java classname="fr.free.banks.phonebook.App"
               fork="true"
               failonerror="true"
               maxmemory="128m" &gt;
            &lt;classpath&gt;
&lt;pathelement location="${dist.dir}/${ant.project.name}.jar" /&gt;

            &lt;/classpath&gt;
            &lt;arg value="-f" /&gt;

        &lt;/java&gt;
    &lt;/target&gt;

&lt;/project&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>You can had dependances from other projects in the prebuild target, for example add this :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">&lt;copy todir="${lib.dir}"&gt;
    &lt;fileset dir="${basedir}/../otherproject/dist"&gt;
    &lt;include name="otherproject.jar"/&gt; &lt;/fileset&gt;
 &lt;/copy&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Hopes this can help you. And don&#8217;t hesitate to report possible errors.</p>
</div>]]></description><link>https://javathought.github.io/2009/06/09/Reusable-Ant-build-file.html</link><guid isPermaLink="true">https://javathought.github.io/2009/06/09/Reusable-Ant-build-file.html</guid><category><![CDATA[ant]]></category><category><![CDATA[ continuous integration]]></category><category><![CDATA[ junit]]></category><category><![CDATA[ Netbeans]]></category><pubDate>Tue, 09 Jun 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[XML binding with JAXB 3/3 : plugins]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>Once you&#8217;ll have been working with JAXB basis, you&#8217;ll want to enhance what your doing. For example, in my case, I want to bind my datas with a GUI. For that, I&#8217;ll need to use beans binding (JSR 295) with netbeans. You can begin to design your GUI, and test it. It will almost work.</p>
</div>
<div class="paragraph">
<p>But you&#8217;ll see that your data changes are not propaged on your GUI components. The reason is that JAXB didn&#8217;t generate the firePropertyChanged calls in the set methods of your beans. And you don&#8217;t want to change manually the generated code.</p>
</div>
<div class="paragraph">
<p>The solution is in the plugins. If your search on internet, your find to user the <a href="https://jaxb2-commons.dev.java.net/property-listener-injector/">property listener (AKA bound properties) injector plugin</a>. Trying it, I discovered that this plugin generates fireVetoableChange calls, not exactly what I expected.</p>
</div>
<div class="paragraph">
<p>Fortunately, a hack of this plugin, <a href="http://www.no0ne.org/general-purpose/index.html#PropListInjector">Enhanced Property Listener Injection plugin</a>, is available and make what I want.</p>
</div>
<div class="paragraph">
<p>You know just have to plug it in your build script.</p>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_ant">ant</h4>
<div class="paragraph">
<p>You&#8217;ll have to add the plugin jar in the library path of your xjc task :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">    &lt;target name=&amp;quot;xjc-typedef-target&amp;quot; depends=&amp;quot;-init-project&amp;quot;&gt;
        &lt;typedef classname=&amp;quot;com.sun.tools.xjc.XJCTask&amp;quot; name=&amp;quot;xjc&amp;quot; xmlns:s=&amp;quot;http://xml.netbeans.org/schema/JAXBWizConfig&amp;quot;&gt;
            &lt;classpath&gt;
&lt;pathelement path=&amp;quot;${jaxbwiz.xjcdef.classpath}&amp;quot; /&gt;
&lt;pathelement location=&amp;quot;lib/proplistinjector-0.1.1.jar&amp;quot; /&gt;

            &lt;/classpath&gt;
        &lt;/typedef&gt;
    &lt;/target&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>and add the argument option to xjc target :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">        &lt;xjc package=&amp;quot;package.name&amp;quot; destdir=&amp;quot;build/generated/jaxbCache/SchemaName&amp;quot; catalog=&amp;quot;catalog.xml&amp;quot;&gt;
            &lt;classpath&gt;
&lt;pathelement location=&amp;quot;${src.dir}&amp;quot;/&gt;
&lt;pathelement path=&amp;quot;${jaxbwiz.xjcrun.classpath}&amp;quot;/&gt;
            &lt;/classpath&gt;
            &lt;arg value=&amp;quot;-xmlschema&amp;quot;/&gt;
            &lt;arg value=&amp;quot;-extension&amp;quot;/&gt;
            &lt;arg value=&amp;quot;&lt;span style=&amp;quot;font-family: Consolas; font-size: x-small;&amp;quot;&gt;-Xinject-prop-listeners&lt;/span&gt;&amp;quot; /&gt;
            &lt;schema file=&amp;quot;xml-resources/jaxb/SchemaName/schemaname.xsd&amp;quot;/&gt;
&lt;produces dir=&amp;quot;build/generated/jaxbCache/schemaname&amp;quot;/&gt;
        &lt;/xjc&gt;</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_maven">maven</h4>
<div class="paragraph">
<p>First, using <a href="http://maven.apache.org/">Maven</a> you&#8217;ll have to place your schema files in <code>src/main/resources/</code>.</p>
</div>
<div class="paragraph">
<p>You&#8217;ll find here (<a href="https://maven-jaxb2-plugin.dev.java.net/">maven-jaxb2-plugin</a>) how to configure your pom.xml file for JAXB (information you could find elsewhere), and more important how to <a href="enabling%20JAXB%202%20plugins">enable JAXB 2 plugin</a>.</p>
</div>
<div class="paragraph">
<p>Unfortunately, I haven&#8217;t been able to configure JAXB plugin with maven. So I&#8217;ll go back using ant.</p>
</div>
<div class="paragraph">
<p>If you want to go further using JAXB, here are two goods links for improving our knowledge :</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><a href="https://jaxb.dev.java.net/tutorial/">A JAXB Tutorial</a> on glassfish website</p>
</li>
<li>
<p><a href="https://jaxb2-commons.dev.java.net/">JAXB commons</a> where you&#8217;ll find useful plugins</p>
</li>
</ol>
</div>
</div>]]></description><link>https://javathought.github.io/2009/04/27/XML-binding-with-JAXB-33-plugins.html</link><guid isPermaLink="true">https://javathought.github.io/2009/04/27/XML-binding-with-JAXB-33-plugins.html</guid><category><![CDATA[ant]]></category><category><![CDATA[ beans binding]]></category><category><![CDATA[ jaxb]]></category><category><![CDATA[ matisse]]></category><category><![CDATA[ maven]]></category><category><![CDATA[ Netbeans]]></category><category><![CDATA[ xml binding]]></category><pubDate>Mon, 27 Apr 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[XML binding with JAXB 2/3 : customisation]]></title><description><![CDATA[<div class="paragraph">
<p>This article is part 2 of the series on JAXB. On <a href="http://javathought.github.io/2009/04/26/xml-binding-with-jaxb-13/">part 1</a>, I exposed the basis of using JAXB.</p>
</div>
<div class="paragraph">
<p>But you can go further with JAXB. You can heavily customize JAXB with annotations. Using the same phonebook example, you can introduce annotations in your schema to make JAXB meet your needs.</p>
</div>
<div class="paragraph">
<p>A phonebook is made of contacts, so developing the mockup presented in part 1, we will add the contacts in our schema :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">    &lt;xsd:element name="phonebook"   &gt;

    &lt;xsd:complexType&gt;
        &lt;xsd:sequence&gt;
            &lt;xsd:element name="contact" type="Contact" minOccurs="1"
                maxOccurs="unbounded"&gt;
            &lt;/xsd:element&gt;
        &lt;/xsd:sequence&gt;
    &lt;/xsd:complexType&gt;

    &lt;/xsd:element&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>What JAXB will generate with this schema. A new class will be generated : <code>Contact</code>. It&#8217;s what we wanted, but take a look at Phonebook class. There will be a new field and an associated get method :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">    protected List&lt;Contact&gt; contact;
    ...
    public List&lt;Contact&gt; getContact() {
        if (contact == null) {
            contact = new ArrayList&lt;Contact&gt;();
        }
        return this.contact;
    }</code></pre>
</div>
</div>
<div class="paragraph">
<p>Not quite what we expected has the get method returns a list, so we expected the get method to be <code>getContacts</code> which is clearer : the method does not return one contact.</p>
</div>
<div class="paragraph">
<p>To correct this we&#8217;ll use annotations, to have a <code>Contact</code> class and a <code>getContacts</code> method :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">    &lt;xsd:element name="phonebook"   &gt;

    &lt;xsd:complexType&gt;
        &lt;xsd:sequence&gt;
            &lt;xsd:element name="contact" type="Contact" minOccurs="1"
                maxOccurs="unbounded"&gt;
                &lt;xsd:annotation&gt;
                    &lt;xsd:appinfo&gt;
                        &lt;jxb:property name="contacts"&gt;&lt;/jxb:property&gt;
                    &lt;/xsd:appinfo&gt;
                &lt;/xsd:annotation&gt;
            &lt;/xsd:element&gt;
        &lt;/xsd:sequence&gt;
    &lt;/xsd:complexType&gt;

    &lt;/xsd:element&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>You can use those annotations for more structural customisations :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>you can specify the Java type to use for the list of elements (by default a List is return) and choose to have lists handed in an Array for example (use the attribute collectionType of tag jxb:property).</p>
</li>
<li>
<p>You can also specify the generated class to be sub-class of a super-class or extend an interface (with tag <code>xjc:superClass</code> or <code>xjc:superIterface</code>, see <a href="https://jaxb.dev.java.net/nonav/2.0.2/docs/vendorCustomizations.html">vendor customizations</a>).</p>
</li>
</ul>
</div>]]></description><link>https://javathought.github.io/2009/04/26/XML-binding-with-JAXB-23-customisation.html</link><guid isPermaLink="true">https://javathought.github.io/2009/04/26/XML-binding-with-JAXB-23-customisation.html</guid><category><![CDATA[jaxb]]></category><category><![CDATA[ xml binding]]></category><pubDate>Sun, 26 Apr 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[XML binding with JAXB 1/3]]></title><description><![CDATA[<div class="paragraph">
<p>I&#8217;ve been watching for an XML binding tool for one of my projects, which make use of XML to store datas.</p>
</div>
<div class="paragraph">
<p>I looked at hibernate, which now make XML bindings, but, from what I&#8217;ve seen, the binding is managed by the relational mapping. As I do not have a database in my application, I had to search elsewhere.</p>
</div>
<div class="paragraph">
<p>So I took a look at JAXB. It&#8217;s the tool I needed : you specify your xml schema, run xjc and you have your object mapping done. As example, I&#8217;ll use a schema I&#8217;m writing at the moment (phonebook.xsd). Now, all you have to write, once the classes are generated is 4 lines of code (plus catching the exceptions:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">        Phonebook phonebook = null;
        JAXBContext jc;

        try {

            // Create the context with package containing mapping classes
            jc = JAXBContext.newInstance(BINDING_ID);

            // Load the xml file
            Unmarshaller u = jc.createUnmarshaller();

            u.setSchema(SchemaFactory.newInstance(
                    XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(
                    new File("phonebook.xsd")));

          phonebook  =
                    (Phonebook)u.unmarshal( new FileInputStream( phonebookFilename ) );

            // Do some work ...

            // Save the modified datas (here writes on stdout)
            Marshaller m = jc.createMarshaller();
             m.marshal( b, System.out);

        } catch (SAXException e) {
            logger.log(Level.ERROR, "Altered schema file.", e);
            throw new Exception("Schema file has been altered.", e);
        } catch (FileNotFoundException e) {
            logger.log(Level.ERROR, "Phonebook file not found.", e);
            throw new Exception("Phonebook file not found.");
        } catch (JAXBException e) {
            logger.log(Level.ERROR, "Corrupted phonebook file ", e);
            throw new Exception("Corrupted phonebook file ");
        }</code></pre>
</div>
</div>
<div class="paragraph">
<p>Let&#8217;s comment the source :</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Create a context : the constant BINDING_ID is the package name of the generated xml binding classes.</p>
</li>
<li>
<p>Create the unmarshaller : the object that will read the xml file and bind it to objects</p>
</li>
<li>
<p>Set the schema of the xml file read to assume xml validation</p>
</li>
<li>
<p>Unmarshal : load the file in the objects</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>But you have three things to know to better use it : first if you want to directly unmarshal to your root class and to write an object representation to an xml file, the master object class has to be tagged @xmlRootElement, if you want to write simplier code.</p>
</div>
<div class="paragraph">
<p>Take the following schema, that does not generate the @XmlRootElement annotation :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">&lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="2.0" &gt;

    &lt;xsd:element name="phonebook" type="Phonebook" /&gt;;

    &lt;xsd:complexType name="Phonebook"&gt;
    ...
    &lt;/xsd:complexType&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>If you use that schema, you&#8217;ll have an error (<code>java.lang.ClassCastException: javax.xml.bind.JAXBElement cannot be cast to package.name.Phonebook</code>) when unmarshalling and an other (<code>unable to marshal type "package.name.Phonebook" as an element because it is missing an @XmlRootElement annotation</code>) when marshalling. You&#8217;ll have to write the following java code to unmarshall and marshall without errors with the schema above :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">phonebook  =
     (Phonebook) ((JAXBElement)u.unmarshal( new FileInputStream( phonebookFilename ) )).getValue;

     m.marshal( new JAXBElement( new QName("", "phonebook"), Phonebook.class, phonebook ), System.out);</code></pre>
</div>
</div>
<div class="paragraph">
<p>Instead, a better way to declare your schema (and have simplier java code) is :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">&lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="2.0" &gt;

    &lt;xsd:element name="phonebook" &gt;;

    &lt;xsd:complexType &gt;
    ...
    &lt;/xsd:complexType&gt;
    &lt;/xsd:element&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>The two others tips to knows will be the subjects of the next posts.</p>
</div>]]></description><link>https://javathought.github.io/2009/04/25/XML-binding-with-JAXB-13.html</link><guid isPermaLink="true">https://javathought.github.io/2009/04/25/XML-binding-with-JAXB-13.html</guid><category><![CDATA[jaxb]]></category><category><![CDATA[ xml binding]]></category><pubDate>Sat, 25 Apr 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[Hudson vs Continuum]]></title><description><![CDATA[<div class="paragraph">
<p>I&#8217;ve installed <a href="http://continuum.apache.org/">Continuum</a> to compare to <a href="https://hudson.dev.java.net/">Hudson</a>.</p>
</div>
<div class="paragraph">
<p>As Hudson, you just uncompress the archive wher you want (for a standalone deployment), run and it works. Then you create your project, choose your build configuration (there&#8217;s default configuration for ant, maven 1 and 2, and console).</p>
</div>
<div class="paragraph">
<p>Just a think to now : you have to specify your SCM url in the maven format (even if you use ant) : for subversion, it will look like &lt;code&gt; scm:svn:https://host:8443/svn/Repository/trunk &lt;/code&gt;, otherwise you&#8217;ll have a message like <strong>Provider</strong> message: <strong>No</strong> <strong>such</strong> <strong>provider</strong>: 's'.</p>
</div>
<div class="paragraph">
<p>First impressions testing it, compared to Hudson : at first sight, I prefer the dashboard of Hudson, which have a better view of the past builds with a meteo indicator computed on past 5 builds.This give you a view of the stability of the builds.</p>
</div>
<div class="paragraph">
<p>image::hudson-1.png[Hudson&#8217;s view of builds,title="hudson-1"]]</p>
</div>
<div class="paragraph">
<p>Continuum is organized ny projects groups, So you have a first view on the group with counters on successful project, with a counter (a project counts for one).</p>
</div>
<div class="paragraph">
<p>image::continuum-1.png[The project groups view of continuum,title="continuum-1"]]</p>
</div>
<div class="paragraph">
<p>When you click on a group you then have a view on the projects of the group :</p>
</div>
<div class="paragraph">
<p>image::continuum-2.png[the view of the projects in the group,title="continuum-2"]]</p>
</div>
<div class="paragraph">
<p>There&#8217;s a release button on each group in the main view, and on each project in a group view. You&#8217;ll find the <a href="http://continuum.apache.org/docs/1.2.3/user_guides/release/prepare.html">documentation on the release functionality</a> on <a href="http://continuum.apache.org/">Continuum website</a>. I should try this soon. For the moment, I&#8217;ve not been able to get the prepare options to continue the process.</p>
</div>
<div class="paragraph">
<p>I find the navigation in Hudson more intutuive, but it&#8217;s quick to findhow to navigate in Hudson. The organisation of project in groups should also be useful in a large organisation, matching groups of project with the team&#8217;s organisation.</p>
</div>
<div class="paragraph">
<p>I&#8217;ll also try integration with Jira later.</p>
</div>]]></description><link>https://javathought.github.io/2009/04/23/Hudson-vs-Continuum.html</link><guid isPermaLink="true">https://javathought.github.io/2009/04/23/Hudson-vs-Continuum.html</guid><category><![CDATA[continuous integration]]></category><category><![CDATA[ continuum]]></category><category><![CDATA[ hudson]]></category><pubDate>Thu, 23 Apr 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[C programming in Eclipse and Netbeans]]></title><description><![CDATA[<div class="paragraph">
<p>You may sometimes misc C programs with your java development. So I could be a good solution to develop them in the same IDE as your Java develoment. Both Eclipse and Netbeans provide plugins/environment to devellop in C.</p>
</div>
<div class="paragraph">
<p>so it&#8217;s really possible and you really have a good C IDE. I&#8217;ve used Eclipse C environment for a while and it&#8217;s really good C environment. I&#8217;ve tried Netbeans since I&#8217;m developing parts of my Java projects in Netbeans, but I stopped for the moment : I could not be able to use the debugger in Netbeans, quite a hige issue for an IDE.</p>
</div>
<div class="paragraph">
<p>So, until I try it again and resolve that issue in Netbeans, Eclipse is for me the "Java IDE" for C development.</p>
</div>]]></description><link>https://javathought.github.io/2009/04/22/C-programming-in-Eclipse-and-Netbeans.html</link><guid isPermaLink="true">https://javathought.github.io/2009/04/22/C-programming-in-Eclipse-and-Netbeans.html</guid><category><![CDATA[C]]></category><pubDate>Wed, 22 Apr 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[svn : common branching patterns]]></title><description><![CDATA[<div class="paragraph">
<p>In my previous post (<a href="../2009/04/19/installing-a-developer-suite/">Installing a developer “Suite”</a>), I talk about the flexibility of <em>svn</em>. As I anticipated, to achieve the integration of  tested and "validated" request, the way to use <em>svn</em> is to use the feature branching pattern. You can read more about it in the book <a href="../2009/04/19/installing-a-developer-suite/">“</a><a href="http://svnbook.red-bean.com/en/1.5/svn-book.pdf">Version Control with Subversion</a><a href="../2009/04/19/installing-a-developer-suite/">”</a> (see chapter 4 - page 137).</p>
</div>
<div class="paragraph">
<p>So to achieve this pattern, the has to follow the process, with the cost overhead. I think the distibuted model of <a href="http://www.selenic.com/mercurial/">mercurial</a> as a smaller overhead in managing feature changes. This process is much simplier with a SCM that implements the process : developers summit their changes attached to a change request, all in the same trunk. Before a release the SCM manager just pick the validated chage requests. In such SCM, branchs are used to maintain releases, not the features.</p>
</div>]]></description><link>https://javathought.github.io/2009/04/20/svn-common-branching-patterns.html</link><guid isPermaLink="true">https://javathought.github.io/2009/04/20/svn-common-branching-patterns.html</guid><category><![CDATA[branching]]></category><category><![CDATA[ change request]]></category><category><![CDATA[ mercurial]]></category><category><![CDATA[ SCM]]></category><category><![CDATA[ svn]]></category><pubDate>Mon, 20 Apr 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[Oracle will buy Sun]]></title><description><![CDATA[<div class="paragraph">
<p>Finally, that&#8217;s Oracle that will buy Sun, surprisingly ahead of others companies, after persistant rumors of exchange with IBM.</p>
</div>
<div class="paragraph">
<p>Thus, Oracle will acquire new activities to concurrence their competitors. Especially, the sun server activity as Oracle didn&#8217;t ship hardware before. A good news to Sun&#8217;s customers. They will also acquire concurrent activity of their actual solutions, as MySql.</p>
</div>
<div class="paragraph">
<p>Personally, I&#8217;m particularly interested in the future of Netbeans, of course. And also, the raise of VirtualBox. Will they improve the solution to compete with VMWare ?</p>
</div>]]></description><link>https://javathought.github.io/2009/04/20/Oracle-will-buy-Sun.html</link><guid isPermaLink="true">https://javathought.github.io/2009/04/20/Oracle-will-buy-Sun.html</guid><category><![CDATA[Oracle]]></category><category><![CDATA[ Sun]]></category><pubDate>Mon, 20 Apr 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[Installing a developer "Suite"]]></title><description><![CDATA[<div class="paragraph">
<p>I&#8217;m installing an environment to support a project that will illustrate my writing about Java.</p>
</div>
<div class="paragraph">
<p>As I&#8217;ll write a desktop application, I&#8217;ll Netbeans for the IDE.</p>
</div>
<div class="paragraph">
<p>Next, I need a SCM (which is a Key Process Area of CMM Level 2) or rather a version control system. But to choose it, before I got my request/issue tracker. It&#8217;s <a href="http://www.atlassian.com/software/jira/">Jira</a>. My short list was <a href="http://subversion.tigris.org/">svn</a> (subversion) and <a href="distributed%20version%20control%20system">mercurial</a> (hg), the later is a distributed version control system (VCS), which differ from traditional centralised ones. I elected svn, though mercurial principlpe is interesting, but svn intregration in Jira is simplier (the plugin is mature).</p>
</div>
<div class="paragraph">
<p>svn is not the more mature VCS I used (I wouldn&#8217;t tell it&#8217;s a SCM), but linked with Jira, we get a missing feature. Correctly used, the changeset are linked to requests, but I found some lack of flexibility (how to decide which request will integrate a release, if the last changeset cumulates all requests ?), though I need to learn more about svn. I think to achieve flexibility, you have to work with branches; but this is harder than in others SCM.</p>
</div>
<div class="paragraph">
<p>I decided to use a continuous integration (CI) tool also. The list I tried was <a href="http://cruisecontrol.sourceforge.net/">CruiseControl</a>and <a href="https://hudson.dev.java.net/">Hudson</a>. I selected Hudson, because it&#8217;s was simpler to install and configure. The configuration is intuitive, not the one for CC. And it simply integrates with Jira too. So in Jira, you track the changeset that fixes your request and the successful build that integrates your request. I began to look at <a href="http://continuum.apache.org/">apache continuum</a>, but hudson was already configured and it seems it has not the simplicity of hudson. Perhaps I&#8217;ll try it more later.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://javathought.github.io/images/hudson-1.png" alt="Hudson CI tool">
</div>
<div class="title">Figure 1. hudson-1</div>
</div>
<div class="paragraph">
<p>So here is my "developer suite" :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>netbeans</p>
</li>
<li>
<p>jira</p>
</li>
<li>
<p>svn</p>
</li>
<li>
<p>hudson</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>I&#8217;ll have a look at natbeans' code coverage plugin next time and compare it to JTest (which does not only do code coverage analysys).</p>
</div>]]></description><link>https://javathought.github.io/2009/04/19/Installing-a-developer-Suite.html</link><guid isPermaLink="true">https://javathought.github.io/2009/04/19/Installing-a-developer-Suite.html</guid><category><![CDATA[CMM]]></category><category><![CDATA[ continuous integration]]></category><category><![CDATA[ hudson]]></category><category><![CDATA[ jira]]></category><category><![CDATA[ Netbeans]]></category><category><![CDATA[ svn]]></category><pubDate>Sun, 19 Apr 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[Debugging in Eclipse vs Netbeans]]></title><description><![CDATA[<div class="paragraph">
<p>This subject was suggested when talking about Eclipse and Netbeans at work. The question was does Netbeans implements hot code replace (HCR or hot method replace). As this feature is available since JDK 1.4.x, it should be possible under Netbeans, the Sun IDE.</p>
</div>
<div class="paragraph">
<p>First, what is HCR ? The precision, because you may think it does not work, but there&#8217;s some limitation in what you can change in your code to fiw it while debugging; it is not possible to do the following :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>change a modifier of a field, method or class</p>
</li>
<li>
<p>add or remove methods or fields</p>
</li>
<li>
<p>change the hierarchy of classes</p>
</li>
<li>
<p>change classes that have not been loaded</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>To summarize, you can change "internal" code of methods.</p>
</div>
<div class="paragraph">
<p>Now, how does it works on these two IDEs :</p>
</div>
<div class="paragraph">
<p>In Eclipse, you just save your code, then your code is recompiled (assuming automatic build is set - see menu Project &#8594; Build automatically). Then the modified code is available in the current debugging session, the instruction pointer is back at the beginning of your method.</p>
</div>
<div class="paragraph">
<p>The difference in Netbeans is that you have to explicit specify that you want your modified code to be "pushed" in the debugging sessions through the menu Debug &#8594; Apply code changes. By the way, if you search more information on the net, search for Hot Code Replace for Eclipse and Apply Code Changes for Netbeans.</p>
</div>]]></description><link>https://javathought.github.io/2009/04/18/Debugging-in-Eclipse-vs-Netbeans.html</link><guid isPermaLink="true">https://javathought.github.io/2009/04/18/Debugging-in-Eclipse-vs-Netbeans.html</guid><category><![CDATA[debugging]]></category><category><![CDATA[ Eclipse]]></category><category><![CDATA[ Netbeans]]></category><pubDate>Sat, 18 Apr 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[VisualEditor (Eclipse) vs Matisse (Netbeans)]]></title><description><![CDATA[<div class="paragraph">
<p>Writing my precedent post, I decided to take back a look at VE. So I installed last version (1.4) of VE on my 3.4 eclipse.</p>
</div>
<div class="paragraph">
<p>So, is VE up to Matisse features ? The response is quickly given : No !</p>
</div>
<div class="paragraph">
<p>VE does not give you the rapid placement of components you have in Netbeans. In Eclipse, you have to place exactly the component where you want it to be to have a professional form.</p>
</div>
<div class="paragraph">
<p>In Netbeans, magnetism is active and place component in a professional way with the GroupLayout. Spacing is automatic, so field text drop perfectly behind labels. Components can be "attached" to borders, so that they grow with the containing panel. A component can have the width of a group of others components. Indentation of components is given, and so on &#8230;&#8203;</p>
</div>
<div class="paragraph">
<p>You&#8217;ll not have this rapid form design in VE.</p>
</div>
<div class="paragraph">
<p>But, what makes Netbeans rules in GUI design against VE is the implementation of JSR-295 Beans Binding ! You simply drag a bean class on the form to have it available for binding. Right-click on a component, then bind and you&#8217;ll have it binded to the property you want. You can start learn beansbinding with this <a href="http://www.netbeans.org/kb/60/java/gui-binding.html">introduction</a>.</p>
</div>
<div class="paragraph">
<p>Opposite, Eclipse gives you nothing. You&#8217;ll really spare time developing your GUI in netbeans. In 1 or 2 day you can design an effective form that works, not only a mock-up but a full funtionnal GUI ready to deliver.</p>
</div>
<div class="paragraph">
<p><em>edit :</em> And the other advantage of Netbeans is the ease of internationalizing your application. No code to write, just write your strings in any language. The IDE can automatically set up the code to load localized labels.</p>
</div>
<div class="paragraph">
<p>Next time, I&#8217;ll speak about the debugging.</p>
</div>]]></description><link>https://javathought.github.io/2009/04/17/VisualEditor-Eclipse-vs-Matisse-Netbeans.html</link><guid isPermaLink="true">https://javathought.github.io/2009/04/17/VisualEditor-Eclipse-vs-Matisse-Netbeans.html</guid><category><![CDATA[Eclipse]]></category><category><![CDATA[ GUI builder]]></category><category><![CDATA[ Netbeans]]></category><pubDate>Fri, 17 Apr 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[Eclipse or Netbeans ?]]></title><description><![CDATA[<div class="paragraph">
<p>When developing with Java, one of the first question is what IDE to used.  As I have worked with Eclipse and netbeans, I&#8217;ll give my feedback on them.</p>
</div>
<div class="paragraph">
<p>Both are good at editing source code (fortunately). There&#8217;s no major difference on basic tasks to develop an application. I&#8217;ll give you the major differences I&#8217;ve found using them to develop J2SE applications. You&#8217;ll have all what you need to develop, make unit tests (with JUnit), package (create jar files), automate your builds (with ant). And you&#8217;ll find additional plugins to help you. So on which feature will you make your choice.</p>
</div>
<div class="paragraph">
<p>First, it seems Netbeans has better integration of some java technologies. E. g., I&#8217;ve develop some applications manipulating xml data files. I choose JAXB to handle the xml-object binding. Netbeans natively supports JAXB. You create your schemas and Netbeans is ready to generate your classes mapping your xml datas. Under Eclipse you&#8217;ll have to install JAXB and the associated plugin. Quite a minor disagreement.</p>
</div>
<div class="paragraph">
<p>Further, Netbeans is from far better when profiling Java applications. You launch your application by the profiling menu : a screen ask you parameters to specify what you want to profile, you click run and &#8230;&#8203; this is all. Your application is being profiled as the result is there quickly. Under Eclipse, you&#8217;ll have to install an agent outside of eclipse, laucnh the agent (outside of eclipse again), and laucnh the profiling. And the bad news is : it&#8217;s very slow. The overhead of profiling under eclipse is just unbearable. I&#8217;ve never been able to wait the end of the profiling.</p>
</div>
<div class="paragraph">
<p>And what about developing desktop applications ? What about Swing GUI builder and beansbing. I&#8217;ve been waiting too long for a GUI builder in Eclipse. VisualEditor (VE) seems to have been quite inactive for a while (see <a href="http://www.eclipse.org/vep/WebContent/main.php">VE project page</a>) , but is back active (you&#8217;ll have to search deeper to find new versions on the <a href="http://wiki.eclipse.org/VE/Installing">wiki page of VE</a>). But I didn&#8217;t tried it (when you disappoint and loose a client, it&#8217;s difficult to get it back). Perhaps I&#8217;ll try it again and give it a chance. There&#8217;s also a new alternative  on eclipse : <a href="http://code.google.com/p/visualswing4eclipse/">VisualSwing4Eclipse</a>. I ddn&#8217;t tried it. But facing this situation, Netbeans comes with embedded <a href="http://www.netbeans.org/features/java/swing.html">Swing GUI Builder</a> (formerly Project Matisse). It comes with great wizards; you&#8217;ll find very goods <a href="http://www.netbeans.org/kb/trails/matisse.html">tutorials on netbeans.org</a>. It comes with BeansBinding integration, creates well design Swing application implementing JSR-296 Swing Application Framework to provide responsive desktop applications.  You rapidly build professional GUI for your applications (I personally build the desktop client of an application with MQ-Series middleware in one day).</p>
</div>
<div class="paragraph">
<p>So, is Netbeans the winner ?</p>
</div>
<div class="paragraph">
<p>On the other hand, in a professionnal environment, you work with other tools to achieve my tasks and goals. So the integrations with them is an important part in the choice of the ideal (not perfect) IDE. In my case, I work with SCM (software configuration management), code analysis tool, and issue tracking software, which of them have plugins for eclipse but not for Netbeans. SCM is the most important part in the integration aspect. This fact is perhaps due to the relationship with WSAD/RAD.</p>
</div>
<div class="paragraph">
<p>Will this change if, finally, IBM buys SUN ?</p>
</div>
<div class="paragraph">
<p>So, I&#8217;ll continue to develop on Eclipse and keep Netbeans for GUI and profiling.</p>
</div>]]></description><link>https://javathought.github.io/2009/04/16/Eclipse-or-Netbeans.html</link><guid isPermaLink="true">https://javathought.github.io/2009/04/16/Eclipse-or-Netbeans.html</guid><category><![CDATA[Eclipse]]></category><category><![CDATA[ IDE]]></category><category><![CDATA[ Netbeans]]></category><pubDate>Thu, 16 Apr 2009 00:00:00 GMT</pubDate></item><item><title><![CDATA[Hello Java world!]]></title><description><![CDATA[<div class="paragraph">
<p>Welcome to <a href="http://javathought.github.io">JavaThought</a>.</p>
</div>
<div class="paragraph">
<p>I&#8217;m Pascal and this blog is a new one where I&#8217;ll post all my notes about Java. I could also write old stuff about Java that I wrote elsewhere to keep only one place for my writings about Java.</p>
</div>
<div class="paragraph">
<p>This will also be a place to stock my sniplets.</p>
</div>
<div class="paragraph">
<p>Hope I&#8217;ll see you soon back here.</p>
</div>]]></description><link>https://javathought.github.io/2009/04/15/Hello-Java-world.html</link><guid isPermaLink="true">https://javathought.github.io/2009/04/15/Hello-Java-world.html</guid><pubDate>Wed, 15 Apr 2009 00:00:00 GMT</pubDate></item></channel></rss>