<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-3646845225376270865</atom:id><lastBuildDate>Mon, 21 May 2012 15:57:44 +0000</lastBuildDate><category>ruby</category><category>couchdb</category><category>flash</category><category>mail</category><category>2009</category><category>j2me on android</category><category>postgres</category><category>magazine</category><category>javascript</category><category>testowanie</category><category>rsync</category><category>encode movie</category><category>junit</category><category>bazy danych</category><category>cross-field</category><category>zostań dawcą szpiku</category><category>postfix</category><category>maven</category><category>gwt</category><category>google gadget</category><category>puzzle</category><category>functions</category><category>template</category><category>flash scope</category><category>coderetreat events</category><category>javaexpress</category><category>validation</category><category>netbeans day</category><category>firefox</category><category>test</category><category>meteo.pl</category><category>testng</category><category>plugin</category><category>geecon</category><category>przeszczep szpiku kostnego</category><category>transaction isolation</category><category>filus</category><category>cross-field validation</category><category>review</category><category>konferencja</category><category>mockito</category><category>narzędzia</category><category>training</category><category>64 bit</category><category>linux</category><category>javafx String</category><category>javafx</category><category>recenzja</category><category>cross</category><category>clockingIT</category><category>scala</category><category>jsf</category><category>mysql</category><category>jsf2</category><category>java</category><category>seam</category><category>ajax</category><category>javafx tutorial</category><category>tutorial</category><category>prawa do pliku</category><category>field</category><category>java4people</category><category>jme</category><category>hudson</category><category>hg-login</category><category>warsjawa 2011</category><category>partial mocks</category><category>jme on android</category><category>component</category><category>uibinder</category><category>repozytorium</category><category>JavaFX in Action</category><category>android</category><category>j2me</category><category>make ubuntu faster</category><category>jpa</category><category>warsjawa</category><category>tokengsm</category><category>zarządzanie</category><category>upload</category><category>play</category><category>samba</category><category>server</category><category>szjug</category><category>filip pająk</category><category>heroku</category><category>ubuntu</category><category>Real World Java EE Patterns Rethinking Best Practices</category><category>skrypt</category><category>mercurial</category><category>javafx types</category><category>warsjawa 2010</category><category>svn</category><category>subversion</category><category>binding</category><title>Java, the Programming, and Everything</title><description /><link>http://pawelstawicki.blogspot.com/</link><managingEditor>noreply@blogger.com (pawelstawicki)</managingEditor><generator>Blogger</generator><openSearch:totalResults>56</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/JavaProgramowanieITakieTam" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="javaprogramowanieitakietam" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-9162154941077105213</guid><pubDate>Sun, 08 Jan 2012 23:58:00 +0000</pubDate><atom:updated>2012-01-26T22:26:47.244+01:00</atom:updated><title>My encounter with a small bug in Hibernate</title><description>&lt;script type="text/javascript"&gt;
var dzone_url = 'http://pawelstawicki.blogspot.com/2011/12/my-encounter-with-small-bug-in.html';
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
var dzone_title = 'My encounter with a small bug in Hibernate';
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
var dzone_blurb = '';
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
var dzone_style = '2';
&lt;/script&gt;
&lt;script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"&gt;
&lt;/script&gt;
&lt;br /&gt;
&lt;h4&gt;

&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;The problem&lt;/span&gt;&lt;/h4&gt;
&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;
At work, I needed to use entities with @DiscriminatorColumn&amp;nbsp;inheritance. It means all types are kept in the same table, with value in this column showing what type given row is of. It's not recommended way to handle inheritance, but for some reasons we needed to use it. In developement, locally, I was using PostgreSQL database. When I tried to store this entities, I was receiving strange errors. Saying I cannot store an entity because entity with such id is already in database. It was quite strange, I was trying to store vanilla new entity. Test case to show this error is very short, so I'll include it here:
&lt;/span&gt;&lt;br /&gt;
&lt;pre class="brush: java"&gt;//Parent entity
@Entity
@Inheritance(strategy = SINGLE_TABLE)
@DiscriminatorColumn(name = "CLASS_ID", discriminatorType = INTEGER)
public abstract class ParentEntity {
  @Id
  @GeneratedValue(strategy = IDENTITY)
  private Long id;
}

//Child entity with discriminator  
@Entity
@DiscriminatorValue("1")
public class InheritingEntity extends ParentEntity {
}

//Test
public class PersistChildEntitiesWithDiscriminatorTest extends BaseCoreFunctionalTestCase {
  
  @Test
  public void shouldPersistTwoEntities() {
    Session session = openSession();
    session.beginTransaction();
    InheritingEntity child1 = new InheritingEntity();
    InheritingEntity child2 = new InheritingEntity();
    session.save(child1);
    session.save(child2);
    session.getTransaction().rollback();
  }
}&lt;/pre&gt;
&lt;h4&gt;

&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;
The cause&lt;/span&gt;&lt;/h4&gt;
&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;
This test throws exception on second save, but only on PostgreSQL. Why is that? Well, when you save new entity to persistence context, Hibernate issues SQL call to database instantly. Other queries, like updates, are cached, and sent to database on &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;em.flush&lt;/span&gt; or &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;em.commit&lt;/span&gt;. But inserting of new entities
  is not cached and there is a reason for that. When we save new entity, Hibernate needs to assign ID to it, and this is taken from database. Most databases
  return &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;ResultSet&lt;/span&gt; with one row and one column after insert, and it contains newly assigned ID. However, PostgreSQL behaves a bit differently.
  It returns whole inserted row (of course, with ID filled in). In most cases it works, because ID is the first column in this row, so when Hibernate takes
  value from the first row and the first column, it is the correct one. However, in case of classes with discriminator, ID is not the first column.
  Discriminator is the first column. So first insert is correct, ID 1 is assigned to &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;child1&lt;/span&gt;, but then when we try to store &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;child2&lt;/span&gt;, Hibernate also tries to assign 1 to it's ID, and complaints that there already is another entity with it.

&lt;/span&gt;&lt;br /&gt;
&lt;h4&gt;
&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;


The solution&lt;/span&gt;&lt;/h4&gt;
&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;
So there was a bug in Hibernate. Can I solve it? I asked this question to myself, but to answer I couldn't do anything else than try ;) So I forked hibernate repository (yes, it's on &lt;a href="https://github.com/"&gt;github&lt;/a&gt;!) and... I was quite overwhelmed by the mass of code there. First challenge was to try to open it in my IDE, with all the subprojects and their interdependencies configured correctly. Thankfully there is gradle task for creating project files for IntelliJ IDEA, the IDE I'm happy user of. Next task was configuring Hibernate tests to use my PostgreSQL database. It turned out quite easy after one or two emails on hibernate-dev list. Now I had to change the code assigning IDs to entities to take it not always from first column first row, but sometimes from column of given name. So I had to get the name of column keeping IDs, which I did with a little help from other developers on the dev list.

&lt;h4&gt;

The contribution&lt;/h4&gt;
Now I commited fix to my forked repository on github, issued a pull request, got some comments, fixed files formatting... We'll see if it's accepted.
&lt;p&gt;
UPDATE:
It is accepted :)
&lt;/p&gt;
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-9162154941077105213?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/qlYAZokV5cnGWJaPBKRtbsmhGwU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/qlYAZokV5cnGWJaPBKRtbsmhGwU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/qlYAZokV5cnGWJaPBKRtbsmhGwU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/qlYAZokV5cnGWJaPBKRtbsmhGwU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/scVW1mr7GcY" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2011/12/my-encounter-with-small-bug-in.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-7234445584577402540</guid><pubDate>Wed, 28 Dec 2011 17:10:00 +0000</pubDate><atom:updated>2011-12-30T14:09:54.048+01:00</atom:updated><title>Easy way to convert file encoding</title><description>&lt;span style="font-family: Verdana, sans-serif;"&gt;Easy way to convert text files to UTF-8 on Ubuntu. Install package &lt;/span&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;enca&lt;/span&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt; and you are able to:&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;enconv -L pl -x UTF-8 myfile.txt&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Verdana, sans-serif;"&gt;Where after &lt;/span&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;-L&lt;/span&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt; is language specified (necessary for enca to recognize file encoding before conversion) and after &lt;/span&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;-x&lt;/span&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt; destination encoding.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Verdana, sans-serif;"&gt;Warning: enconv overwrites existing file, so better create backup copy before.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Verdana, sans-serif;"&gt;UPDATE: Another way, useful if you know source file encoding:&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; color: #333333; line-height: 18px; text-align: left;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;iconv -f ISO-8859-2 -t UTF-8 source.txt &amp;gt; utf8.txt&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-7234445584577402540?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/B7s3_HkYlzomzLen6lbA5WmVYew/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/B7s3_HkYlzomzLen6lbA5WmVYew/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/B7s3_HkYlzomzLen6lbA5WmVYew/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/B7s3_HkYlzomzLen6lbA5WmVYew/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/SsvitIKER3w" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2011/12/easy-way-to-convert-file-encoding.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-2508088679170622379</guid><pubDate>Wed, 30 Nov 2011 22:18:00 +0000</pubDate><atom:updated>2011-12-08T22:27:04.207+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">play</category><category domain="http://www.blogger.com/atom/ns#">heroku</category><title>Play! with Heroku</title><description>&lt;script type="text/javascript"&gt;
var dzone_url = 'http://pawelstawicki.blogspot.com/2011/11/play-with-heroku.html';
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
var dzone_title = 'Play! with Heroku';
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
var dzone_blurb = '';
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
var dzone_style = '2';
&lt;/script&gt;
&lt;script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"&gt;
&lt;/script&gt;

&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;
Recently, inspired by some talks on Devoxx, I decided to check &lt;a href="http://www.playframework.org/"&gt;Play framework&lt;/a&gt; and &lt;a href="http://www.heroku.com/"&gt;Heroku&lt;/a&gt;.
&lt;br /&gt;
&lt;br /&gt;
Play is another java web framework, but this one is heavily influenced by Ruby on Rails. Convention over configuration, little code necessary etc. Looks like Play is gaining momentum, version 2 (now beta) supports Scala and now it became part of &lt;a href="http://typesafe.com/stack"&gt;Typesafe&lt;/a&gt; stack.
&lt;br /&gt;
&lt;br /&gt;Heroku is another cloud. Well, quite different than AWS or GAE (actually, as far as I know, it works on AWS). Heroku is not only running applications, it is also able to build and deploy them. So to deploy your changes, it's enough to make &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;git push&lt;/span&gt;.
&lt;br /&gt;
&lt;br /&gt;
So first, download Play 2 beta from &lt;a href="http://www.playframework.org/2.0"&gt;this site&lt;/a&gt;. Unpack, add dir to your &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$PATH&lt;/span&gt;, so that you could use &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;play&lt;/span&gt; command from anywhere.
&lt;br /&gt;
&lt;br /&gt;
Go to dir where you want to create the app and issue &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;play new helloapp&lt;/span&gt; (where &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;helloapp&lt;/span&gt; is your app name). Play should create &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;helloapp&lt;/span&gt; directory. No go into it. You can notice that Play nicely added &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;.gitignore&lt;/span&gt; file there, so when you create git repository here, unnecessary files won't be added.
Play created fully functional, basic web application. You can issue &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;play run&lt;/span&gt; in &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;helloapp&lt;/span&gt; directory and the server is going to be started and application deployed. You can now see it on &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;localhost:9000&lt;/span&gt;.
&lt;br /&gt;
&lt;br /&gt;
Now you'll need account on Heroku. Create one on &lt;a href="http://heroku.com/"&gt;heroku.com&lt;/a&gt;, it's easy as creating email or forum account. Then just activate it by email sent to you from Heroku.
&lt;br /&gt;
&lt;br /&gt;
For your app to be able to run on Heroku cloud, you'll need to add one more file. In the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;helloapp&lt;/span&gt; dir create &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Procfile&lt;/span&gt; file with content like this:
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;web: target/start&lt;/span&gt;
&lt;br /&gt;
If you created your app with Play 1.x instead of 2.0, &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Procfile&lt;/span&gt; should be quite different:
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;web: play run --http.port=$PORT $PLAY_OPTS&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
To interact with the cloud you'll also need &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;heroku-toolbelt&lt;/span&gt;. Get one from &lt;a href="http://toolbelt.herokuapp.com/"&gt;here&lt;/a&gt;.
&lt;br /&gt;
&lt;br /&gt;
Ok, you have your app and all the tools necessary to deploy it to the cloud. You'll also need git, which I assume you have already installed ;) As I mentioned on the beginning, it's necessary to push your app's code to Heroku.
&lt;br /&gt;
&lt;br /&gt;
Create git repository in the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;helloapp&lt;/span&gt; directory. Enter the directory and issue the following comands.
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;
git init&lt;br /&gt;
git add .&lt;br /&gt;
git commit -m init&lt;/span&gt;
&lt;br /&gt;
This commands created git repository in the directory, added current directory (&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;helloapp&lt;/span&gt;) to the git index, and commited the changes to the local repository.
&lt;br /&gt;
&lt;br /&gt;
Next thing to do is creating new application on Heroku: &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;heroku create --stack cedar&lt;/span&gt; from &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;helloapp&lt;/span&gt; dir. This not only creates new application, but also nicely adds remote git repository. Heroku has few stacks. Stack is OS and stuff installed on it for our applications to run. For now, the only stack that supports Play is called Cedar. It's not the default one, so you need to tell Heroku explicitely that it should be used for your application.
&lt;br /&gt; 
&lt;br /&gt; 
It is also going to ask about your credentials to authenticate you on Heroku. It is done only once, and then your &lt;strike&gt;credentials&lt;/strike&gt; key and token are stored on disk. If you want to delete them, just &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;heroku auth:logout&lt;/span&gt;.
&lt;br /&gt;
&lt;br /&gt;
Ok, so you have application on Heroku, with git repository added to your remote ones, and you have one app locally which you want now to deploy to the cloud. Well, it couldn't be simplier:
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;
git push heroku master&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
From now on it only takes some patience. Deployment takes time. When it's finished, it gives you the address, something like &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;http://blooming-stone-5863.herokuapp.com deployed to Heroku&lt;/span&gt; in the console.
&lt;br /&gt;
&lt;br /&gt;
Go to this address and you'll see your app. Have fun!&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-2508088679170622379?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/exEENWAGjBAOZcJ21Bb4HYKUoDQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/exEENWAGjBAOZcJ21Bb4HYKUoDQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/exEENWAGjBAOZcJ21Bb4HYKUoDQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/exEENWAGjBAOZcJ21Bb4HYKUoDQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/3Lv974mMCpY" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2011/11/play-with-heroku.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>5</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-1551430185588176169</guid><pubDate>Thu, 20 Oct 2011 06:56:00 +0000</pubDate><atom:updated>2011-10-20T08:56:48.470+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">warsjawa</category><category domain="http://www.blogger.com/atom/ns#">warsjawa 2011</category><title>Warsjawa 2011</title><description>&lt;span class="Apple-style-span" style="background-color: white; color: #38761d; font-family: 'Courier New', Courier, monospace;"&gt;Dear reader. This post is about Polish event, organised by Polish programmers for Polish programmers. Speaking only Polish. So if you don't speak Polish, I don't think you'd be interested. Therefore, this post is in Polish.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
W miniony weekend wybrałem się na warsztaty Warsjawa 2011. Wybrałem się z ekipą ze Szczecina jak zwykle pociągiem, co okazało się mieć taki minus, że pora roku jaka już nadeszła zapewnia że w pociągu może być albo zimno, albo gorąco. My wybraliśmy zimno. Jakoś jednak dojechaliśmy rankiem do Warszawy. Ja udałem się załatwić jeszcze parę prywatnych spraw, i nie bez drobnych komplikacji dotarłem do budynku przy Nowowiejskiej na tyle wcześnie, że mogłem jeszcze pomóc nosić ławki i krzesła.&lt;br /&gt;
&lt;br /&gt;
Z czterech dostępnych ścieżek wybrałem &lt;b&gt;DDD i CqRS,&lt;/b&gt;&amp;nbsp;prowadzone przez Sławka Sobótkę i Rafała Jamroza. Warsztaty miały części prezentacyjne, i stricte warsztatowe. O ile prezentacjom niczego nie zabrakło (przynajmniej dla mnie, ale obie widziałem już wcześniej), to część warsztatowa jakoś się "rozlazła".&lt;br /&gt;
&lt;br /&gt;
Z początku wstęp do DDD, ciekawy i świetnie poprowadzony. Dowiedzieliśmy się co to takiego to DDD, do czego się nadaje i z czym to się je. Po wstępie Sławek "oprowadził" nas po wcześniej przygotowanej na warsztaty aplikacji, pokazując "klocki DDD", z których jest zbudowana.&lt;br /&gt;
&lt;br /&gt;
W pierwszej części warsztatowej zadaniem uczestników było rozszerzenie funkcjonalności aplikacji w duchu DDD. Zaczęliśmy prawidłowo, od testów. Z braku czasu testy pozostały na etapie wstępnym, tzn. takim, w którym wystarczyło w klasie testowanej z każdej metody zwrócić &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;true&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt; żeby przechodziły&lt;/span&gt;. Więcej chyba było w tej części dyskusji, pytań i odpowiedzi niż kodowania, ale nie uważam tego za jej wadę. Wszak programowanie to przede wszystkim komunikacja. I tak czas upłynął nam do obiadu.&lt;br /&gt;
&lt;br /&gt;
Na obiad była pizza, zgodnie z obietnicami organizatorów nie zabrakło :)&lt;br /&gt;
&lt;br /&gt;
Po przerwie obiadowej znowu miała miejsce część prezentacyjna, w której Sławek pokazał co to takiego ten CqRS, i jakie ciekawe triki można stosować w celu poprawienia wydajności aplikacji. Np. mieć osobną bazę danych do zapisu i osobną do odczytu.&lt;br /&gt;
&lt;br /&gt;
Prezentacja dość płynnie przeszła w kolejne warsztaty, które jednak chyba więcej miały z prezentacji. Nie żeby mi to przeszkadzało, może nawet tak miało być :) Dowiedzieliśmy się czegoś więcej o kilku bardziej skomplikowanych wzorcach, jak &lt;i&gt;Saga&lt;/i&gt; czy &lt;i&gt;Specification&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
W ostatniej części Sławek pokazał nowe dla mnie narzędzie &lt;i&gt;JBehave&lt;/i&gt;. Musze powiedzieć, że zrobiło na mnie wrażenie, i zamierzam poświęcić trochę czasu na bliższe poznanie tegoż. Zauważam też spore podobieństwo do &lt;i&gt;Cucumbera&lt;/i&gt;, ciekawym czym się różnią.&lt;br /&gt;
&lt;br /&gt;
Po wszystkim cała nasza ekipa czuła się pozytywnie naładowana informacjami, czuło się entuzjazm do dalszego zgłębiania poruszonych tematów, a to przecież najważniejsze. I choćby to świadczyć może o sukcesie tych warsztatów.&lt;br /&gt;
&lt;br /&gt;
Jeśli miałbym szukać minusów to może za mało było napojów, no i nie było kawy. Aczkolwiek nie był do duży problem, bo w budynku były automaty zarówno z kawą, jak i z zimnymi napojami.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-1551430185588176169?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/nGBSyt_PixHTBbMvSIwTo6B3H6U/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/nGBSyt_PixHTBbMvSIwTo6B3H6U/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/nGBSyt_PixHTBbMvSIwTo6B3H6U/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/nGBSyt_PixHTBbMvSIwTo6B3H6U/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/QEna452Ar_c" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2011/10/warsjawa-2011.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-8653849272248510331</guid><pubDate>Thu, 20 Jan 2011 21:53:00 +0000</pubDate><atom:updated>2011-01-20T22:53:20.475+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">coderetreat events</category><title>First CodeRetreat in Poznań</title><description>&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;On 15th January I had a pleasure to participate in first Code Retreat in Poznań. The event was organised by Adam Dudczak and &lt;a href="http://www.jug.poznan.pl/"&gt;Poznań JUG&lt;/a&gt;. If you don't know what Code Retreat is, take a look &lt;a href="http://www.coderetreat.com/how-it-works.html"&gt;here&lt;/a&gt;. It is a great opportunity to meet other coders, see how they work and exchange knowledge and experience. There were 5 sessions, and the pairs were changing each time, so everyone coded with 5 different people.&lt;br /&gt;
&lt;br /&gt;
Idea of Code Retreat is not only to code in pairs but also to use TDD. After lunch, during break, there were two discussion groups, one discussing BDD, and the other pair programming. I joined BDD group. First it was explained what BDD is, then we were discussing. The group was very active, many people had questions but there were also many answers :)&lt;br /&gt;
&lt;br /&gt;
Programming task was standard for Code Retreats - Conway's &lt;a href="http://en.wikipedia.org/wiki/Conway%27s_game_of_life"&gt;Game Of Life&lt;/a&gt;. It's nice to watch development. During the first session we didn't finish our task, like most pairs. We barely started when the time was over. After the third session, most pairs had Game Of Life algorithm finished. Of course together with tests :)&lt;br /&gt;
&lt;br /&gt;
Such an event is not only opportunity to learn, but also to meet people. Some I already knew from twitter, blogs etc., some from other events, and some were completely new to me. There was time to talk, not only during quite short breaks between sessions, but also during lunch and "afterparty". For lunch there was not pizza, but some decent dish, huge and tasty.&lt;br /&gt;
&lt;br /&gt;
I have to write also about the place the event was held at. It was in &lt;a href="http://www.cognifide.com/AboutUs/Events/Code-Retreat"&gt;Cognifide&lt;/a&gt;&amp;nbsp;offices, and it was one of the nicest offices I've ever seen! Lunch and afterparty was in the basement, but this basement looked like a decent pub. Brick walls and ceilings, bar, comfy sofas and tables. There was also refrigerator full of beer, and it was used during afterparty :)&lt;br /&gt;
&lt;br /&gt;
For me this event was a big success. Congrats, organizers!&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-8653849272248510331?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/B9Zr9Vfm-tiGmwSz6kI9oHBV3W4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/B9Zr9Vfm-tiGmwSz6kI9oHBV3W4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/B9Zr9Vfm-tiGmwSz6kI9oHBV3W4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/B9Zr9Vfm-tiGmwSz6kI9oHBV3W4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/BTvWHw2CIns" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2011/01/first-coderetreat-in-poznan.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-4755608585134430693</guid><pubDate>Fri, 24 Dec 2010 23:07:00 +0000</pubDate><atom:updated>2010-12-25T00:07:52.353+01:00</atom:updated><title>Scala script to find duplicate files</title><description>&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;Here is simple Scala script finding duplicate files and moving them to another directory. It searches &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;album-with-duplicates&lt;/span&gt; for duplicates of files in &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;main-album&lt;/span&gt;. All duplicates found are moved to &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;copies&lt;/span&gt; directory in user's home.&lt;br /&gt;
&lt;br /&gt;
If you have some ideas how to improve it, I'd appreciate if you share it in comments.&lt;br /&gt;
&lt;br /&gt;
MD5 algorithm taken from &lt;a href="http://code-redefined.blogspot.com/2009/05/md5-sum-in-scala.html"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;/span&gt;&lt;pre class="brush: scala"&gt;package com.blogspot.pawelstawicki.remove.duplicates

import java.security.MessageDigest
import java.io.{FileInputStream, File}
import org.apache.commons.io.{FilenameUtils, FileUtils, IOUtils}

/**
 * @author ${user.name}
 */
object App {
  
  def main(args : Array[String]) {
    val dir1 = new File("/photos/main-album,");
    val dir2 = new File("/photos/album-with-duplicates");

    val dir1Content = getAllFiles(dir1)
    val dir2Content = getAllFiles(dir2)

    var dir1Map = Map[String, File]()
    dir1Content.foreach(f =&amp;gt; {
      val md5 = md5SumString(IOUtils.toByteArray(new FileInputStream(f)))
      println("md5 for " + f.getPath + ": " + md5)
      dir1Map = dir1Map + (md5 -&amp;gt; f)
    })

    var dir2Map = Map[String, File]()
    dir2Content.foreach(f =&amp;gt; {
      val md5 = md5SumString(IOUtils.toByteArray(new FileInputStream(f)))
      println("md5 for " + f.getPath + ": " + md5)
      dir2Map = dir2Map + (md5 -&amp;gt; f)
    })

    for(md51 &amp;lt;- dir1Map.keys; md52 &amp;lt;- dir2Map.keys) {

      if (md51.equals(md52)) {
        val suspectedDuplicate = dir2Map(md52)
        val original = dir1Map(md52)

        if (checkDuplicate(original, suspectedDuplicate)) {
          println(suspectedDuplicate.getPath + " is duplicate of " + original.getPath)
          val copiesDir = new File(FileUtils.getUserDirectory + "/copies/" + FilenameUtils.getPathNoEndSeparator(original.getAbsolutePath()));
          println("Moving to " + copiesDir.getPath)
          FileUtils.moveFileToDirectory(suspectedDuplicate, copiesDir, true)
        }
      }
    }
  }

  def checkDuplicate(f1: File, f2: File): Boolean = {
    val bytes1 = new Array[Byte](1024*1024)
    val bytes2 = new Array[Byte](1024*1024)

    val input1 = new FileInputStream(f1)
    val input2 = new FileInputStream(f2)

    var bytesRead1 = input1.read(bytes1)
    while(bytesRead1 &amp;gt; 0) {
      val bytesRead2 = input2.read(bytes2)

      if (bytesRead1 != bytesRead2) {
        return false;
      }

      //Bytes read number the same
      if (!bytes1.sameElements(bytes2)) {
        return false
      }

      bytesRead1 = input1.read(bytes1)
    }

    //bytesRead1 is -1. Check if bytes read number from file2 is also -1
    if (input2.read(bytes2) == -1) {
      return true;
    } else {
      return false;
    }
  }

  def md5SumString(bytes : Array[Byte]) : String = {
    val md5 = MessageDigest.getInstance("MD5")
    md5.reset()
    md5.update(bytes)

    md5.digest().map(0xFF &amp;amp; _).map { "%02x".format(_) }.foldLeft(""){_ + _}
  }

  def getAllFiles(dir : File) : List[File] = {
    var l = List[File]()
    dir.listFiles.foreach(f =&amp;gt; {
      if (f.isFile) {
        l = f :: l
      } else {
        l = l ::: getAllFiles(f)
      }
    })

    l
  }

}
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-4755608585134430693?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/sj9_o_SvzkxNeOO5_HyHQkdnpgU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sj9_o_SvzkxNeOO5_HyHQkdnpgU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/sj9_o_SvzkxNeOO5_HyHQkdnpgU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sj9_o_SvzkxNeOO5_HyHQkdnpgU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/AOo1rgHNUFc" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2010/12/scala-script-to-find-duplicate-files.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-1787883164214733154</guid><pubDate>Mon, 20 Dec 2010 23:02:00 +0000</pubDate><atom:updated>2010-12-21T00:26:36.661+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">jsf2</category><category domain="http://www.blogger.com/atom/ns#">cross-field validation</category><category domain="http://www.blogger.com/atom/ns#">cross-field</category><category domain="http://www.blogger.com/atom/ns#">cross</category><category domain="http://www.blogger.com/atom/ns#">validation</category><category domain="http://www.blogger.com/atom/ns#">jsf</category><category domain="http://www.blogger.com/atom/ns#">component</category><category domain="http://www.blogger.com/atom/ns#">field</category><title>JSF2.0 component for cross-field validation</title><description>&lt;script type="text/javascript"&gt;var dzone_url = 'http://pawelstawicki.blogspot.com/2010/12/jsf20-component-for-cross-field.html';&lt;/script&gt;&lt;script type="text/javascript"&gt;var dzone_title = 'JSF2.0 component for cross-field validation';&lt;/script&gt;&lt;script type="text/javascript"&gt;var dzone_blurb = '';&lt;/script&gt;&lt;script type="text/javascript"&gt;var dzone_style = '2';&lt;/script&gt;&lt;script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;Have you ever had problems with cross-field validation in JSF? Me too, so I created this component. You can validate few &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;UIInput&lt;/span&gt; components and have their values as &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;List&lt;/span&gt; in validator. The component is in softwaremill-faces library. To use it in maven project, add repository:&lt;br /&gt;
&lt;pre class="brush: xml"&gt;&amp;lt;repository&amp;gt;
  &amp;lt;url&amp;gt;http://tools.softwaremill.pl/nexus/content/groups/smlcommon-repos/ &amp;lt;/url&amp;gt;
  &amp;lt;layout&amp;gt;default&amp;lt;/layout&amp;gt;
  &amp;lt;releases&amp;gt;
    &amp;lt;enabled&amp;gt;true&amp;lt;/enabled&amp;gt;
  &amp;lt;/releases&amp;gt;
  &amp;lt;snapshots&amp;gt;
    &amp;lt;enabled&amp;gt;true&amp;lt;/enabled&amp;gt;
  &amp;lt;/snapshots&amp;gt;
&amp;lt;/repository&amp;gt;
&lt;/pre&gt;and dependency:&lt;br /&gt;
&lt;pre class="brush: xml"&gt;&amp;lt;dependency&amp;gt;
  &amp;lt;groupId&amp;gt;pl.softwaremill.common&amp;lt;/groupId&amp;gt;
  &amp;lt;artifactId&amp;gt;softwaremill-faces&amp;lt;/artifactId&amp;gt;
  &amp;lt;version&amp;gt;43-SNAPSHOT&amp;lt;/version&amp;gt;
&amp;lt;/dependency&amp;gt;
&lt;/pre&gt;Now you can use multiValidator component. First add namespace to your .xhtml page:&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;xmlns:v="http://pl.softwaremill.common.faces/components"&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Then just wrap components you want to cross-validate in &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;v:multiValidator&amp;gt;&lt;/span&gt;. If you attach validator to this component, &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;value&lt;/span&gt;&amp;nbsp;parameter that goes to validation method is &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;List&lt;/span&gt; of values of &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;UIInput&lt;/span&gt; components inside&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;v:multivalidator&gt;&lt;/v:multivalidator&gt;&lt;/span&gt;&amp;nbsp;tag.&lt;br /&gt;
&lt;br /&gt;
E.g. if you want to validate two checkboxes. Each can be checked or unchecked, but at least one has to be checked.&lt;br /&gt;
&lt;pre class="brush: xhtml"&gt;&amp;lt;v:multiValidator id="multi" validator="#{bean.validationMethod}"&amp;gt;
  &amp;lt;h:selectBooleanCheckbox value="#{bean.check1}" /&amp;gt;
  &amp;lt;h:selectBooleanCheckbox value="#{bean.check2}" /&amp;gt;
&amp;lt;/v:multiValidator&amp;gt;
&amp;lt;h:message for="multi" /&amp;gt;
&lt;/pre&gt;Validation method in bean:&lt;br /&gt;
&lt;pre class="brush: java"&gt;public void validationMethod(FacesContext context, UIComponent component, Object value) {
  List&amp;lt;Object&amp;gt; values = (List&amp;lt;Object&amp;gt;) value;
  //value is list of values of both selectBooleanCheckboxes
  Boolean firstChecked = (Boolean) values.get(0);
  Boolean secondChecked = (Boolean) values.get(1);

  if (! (firstChecked || secondChecked)) {
    Message message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Check at least one checkbox", null);
    throw new ValidatorException(message);
  }
}
&lt;/pre&gt;If none checkbox is checked error message is displayed in &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;h:message for="multi"&amp;gt;&lt;/span&gt; tag.&lt;br /&gt;
&lt;br /&gt;
Source code of this component is on &lt;a href="https://github.com/softwaremill/softwaremill-common/blob/master/softwaremill-faces/src/main/java/pl/softwaremill/common/faces/validator/MultiValidator.java"&gt;github&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Any suggestions, opinions or questions regarding this component are welcome. Have a good time using it :)&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-1787883164214733154?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/-x7FlY6L1bJtCdmYLql-54EXUOw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-x7FlY6L1bJtCdmYLql-54EXUOw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/-x7FlY6L1bJtCdmYLql-54EXUOw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-x7FlY6L1bJtCdmYLql-54EXUOw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/KlBqqdkKEtE" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2010/12/jsf20-component-for-cross-field.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-2335318368224110209</guid><pubDate>Tue, 02 Nov 2010 22:51:00 +0000</pubDate><atom:updated>2010-11-02T23:51:43.626+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">uibinder</category><category domain="http://www.blogger.com/atom/ns#">gwt</category><title>GWT table row as UiBinder</title><description>&lt;div class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;Some time ago I wanted to dynamically add rows to a table in GWT, but I wanted to define row template using &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;UiBinder&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;. Programatically it is no problem. You can create &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;FlexTable&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt; and add widgets to it. The problem arises when you want to do it using &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;UiBinder&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;. You can create a &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;FlexTable&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt; in &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;UiBinder&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;, and you can create widgets, but you can't create element which renders to html tag &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;. &lt;a href="http://blog.xemantic.com/"&gt;Kazik Pogoda&lt;/a&gt; found a way to do it.&lt;/span&gt;&lt;br /&gt;
&lt;div style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;First we need two widgets which renter to &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt; and &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;. The code for TR:&lt;/span&gt;&lt;/div&gt;&lt;pre class="brush: java" style="font-family: Verdana, sans-serif;"&gt;public class TrElement extends ComplexPanel {
  private TableRowElement tr;

  public TrElement() {
    Document doc = Document.get();
    tr = doc.createTRElement();
    setElement(tr);
  }

  @Override
  public void add(Widget child) {
    add(child, (Element) tr.cast());
  }
}
&lt;/pre&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;The TD is analogous, just change &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;TableRowElement&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt; into &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;TableCellElement&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt; and &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;doc.createTRElement()&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt; into &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;doc.createTDElement()&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;. We can now create &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;UiBinder xml&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt; file which renders to single table row (TR element is it's root):&lt;/span&gt;&lt;/div&gt;&lt;pre class="brush: xml" style="font-family: Verdana, sans-serif;"&gt;&amp;lt;!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"&amp;gt;
&amp;lt;ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
      xmlns:g="urn:import:com.google.gwt.user.client.ui"
      xmlns:my="urn:import:pl.my.gwt.client"&amp;gt;
 
  &amp;lt;my:TrElement&amp;gt;
    &amp;lt;my:TdElement&amp;gt;
      &amp;lt;g:HTMLPanel&amp;gt;
        &amp;lt;g:Label ui:field="icon" styleName="Icon"&amp;gt;&amp;lt;/g:Label&amp;gt;
        &amp;lt;g:Label ui:field="title" styleName="Title"&amp;gt;&amp;lt;/g:Label&amp;gt;
        &amp;lt;g:Label ui:field="description" styleName="Description"&amp;gt;&amp;lt;/g:Label&amp;gt;
      &amp;lt;/g:HTMLPanel&amp;gt;
    &amp;lt;/my:TdElement&amp;gt;
    &amp;lt;my:TdElement&amp;gt;
      &amp;lt;g:Label ui:field="price" styleName="Price"&amp;gt;&amp;lt;/g:Label&amp;gt;
    &amp;lt;/my:TdElement&amp;gt;
  &amp;lt;/my:TrElement&amp;gt;
&amp;lt;/ui:UiBinder&amp;gt;
&lt;/pre&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;Here is how we can use it to add to a table (&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;FlexTable&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;):&lt;/span&gt;&lt;/div&gt;&lt;pre class="brush: java" style="font-family: Verdana, sans-serif;"&gt;TableRowView trView = new TableRowView();
table.getElement().appendChild(trView.getElement());
&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-2335318368224110209?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/OvjkKbljFx-A0rxZcD_GHUJ0BLI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/OvjkKbljFx-A0rxZcD_GHUJ0BLI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/OvjkKbljFx-A0rxZcD_GHUJ0BLI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/OvjkKbljFx-A0rxZcD_GHUJ0BLI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/kd81GuzFnfw" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2010/11/gwt-table-row-as-uibinder.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-2971570036167162028</guid><pubDate>Fri, 29 Oct 2010 23:45:00 +0000</pubDate><atom:updated>2010-10-30T01:45:22.406+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">warsjawa</category><category domain="http://www.blogger.com/atom/ns#">warsjawa 2010</category><title>Warsjawa 2010. Impressions.</title><description>&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;My impressions after this year's &lt;a href="http://github.com/warszawajug/warsjawa2010/wiki/Konferencja-Warsjawa-2010"&gt;Warsjawa&lt;/a&gt; are very positive. Well, in fact I could expect this :) Presentations were interesting, meeting other IT people is always good too. I met &lt;a href="http://bartekzdanowski.pl/"&gt;Bartek Zdanowski&lt;/a&gt;, who wanted to meet me. It's quite strange feeling when you meet somebody who knows you, but didn't meet you before. Strange but nice :)&lt;br /&gt;
&lt;br /&gt;
First presentation was about &lt;a href="http://www.playframework.org/"&gt;Play&lt;/a&gt;&amp;nbsp;framework by &lt;a href="http://sites.google.com/site/wojtassj2/"&gt;Wojciech Erbetowski&lt;/a&gt;. I was a little late, but I've seen enough to notice that Play is framework different than all the others.&lt;br /&gt;
&lt;br /&gt;
I was a bit disappointed that &lt;a href="http://art-of-software.blogspot.com/"&gt;Sławek Sobótka&lt;/a&gt; didn't make it there (he fell ill). He's topic was the most interesting for me. However, &lt;a href="http://www.pawellipinski.com/"&gt;Paweł Lipiński&lt;/a&gt; worthily replaced him. Paweł was talking about what in programming he was taught by... his own children, kindergarten, &lt;a href="http://en.wikipedia.org/wiki/Roomba"&gt;Roomba&lt;/a&gt;&amp;nbsp;etc. I never noticed that when there are 2-3 people in a project, it is much cleaner, but it's becoming a mess when there are more than 5 people. I never noticed it, but now it's very clear to me. It seems Paweł is a man who can learn and get knowledge from anything. Ah, and he mentioned me :)&lt;br /&gt;
&lt;br /&gt;
This year on Warsjawa there was also something from our &lt;a href="http://groups.google.com/group/szczecin-jug"&gt;Szczecin JUG&lt;/a&gt;. &lt;a href="http://luksza.org/"&gt;Darek "Lock" Łuksza&lt;/a&gt; presented &lt;a href="http://git-scm.com/"&gt;Git&lt;/a&gt; version control system and it's Eclipse plugin &lt;a href="http://www.eclipse.org/egit/"&gt;EGit&lt;/a&gt;. Darek did great job, and even found one bug during presentation :) It seemed a bit embarassing for him, but the rest was very good. He knows the topic very well (he's EGit commiter) and he showed many things coding live. Overall presentation was very good.&lt;br /&gt;
&lt;br /&gt;
After Darek's presentation pizza arrived. It disappeared quite quickly, maybe there was a bit too few. We run out of beverages too. Anyway I didn't hear somebody died of hunger or thirst, so it wasn't that bad :)&lt;br /&gt;
&lt;br /&gt;
Next interesting presentation was about &lt;a href="http://clojure.org/"&gt;Clojure&lt;/a&gt;. This time there were two presenters. First &lt;a href="http://www.clojureblog.pl/"&gt;Marcin Rzewucki&lt;/a&gt; showed us some theory, then &lt;a href="http://jan.rychter.com/"&gt;Jan Rychter&lt;/a&gt; told about practical use of Clojure in &lt;a href="http://fablo.pl/"&gt;Fablo&lt;/a&gt;. He showed few interesting features of this language, like &lt;a href="http://en.wikipedia.org/wiki/Software_transactional_memory"&gt;STM&lt;/a&gt;. Thanks to STM in Fablo they are able to replace customer's database without stopping the service. Pretty impressive.&lt;br /&gt;
&lt;br /&gt;
Did you know that in Java you can have two methods with the same name and arguments, differing only by return type? Compiler can't compile this, but if you write it in bytecode it is perfectly valid! This and others interesting things about bytecode were shown by Adam Michalik. I wonder if any company needs "bytecode programmer"? I like such low-level stuff. At the university I always liked assembler.&lt;br /&gt;
&lt;br /&gt;
The last presentation by &lt;a href="http://rrusin.blogspot.com/"&gt;Rafał Rusin&lt;/a&gt; was about &lt;a href="http://incubator.apache.org/hise/"&gt;Apache HISE&lt;/a&gt;. I have to admit I was too tired and the topic was not very interesting for me, so I didn't remember much from this one.&lt;br /&gt;
&lt;br /&gt;
Generally I think this was very nice conference. Meeting new people, and some older friends, is always nice. Listening to interesting people talking about interesting things is also nice. It seems one hour for presentation is very good duration. All the presenters could do all they wanted/needed (at least it seemed so). I remember on &lt;a href="http://2010.geecon.org/"&gt;GeeCON&lt;/a&gt;&amp;nbsp;there was only 45 minutes and it was too little. If only there was more pizza (or maybe something better?) and beverages it would be perfect.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-2971570036167162028?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/pGthAIlFDk1L3iWKz8ACwI0gJHI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/pGthAIlFDk1L3iWKz8ACwI0gJHI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/pGthAIlFDk1L3iWKz8ACwI0gJHI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/pGthAIlFDk1L3iWKz8ACwI0gJHI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/lPu_xt1XG8w" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2010/10/warsjawa-2010-impressions.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-8770566953086883390</guid><pubDate>Wed, 13 Oct 2010 08:58:00 +0000</pubDate><atom:updated>2010-10-13T10:58:53.222+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">tokengsm</category><category domain="http://www.blogger.com/atom/ns#">jme</category><category domain="http://www.blogger.com/atom/ns#">j2me on android</category><category domain="http://www.blogger.com/atom/ns#">j2me</category><category domain="http://www.blogger.com/atom/ns#">jme on android</category><category domain="http://www.blogger.com/atom/ns#">android</category><title>Convert JME application to Android</title><description>&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;Here is the story:&lt;br /&gt;
&lt;br /&gt;
I bought Android phone. Earlier I was using Windows Mobile phone, and I had one j2me application on it that was very important to me. It was "TokenGSM", application which serves the same purpose as RSA tokens, but installed on my phone. Very good decision of my bank that they created it so users don't have to carry additional device with them (users have choice, you can also get RSA token if you prefer it). So this application is necessary if I want to log in to my bank account. Pretty vital.&lt;br /&gt;
&lt;br /&gt;
But, as you probably know, there is no Java ME on Android :( Here is what I did (&lt;a href="http://forum.android.com.pl/f34/tokengsm-1673/index3.html"&gt;this forum was useful&lt;/a&gt;):&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;Call the bank and ask for new GSM token. Token is somehow bound to the phone, so if you change phone, you need new token.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;Write down URL from WAP Push SMS. Do it before opening it. On my phone (Android 2.2, HTC Desire) if you don't do it but just try to open URL, it's lost. Browser can't open it, but you don't even have chance to see it. Browser just blinks and returns to home screen :| It's not in history, nor in downloads.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;Go to &lt;a href="http://www.netmite.com/android/"&gt;http://www.netmite.com/android/&lt;/a&gt; and download App Runner. I went there from my phone and downloaded directly to it. I'm not sure if this point is really necessary, but some say it is.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;Click "Convert existing j2mes into apk &amp;amp; upload to Android Market." I don't think it really uploads to Market.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;Enter your written down URL and click "Get Apk". You have your Android TokenGSM :)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;Transfer the file to your phone and install it.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;Now you have to activate the token with code you received from the bank.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-8770566953086883390?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/gcUEmUUmL_GjJOP-rdBJV3HMi8s/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gcUEmUUmL_GjJOP-rdBJV3HMi8s/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/gcUEmUUmL_GjJOP-rdBJV3HMi8s/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gcUEmUUmL_GjJOP-rdBJV3HMi8s/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/uYqsK2bTkK0" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2010/10/convert-jme-application-to-android.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-1877647165714347737</guid><pubDate>Sun, 26 Sep 2010 21:38:00 +0000</pubDate><atom:updated>2010-12-06T16:29:57.866+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">jsf2</category><category domain="http://www.blogger.com/atom/ns#">flash scope</category><title>Flash scope in JSF 2.0 (nothing about Adobe Flash)</title><description>&lt;div class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;In JSF 2.0, amongst &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Request&lt;/span&gt;, &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Session&lt;/span&gt; etc, there is the new scope called &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Flash&lt;/span&gt;. (However there is no annotation &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;@FlashScope&lt;/span&gt;, and you can't put bean in this scope). It's concept is taken from Ruby on Rails. Data in &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Flash&lt;/span&gt; scope are available for current and for next request, but not for subsequent requests. Usage is very simple.&lt;br /&gt;
On first page (e.g. &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;index.html&lt;/span&gt;):&lt;br /&gt;
&lt;pre class="brush: xml"&gt;&amp;lt;h:form&amp;gt;
  &amp;lt;h:inputtext value="#{flash.text}"&amp;gt;
  &amp;lt;h:commandbutton action="page?faces-redirect=true" value="To page"&amp;gt;
&amp;lt;/h:form&amp;gt;
&lt;/pre&gt;And this is the page we are redirecting to, &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;page.xhtml&lt;/span&gt;:&lt;br /&gt;
&lt;pre class="brush: xml"&gt;&amp;lt;h:form&amp;gt;
  &amp;lt;h:outputtext value="#{flash.text}"&amp;gt;
&amp;lt;/h:form&amp;gt;
&lt;/pre&gt;Why would you need such scope? Imagine you want to enter data on one page, then redirect to another page, and display this data. If not for redirect, we could use &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Request&lt;/span&gt; scope. But with redirect value is sent with request, then browser is redirected to another page, and makes another request. &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Request&lt;/span&gt; scoped value is gone. In such case &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Flash&lt;/span&gt; scope becomes useful. We can put value in this scope with one request, and when another request is made, the value is still there. But it is not stored in session, and is not available for subsequent requests.&lt;br /&gt;
&lt;br /&gt;
However, there is a way to make data in &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Flash&lt;/span&gt; scope alive a bit longer. It is enough if in &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;page.xhtml&lt;/span&gt; we change &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;#{flash.text}&lt;/span&gt; to &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;#{flash.keep.text}&lt;/span&gt;. This way data is not removed from the scope after first request, but is available for one more.&lt;br /&gt;
&lt;br /&gt;
In managed beans, you can get flash scope by&lt;br /&gt;
&lt;pre class="brush: java"&gt;Flash flash = FacesContext.getCurrentInstance().getExternalContext().getFlash();
&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-1877647165714347737?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/6nqwqRayxt0s9D8ui8-myL47i_Y/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6nqwqRayxt0s9D8ui8-myL47i_Y/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/6nqwqRayxt0s9D8ui8-myL47i_Y/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6nqwqRayxt0s9D8ui8-myL47i_Y/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/8uwVR5Sz8hg" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2010/09/flash-scope-in-jsf-20-nothing-about.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-6868328936791707726</guid><pubDate>Fri, 27 Aug 2010 23:22:00 +0000</pubDate><atom:updated>2010-08-28T01:40:54.039+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">jsf2</category><category domain="http://www.blogger.com/atom/ns#">template</category><category domain="http://www.blogger.com/atom/ns#">jsf</category><title>JSF 2 templating</title><description>&lt;script type="text/javascript"&gt;var dzone_url = 'http://pawelstawicki.blogspot.com/2010/08/jsf-2-templating.html';&lt;/script&gt;&lt;script type="text/javascript"&gt;var dzone_title = 'JSF 2 templating';&lt;/script&gt;&lt;script type="text/javascript"&gt;var dzone_blurb = 'JSF 2 templating with &amp;lt;ui:...&amp;gt; tags';&lt;/script&gt;&lt;script type="text/javascript"&gt;var dzone_style = '2';&lt;/script&gt;&lt;script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"&gt;&lt;/script&gt;&lt;div class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;In this post I want to share my knowledge about JSF 2 templating. Most of this post are source codes, but if you are novice and don't know how to start, and where to put the source code, here you go.&lt;br /&gt;
&lt;h4&gt;0. Download Netbeans and setup the project.&lt;/h4&gt;Install Netbeans and run it. I use version 6.9. In Netbeans, go to &lt;i&gt;File -&amp;gt; New Project...&lt;/i&gt; and then choose &lt;i&gt;Java Web&lt;/i&gt; and &lt;i&gt;Web Application&lt;/i&gt;. Click Next.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_zOPiqa0XBio/TGxdB3R6wvI/AAAAAAAAAR4/DUsAUsNgqi4/s1600/choose+project.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="427" src="http://4.bp.blogspot.com/_zOPiqa0XBio/TGxdB3R6wvI/AAAAAAAAAR4/DUsAUsNgqi4/s640/choose+project.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
In next window choose project name, optionally directory where to store it, and set the project as the main project.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_zOPiqa0XBio/TGxd9nAYU2I/AAAAAAAAAR8/VNgDbV5qvqA/s1600/project+name.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="411" src="http://4.bp.blogspot.com/_zOPiqa0XBio/TGxd9nAYU2I/AAAAAAAAAR8/VNgDbV5qvqA/s640/project+name.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;In the next window leave &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;None&amp;gt;&lt;/span&gt; in enterprise application and choose web server. Default should be ok, the same about context path.&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_zOPiqa0XBio/TG2xL9Cwx1I/AAAAAAAAASM/deNPMtWXAA8/s1600/server.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="356" src="http://3.bp.blogspot.com/_zOPiqa0XBio/TG2xL9Cwx1I/AAAAAAAAASM/deNPMtWXAA8/s640/server.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: left;"&gt;Check &lt;i&gt;JavaServer Faces&lt;/i&gt;. In &lt;i&gt;Libraries&lt;/i&gt;&amp;nbsp;tab&amp;nbsp;select &lt;i&gt;Registered Libraries&lt;/i&gt;&amp;nbsp;and &lt;i&gt;JSF 2.0&lt;/i&gt;.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_zOPiqa0XBio/TG2x-rggtWI/AAAAAAAAASU/WjWbMeiG7qE/s1600/frameworks.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="358" src="http://2.bp.blogspot.com/_zOPiqa0XBio/TG2x-rggtWI/AAAAAAAAASU/WjWbMeiG7qE/s640/frameworks.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;h4&gt;1. Simple template and it's client. &amp;lt;ui:insert&amp;gt; and &amp;lt;ui:define&amp;gt;&lt;/h4&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Ok, we'll create simpliest template possible. In &lt;i&gt;Web Pages&lt;/i&gt;&amp;nbsp;create new &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;.xhtml&lt;/span&gt; file, let's name it &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;headerFooter.xhtml&lt;/span&gt;. It's our template containing header, footer, and place for some content between them.&lt;/div&gt;&lt;br /&gt;
&lt;div style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_zOPiqa0XBio/TG7vow15yRI/AAAAAAAAASk/1nj42z28Rqo/s1600/simpleTemplate.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="336" src="http://1.bp.blogspot.com/_zOPiqa0XBio/TG7vow15yRI/AAAAAAAAASk/1nj42z28Rqo/s640/simpleTemplate.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;You can let Netbeans create it for you along with nice CSS files, you can also select one of predefined template layouts. Click &lt;i&gt;File -&amp;gt; &amp;nbsp;New File -&amp;gt; JavaServer Faces -&amp;gt; Facelets Template&lt;/i&gt;. Our template code:&lt;/div&gt;&lt;pre class="brush: xml"&gt;&amp;lt;?xml version='1.0' encoding='UTF-8' ?&amp;gt;
&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&amp;gt;
&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"&amp;gt;
    &amp;lt;h:head&amp;gt;
        &amp;lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&amp;gt;
        &amp;lt;title&amp;gt;Header-Footer Template&amp;lt;/title&amp;gt;
    &amp;lt;/h:head&amp;gt;
    &amp;lt;h:body&amp;gt;
        &amp;lt;div id="top"&amp;gt;
            Here goes our header
        &amp;lt;/div&amp;gt;
        &amp;lt;div id="content" class="center_content"&amp;gt;
            &amp;lt;ui:insert name="content"&amp;gt;Content&amp;lt;/ui:insert&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div id="bottom"&amp;gt;
            And here footer
        &amp;lt;/div&amp;gt;
    &amp;lt;/h:body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Now create template client. It is a page which uses the template. Let's call it &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;templateClient.xhtml&lt;/span&gt;:&lt;/div&gt;&lt;pre class="brush: xml"&gt;&amp;lt;?xml version='1.0' encoding='UTF-8' ?&amp;gt;
&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&amp;gt;
&amp;lt;ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./headerFooter.xhtml"&amp;gt;
    
    &amp;lt;ui:define name="content"&amp;gt;
        content
    &amp;lt;/ui:define&amp;gt;

&amp;lt;/ui:composition&amp;gt;
&lt;/pre&gt;In template there is &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;ui:insert&amp;gt;&lt;/span&gt; tag. This is a named place where content from template client goes, and it's name in this case is &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;content&lt;/span&gt;. In client, there is &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;ui:composition&amp;gt;&lt;/span&gt;. It uses template given as tags attribute, and has &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;ui:define&amp;gt;&lt;/span&gt; tags, with the same name as &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;ui:insert&amp;gt;&lt;/span&gt; in template. So what's in &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;ui:define&amp;gt;&lt;/span&gt; tag is inserted in place of &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;ui:insert&amp;gt;&lt;/span&gt; with the same name. You can run your project (in Netbeans right-click on project and select &lt;i&gt;Run&lt;/i&gt;) and see the templated page&amp;nbsp;at&amp;nbsp;&lt;a href="http://localhost:8080/JsfTemplating/faces/templateClient.xhtml"&gt;http://localhost:8080/JsfTemplating/faces/templateClient.xhtml&lt;/a&gt;&amp;nbsp;Any content surrounding &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;ui:composition&amp;gt;&lt;/span&gt; tag is ommitted.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_zOPiqa0XBio/THGQYYdOgtI/AAAAAAAAAS0/z_uiXfKX-vk/s1600/dataflow.jpg.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="508" src="http://3.bp.blogspot.com/_zOPiqa0XBio/THGQYYdOgtI/AAAAAAAAAS0/z_uiXfKX-vk/s640/dataflow.jpg.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;Template client can also be a template. Just put some&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;ui:insert&amp;gt;&lt;/span&gt;&amp;nbsp;tag inside of&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;ui:define&amp;gt;&lt;/span&gt;&amp;nbsp;block. E.g.&lt;br /&gt;
&lt;pre class="brush: xml"&gt;&amp;lt;ui:define name="content"&amp;gt;
    &amp;lt;div class="info"&amp;gt;
        Here goes some additional info, which is not in the header nor in the footer, but we need it on some pages.
    &amp;lt;/div&amp;gt;
    &amp;lt;ui:insert name="innerContent"&amp;gt;
&amp;lt;/ui:define&amp;gt;
&lt;/pre&gt;&lt;h4&gt;2. Decorate&lt;/h4&gt;We can also insert parts of markup in our pages. If you have piece of code which you put on some pages and it's always the same, you can separate it to a file and just insert it in the pages. &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;ui:decorate&amp;gt;&lt;/span&gt; tag is used for this:&lt;br /&gt;
&lt;pre class="brush: xml"&gt;&amp;lt;?xml version='1.0' encoding='UTF-8' ?&amp;gt;
&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&amp;gt;
&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"&amp;gt;
    &amp;lt;body&amp;gt;
        Some page text
        &amp;lt;ui:decorate template="./disclaimer.xhtml"/&amp;gt;
    &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;Content of &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;disclaimer.xhtml&lt;/span&gt;&amp;nbsp;is injected where&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;ui:decorate&amp;gt;&lt;/span&gt;&amp;nbsp;tag is. Don't add &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;?xml ... ?&amp;gt;&lt;/span&gt; declaration or doctype there, or it is going to be inserted in the middle of your page, which is not desirable. You can also use standard templating&amp;nbsp;in &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;disclaimer.xhtml&lt;/span&gt;. You can put&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;ui:insert&amp;gt;&lt;/span&gt;&amp;nbsp;there and&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;ui:define&amp;gt;&lt;/span&gt;&amp;nbsp;in page which uses it.&lt;br /&gt;
&lt;h4&gt;3. Include&lt;/h4&gt;Another method to attach some piece of markup is&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;ui:include&amp;gt;&lt;/span&gt;. This one also lets us pass some parameter to the piece of code we want to include, and this parameter can be managed bean. Lets say we have bean with information about some documents:&lt;br /&gt;
&lt;pre class="brush: java"&gt;@ManagedBean
public class Paper {

    private String author;
    private String title;

    //getters and setters omitted
}&lt;/pre&gt;Piece of code to display information about a book is prepared in &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;book.xhtml&lt;/span&gt; file:&lt;br /&gt;
&lt;pre class="brush: xml"&gt;&amp;lt;div xmlns="http://www.w3.org/1999/xhtml"&amp;gt;
    Book "#{book.title}" by #{book.author}
&amp;lt;/div&amp;gt;&lt;/pre&gt;Now in any other JSF page we can use it:&lt;br /&gt;
&lt;pre class="brush: xml"&gt;&amp;lt;ui:include src="./book.xhtml"&amp;gt;
    &amp;lt;ui:param name="book" value="#{tomSawyer}" /&amp;gt;
&amp;lt;/ui:include&amp;gt;&lt;/pre&gt;I hope this post is going to be helpful to somebody. At least to me. Happy templating with JSF!&lt;br /&gt;
&lt;/div&gt;&lt;iframe src="http://www.facebook.com/widgets/like.php?href=http://pawelstawicki.blogspot.com/2010/08/jsf-2-templating.html"
        scrolling="no" frameborder="0"
        style="border:none; width:450px; height:80px"&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-6868328936791707726?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/J__aO2VcRiYSY-HDqXAwk_qsFzM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/J__aO2VcRiYSY-HDqXAwk_qsFzM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/J__aO2VcRiYSY-HDqXAwk_qsFzM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/J__aO2VcRiYSY-HDqXAwk_qsFzM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/G5OHBWR1T5g" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2010/08/jsf-2-templating.html</link><author>noreply@blogger.com (pawelstawicki)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_zOPiqa0XBio/TGxdB3R6wvI/AAAAAAAAAR4/DUsAUsNgqi4/s72-c/choose+project.jpg" height="72" width="72" /><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-8495082012833529782</guid><pubDate>Mon, 09 Aug 2010 21:11:00 +0000</pubDate><atom:updated>2010-08-10T09:26:20.309+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">jpa</category><category domain="http://www.blogger.com/atom/ns#">puzzle</category><title>JPA Puzzle. When your entity misses some fields.</title><description>Today I encountered quite interesting problem. It wasted few hours of my life, so maybe if you read this you can save some. Example is simplified as much as possible.&lt;br /&gt;
&lt;pre class="brush: java"&gt;@Entity
@Table(name = "PERSONS")
@NamedNativeQueries({
    @NamedNativeQuery(
        name = "getPersonBasic",
        query = "SELECT p.name, p.surname FROM persons where p.surname = ?",
        resultClass = Person.class),
    @NamedNativeQuery(
        name = "getPersonDetails",
        query = "SELECT p.name, p.surname, p.age, p.street, p.city FROM persons where p.surname = ?",
        resultClass = Person.class)
})
public class Person {
    
    private String name;

    @Id
    private String surname;

    private int age;

    private String street;

    private String city;

}
&lt;/pre&gt;&lt;br /&gt;
Now, in my application I am getting &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Person&lt;/span&gt; with surname "Stawicki" without details, by &lt;i&gt;"getPersonBasic"&lt;/i&gt; query. Then I need detailed person in the same transaction, so I execute &lt;i&gt;"getPersonDetails"&lt;/i&gt;. And... I am getting &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Person&lt;/span&gt; without age, street and city. This three fields are null. Why? Do you already know? If not, look below for answer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The problem is in cache, and in &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;@Id&lt;/span&gt; which is only on surname field. First person is retrieved without details and stored in cache. Then we try to get person with details, but JPA doesn't understand difference between our queries. It queries the database, and identifies that if it builds entity from resulting &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ResultSet&lt;/span&gt;, it is going to have the same &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;@Id&lt;/span&gt; as entity which is already in cache. If &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;@Id&lt;/span&gt; is the same, logically it is the same entity. So it just returns it without building whole entity from &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ResultSet&lt;/span&gt;.&lt;br /&gt;
&lt;iframe src="http://www.facebook.com/widgets/like.php?href=http://pawelstawicki.blogspot.com/2010/08/jpa-puzzle-when-your-entity-misses-some.html"
        scrolling="no" frameborder="0"
        style="border:none; width:450px; height:80px"&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-8495082012833529782?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/UPshGsVBNCzQ_HI3NqFB_NpAzFM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/UPshGsVBNCzQ_HI3NqFB_NpAzFM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/UPshGsVBNCzQ_HI3NqFB_NpAzFM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/UPshGsVBNCzQ_HI3NqFB_NpAzFM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/373HkGUi4CQ" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2010/08/jpa-puzzle-when-your-entity-misses-some.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-1938916841431681315</guid><pubDate>Tue, 27 Jul 2010 20:57:00 +0000</pubDate><atom:updated>2010-07-28T12:02:48.311+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">review</category><category domain="http://www.blogger.com/atom/ns#">Real World Java EE Patterns Rethinking Best Practices</category><title>Review: Real World Java EE Patterns Rethinking Best Practices, by Adam Bien</title><description>&lt;a href="http://www.amazon.com/Real-World-Patterns-Rethinking-Practices/dp/0557078326?ie=UTF8&amp;amp;tag=pawelsblog-20&amp;amp;link_code=bil&amp;amp;camp=213689&amp;amp;creative=392969" imageanchor="1" target="_blank"&gt;&lt;img alt="Real World Java EE Patterns Rethinking Best Practices" src="http://ws.amazon.com/widgets/q?MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;ID=AsinImage&amp;amp;WS=1&amp;amp;Format=_SL160_&amp;amp;ASIN=0557078326&amp;amp;tag=pawelsblog-20" /&gt;&lt;/a&gt;&lt;img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=pawelsblog-20&amp;amp;l=bil&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=0557078326" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /&gt;&lt;br /&gt;
&lt;br /&gt;
"Real World Java EE Patterns" is a book targeted rather for developers with some experience with JEE. If you are a beginner, you can miss some context. If you have some experience with JEE, in this book you'll probably find solutions to problems that are familiar to you.&lt;br /&gt;
&lt;br /&gt;
Adam Bien is great at explaining difficult topics. Difficult? I didn't find anything difficult in this book ;) E.g. transactions isolation is explained very clearly. &lt;br /&gt;
&lt;br /&gt;
The book is very good catalog of JEE Patterns. Each pattern is described separately in similar manner. Each chapter has subchapters: "Problem", "Forces", "Solution", "Testing", "Documentation", "Consequences" and "Related Patterns". In "Problem" a reader can find short description of a problem the pattern should solve. "Forces" shows features that solution should have. "Solution" contains description of pattern, what classes it consists of and what is their responsibility. Usually accompanied by very clear and simple pieces of code. In "Testing" and "Documentation" author highlights what should we test when we use certain pattern, and what should be documented (quite obvious, isn't it?). In "Consequences" we can read about what are pros and cons of the pattern. "Related Patterns" is self explanatory. Most interesting subchapter is "Solution", and it also has sub-subchapters. One of them is "Rethinking". It is good part for experienced JEE developers. Adam shows why some patterns are obsolete. It doesn't mean you should never use it, but in most cases it is no longer necessary in JEE5 or 6. Some patterns, when moved from EJB2 to EJB3, are not adding any value, but instead are adding layer of abstraction and unnecessary complicating the system.&lt;br /&gt;
&lt;br /&gt;
What I like about Adam Bien is that he is not only writing and talking about programming, but he's also programming. While reading the book, one can feel that the author has real experience with the topic. Sometimes he advices not to use what is common "best practice", when it is not necessary and is not adding any value. Good programmer should be able to balance pros and cons of possible solutions, not just blindly follow common practice.&lt;br /&gt;
&lt;br /&gt;
There are small mistakes in the book, but only editor ones, like misspellings and formatting mistakes, single lines of code on next/previous page etc. Nothing really annoying, but there is room for improvement on this field.&lt;br /&gt;
&lt;br /&gt;
Thank you Adam for this book!&lt;br /&gt;
&lt;br /&gt;
&lt;iframe src="http://www.facebook.com/widgets/like.php?href=http://pawelstawicki.blogspot.com/2010/07/review-real-world-java-ee-patterns.html"
        scrolling="no" frameborder="0"
        style="border:none; width:450px; height:80px"&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-1938916841431681315?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Lqatl3LxQce8gG4vcWOt5M-lwJs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Lqatl3LxQce8gG4vcWOt5M-lwJs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Lqatl3LxQce8gG4vcWOt5M-lwJs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Lqatl3LxQce8gG4vcWOt5M-lwJs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/Ghif7BLmJ2o" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2010/07/review-real-world-java-ee-patterns.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-2603365714764060619</guid><pubDate>Sun, 30 May 2010 22:23:00 +0000</pubDate><atom:updated>2010-06-07T00:05:49.279+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">transaction isolation</category><title>Transaction isolation level</title><description>&lt;script type="text/javascript"&gt;var dzone_url = 'http://pawelstawicki.blogspot.com/2010/05/transaction-isolation-level.html';&lt;/script&gt;
&lt;script type="text/javascript"&gt;var dzone_title = 'Transaction isolation levels explained';&lt;/script&gt;
&lt;script type="text/javascript"&gt;var dzone_blurb = 'Transactions were invented to make operations on database atomic, and to isolate operations made by different users from each other. There are 4 levels of transaction isolations, all have their pros and cons and work differently. In this article I tried to explain what transactions are and the differences between the 4 levels of isolation.';&lt;/script&gt;
&lt;script type="text/javascript"&gt;var dzone_style = '2';&lt;/script&gt;
&lt;script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"&gt;&lt;/script&gt;
&lt;p&gt;
Recently I have read very good explanation of transaction isolation levels in "&lt;a href="http://press.adam-bien.com/"&gt;Real World Java EE Patterns. Rethinking Best Practices.&lt;/a&gt;" by Adam Bien.
&lt;/p&gt;&lt;p&gt;
Transactions were introduced for two reasons. To make complex operations atomic (all or nothing) and to give possibility to concurrently use resources. Without transactions it is possible that two users (or more specifically actors, this can be some parts of the system, not necessarly live users) read/write the same resource simultaneously, and changes made by one of them are lost and overwriten by the other one.
&lt;/p&gt;
&lt;p&gt;Consider following example document:
&lt;pre&gt;
Cheesecake bottom
250g crunchy bisquits
100g butter

Cheesecake top
900g cottage cheese
250g mascarpone cheese
1 lemon
&lt;/pre&gt;
&lt;/p&gt;
&lt;p&gt;
Imagine one user gets the document and the other user also is getting the same document. Both users have the same data. Now both of them are editing it. One likes sweeter cake bottom, so adds "2 spoons of sugar" to the recipe, and writes changed recipe back to the database. In database now it looks like this:
&lt;pre&gt;
Cheesecake bottom
250g crunchy bisquits
100g butter
&lt;span style="color: green;"&gt;2 spoons of sugar&lt;/span&gt;

Cheesecake top
900g cottage cheese
250g mascarpone cheese
1 lemon
&lt;/pre&gt;
&lt;/p&gt;&lt;p&gt;

Meanwhile second user adds "2 eggs" to cheescake top recipe and saves his version:
&lt;pre&gt;
Cheesecake bottom
250g crunchy bisquits
100g butter
&lt;span style="color: gray; text-decoration: line-through;"&gt;2 spoons of sugar&lt;/span&gt;

Cheesecake top
900g cottage cheese
250g mascarpone cheese
1 lemon
&lt;span style="color: green;"&gt;2 eggs&lt;/span&gt;
&lt;/pre&gt;

Change made by the first user is lost. In some cases it can lead to inconsistent data.
&lt;/p&gt;&lt;p&gt;
So that's why transactions were introduced. Transaction isolates changes made by one user from changes made by the other. There are 4 levels of transaction isolation.
&lt;/p&gt;
&lt;p&gt;
&lt;h4&gt;Serializable&lt;/h4&gt;
Transaction locks all necessary resources. If user wants to read or write some resource, it is locked and no one else can read or write it. This level of isolation can easly lead to deadlocks:
&lt;ol&gt;
&lt;li&gt;
User Ann opens transaction. Ann needs resource A, transaction locks it.
&lt;/li&gt;&lt;li&gt;
User John opens another transaction. John needs resource B, transaction locks it.
&lt;/li&gt;&lt;li&gt;
Ann needs resource B, but it is locked, so Ann's transaction needs to wait until it is released
&lt;/li&gt;&lt;li&gt;
John needs resource A, but it is locked. John's transaction waits until it is released. Both users wait endlessly.
&lt;/li&gt;
&lt;/ol&gt;
&lt;/p&gt;&lt;p&gt;
If John didn't need A, he finishes his transaction, B is released and Ann can finish her transaction too.
&lt;/p&gt;&lt;p&gt;
&lt;h4&gt;Repeatable reads&lt;/h4&gt;
Guarantees that the same query will return the same results if executed in one transaction. Even if other transaction modifies resource meanwhile. Exception is adding - new rows can appear in query result. If another transaction deletes existing rows or modifies them, this changes are not visible.
&lt;ol&gt;&lt;li&gt;
Ann opens transaction. She reads names of java4people organizers: "Stawicki" and "Gruchała".
&lt;/li&gt;&lt;li&gt;
Bob opens transaction and deletes "Stawicki". Bob commits changes and closes transaction.
&lt;/li&gt;&lt;li&gt;
Again Ann reads names. She gets "Stawicki" and "Gruchała".
&lt;/li&gt;&lt;/ol&gt;
&lt;/p&gt;&lt;p&gt;
If Bob added some name, Ann would read it too.
&lt;/p&gt;&lt;p&gt;
&lt;h4&gt;Read commited&lt;/h4&gt;
The same query can return different result even in one transaction if another transaction makes changes and commits them.
&lt;ol&gt;&lt;li&gt;
Ann opens transaction and reads names of java4people organizers: "Stawicki" and "Gruchała".
&lt;/li&gt;&lt;li&gt;
Bob opens transaction and deletes "Stawicki".
&lt;/li&gt;&lt;li&gt;
Ann reads names again. She gets "Stawicki" and "Gruchała".
&lt;/li&gt;&lt;li&gt;
Bob commits his transaction
&lt;/li&gt;&lt;li&gt;
Ann reads names again (still in one transaction). She gets "Gruchała".
&lt;/li&gt;&lt;/ol&gt;
&lt;/p&gt;&lt;p&gt;
&lt;h4&gt;Read uncommited&lt;/h4&gt;
Like no transactions at all. It only gives us atomic operations. User can rollback all the changes in transaction. Changes are visible to other transactions even before commit. Of course, if transaction that made changes is rolled back, changes are not visible any more.
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-2603365714764060619?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/PMaC359Cy_pfPmzv-tgV9W7gzp0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/PMaC359Cy_pfPmzv-tgV9W7gzp0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/PMaC359Cy_pfPmzv-tgV9W7gzp0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/PMaC359Cy_pfPmzv-tgV9W7gzp0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/pU7u0zUBBpQ" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2010/05/transaction-isolation-level.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-2274192340944233254</guid><pubDate>Sat, 15 May 2010 10:02:00 +0000</pubDate><atom:updated>2010-05-16T01:07:27.493+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">geecon</category><title>After GeeCON 2010</title><description>&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;
&lt;p&gt;
This year &lt;a href="http://2010.geecon.org/main/home"&gt;GeeCON&lt;/a&gt; took place in Poznań which is much closer to Szczecin than Cracow. I expected it to be as good as a year before, maybe I expected too much. I don't mean it was bad, but previous year it was so great that maybe it was hard to keep this level. Or maybe I was not choosing right presentations. There were three tracks this year so choice was sometimes difficult.
&lt;/p&gt;&lt;p&gt;
Like a previous year there was "University Day" before the conference. University Day is day of workshops on various topics. I have chosen Gradle, like many other people. Too many unfortunately. &lt;a href="http://2010.geecon.org/speakerdetails/30"&gt;Hans&lt;/a&gt; said there are too many attendants to make exercises for everyone, so only he coded live. I missed coding myself.
&lt;/p&gt;&lt;p&gt;
First interesting concept I heard about was &lt;a href="http://www.objectteams.org/index.html"&gt;Object Teams&lt;/a&gt;. It is a new idea of modularizing our programs, based on entities, collaborations and roles. All three look pretty much like java classes. In OOP there are objects which are data and methods. We can use objects to modularize our applications, but often connections between modules are becoming complicated. Creators of Object Teams concluded that modularization and OOP is not about modules/objects itself but about connections between them. So there are &lt;b&gt;entities&lt;/b&gt;, which represent data. There are &lt;b&gt;collaborations&lt;/b&gt;, that represent operations on data, and &lt;b&gt;roles&lt;/b&gt;. In a collaboration, each entity plays some role. Everything looks pretty and neat, and I wonder if it is going to become popular in coming years. I must admit I haven't heard about it before.
&lt;/p&gt;&lt;p&gt;
Quite interesting presentation was about &lt;a href="http://java.sun.com/javaee/javaserverfaces/"&gt;JSF 2.0&lt;/a&gt; by &lt;a href="http://2010.geecon.org/speakerdetails/1"&gt;Ed Burns&lt;/a&gt;. Nothing quite new for me, but if someone thinks JSF didn't change much since 1.2 version he should attend this presentation (or watch on &lt;a href="http://parleys.com/#id=51713&amp;amp;st=4"&gt;GeeCON's channel on parleys.com&lt;/a&gt; when it becomes available ;)). Guys who created version 2.0 addressed all the problems developers were complaining about with previous versions. I remember Seam was framework which was built on JSF and addressed such problems. Now, when it is solved in JSF itself, I wonder what are differences between Seam and JSF 2.0.
&lt;/p&gt;&lt;p&gt;
On the second day &lt;a href="http://2010.geecon.org/speakerdetails/5"&gt;Jonas Bonér&lt;/a&gt; was talking about actors, agents, STM and other solutions making concurrent programming much easier than threads with shared state and locks. Next time I'll need to do some concurrent programming in Java I'll definitely use something from Akka.
&lt;/p&gt;&lt;p&gt;
&lt;a href="http://2010.geecon.org/speakerdetails/18"&gt;Vaclav Pech&lt;/a&gt;'s presentation was quite similar. He also talked about concurrent programming with actors, but in Groovy. As usual Vaclav gave very good presentation.
&lt;/p&gt;&lt;p&gt;
&lt;a href="http://vaadin.com/home"&gt;Vaadin&lt;/a&gt; is the next thing I want to use. At work I use &lt;a href="http://code.google.com/webtoolkit/"&gt;GWT&lt;/a&gt; and I don't really like it. GWT compilation is very long and asynchronous callbacks are making code more complicated. Besides most of work is done on the server anyway. Programming in Vaadin is very similar to programming in GWT, but everything is server side. Vaadin uses GWT for presentation, so it is possible to write custom components for Vaadin in GWT, but then compilation is needed only once. Damn, this could save many hours of my life.
&lt;/p&gt;&lt;p&gt;
&lt;a href="http://2010.geecon.org/speakerdetails/3"&gt;Bruno Bossola&lt;/a&gt;'s presentation was very good and funny. No suprise here :) Bruno talks about things that many developers really need. I agree somewhere we lost real &lt;b&gt;Object Oriented&lt;/b&gt; programming. Bruno also mentioned a book which I feel is unfairly forgotten. "&lt;a href="http://www.amazon.com/Applying-UML-Patterns-Introduction-Object-Oriented/dp/0131489062/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1273964626&amp;amp;sr=8-1"&gt;Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development&lt;/a&gt;" by Craig Larman. When I started working for &lt;a href="http://www.ncdc.pl/"&gt;NCDC&lt;/a&gt; more than few years ago, my boss put this book to company's library and recommended it to us. I read it and I feel it made me a better developer. If you put all your code into one huge class or even method, buy or borrow this book and read it. Even if it's old it's worth it. Some things don't change even in IT ;)
&lt;/p&gt;&lt;p&gt;
If I can have some hint for the organizers I'd like to suggest to make presentations longer. Many presenters didn't manage to show everything they wanted. I think 1.5 hour is minimum.
&lt;/p&gt;&lt;p&gt;
I heard food was also a problem on the first day. It didn't suffice for everybody, but I managed to grab my plate so I don't complain :)&lt;/p&gt;
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-2274192340944233254?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/HvzDXfAJZo14-pMv6EztdDP9P8Q/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/HvzDXfAJZo14-pMv6EztdDP9P8Q/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/HvzDXfAJZo14-pMv6EztdDP9P8Q/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/HvzDXfAJZo14-pMv6EztdDP9P8Q/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/ZBCIb_Cb2ok" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2010/05/after-geecon-2010.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-8661191915202254690</guid><pubDate>Fri, 23 Apr 2010 22:20:00 +0000</pubDate><atom:updated>2010-04-24T22:15:28.302+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">filus</category><category domain="http://www.blogger.com/atom/ns#">testng</category><category domain="http://www.blogger.com/atom/ns#">szjug</category><category domain="http://www.blogger.com/atom/ns#">filip pająk</category><title>SzJUG member, Filip "Filus" Pająk presentation on TestNG</title><description>&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;p&gt;
Recently (last Thursday) I had pleasure to attend &lt;a href="http://szczecin.jug.pl"&gt;Szczecin JUG&lt;/a&gt; meeting at which Filip presented TestNG. Presentation was great. I knew &lt;a href="http://pacykarz.blogspot.com"&gt;Filip&lt;/a&gt; is a perfectionist, and when he does something it is just perfect :), but I didn't know he has such great speaker talent! I felt he really cares about being understood.
&lt;/p&gt;&lt;p&gt;
Filip was very well prepared. A lot of knowledge and a lot of great examples. Examples were prepared before and were short and simple. Just what you need to understand some issue, no less and no more. I think it is better than coding "live" when something can blow up. Show example, run it and show results.
&lt;/p&gt;&lt;p&gt;
Filip claimed he is no "guru" and doesn't know TestNG very well, but as far as I remember, he knew answer to every question :). I hope it was not his last presentation at Szczecin JUG. Or maybe he'll present somewhere else now? Who knows?
&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-8661191915202254690?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/XrjAHVgv-1RoCPxAcqO9qte8rss/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XrjAHVgv-1RoCPxAcqO9qte8rss/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/XrjAHVgv-1RoCPxAcqO9qte8rss/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XrjAHVgv-1RoCPxAcqO9qte8rss/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/jpvdLdyvjFQ" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2010/04/szjug-member-filip-filus-pajak.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-2956116161350035335</guid><pubDate>Sat, 17 Apr 2010 17:42:00 +0000</pubDate><atom:updated>2010-04-17T20:12:03.739+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">testng</category><category domain="http://www.blogger.com/atom/ns#">szjug</category><category domain="http://www.blogger.com/atom/ns#">test</category><title>Szczecin JUG Meeting. Filip "Filus" Pająk on TestNG.</title><description>&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;
&lt;p&gt;
On 22nd of April 2010 &lt;a href="http://pacykarz.blogspot.com/"&gt;Filip "Filus" Pająk&lt;/a&gt; will present &lt;a href="http://testng.org/"&gt;TestNG&lt;/a&gt;. If you are around Szczecin, feel invited. It's free :)
&lt;/p&gt;
&lt;p&gt;
Filus is experienced Java programmer and tester. When he does something, you can be sure it's going to be good. I think he'll make great presentation.
&lt;/p&gt;
&lt;p&gt;
I am very glad &lt;a href="http://szczecin.jug.pl/"&gt;Szczecin JUG&lt;/a&gt; is organising another meeting. It's been some time since the last one.
&lt;/p&gt;
&lt;p&gt;
Maybe I should also present something? JavaFX? Scala?
&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-2956116161350035335?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/3ULDF85GfI5L91fhk0ne8ob0Vdg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3ULDF85GfI5L91fhk0ne8ob0Vdg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/3ULDF85GfI5L91fhk0ne8ob0Vdg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3ULDF85GfI5L91fhk0ne8ob0Vdg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/cDA--Ohzc_g" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2010/04/szczecin-jug-meeting-filip-filus-pajak.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-1760198835299773801</guid><pubDate>Mon, 22 Mar 2010 21:13:00 +0000</pubDate><atom:updated>2010-03-22T23:45:20.218+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">javascript</category><category domain="http://www.blogger.com/atom/ns#">training</category><title>JavaScript training</title><description>&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;
&lt;p&gt;
This weekend I was able to take part in JavaScript training by &lt;a href="http://ferrante.pl/"&gt;Damian Wielgosik&lt;/a&gt; . As I was not very experienced JavaScript developer, I have learned a lot. I also got convinced that in JavaScript everything is possible :)
&lt;/p&gt;&lt;p&gt;
I am impressed by the trainer. I was quite surprised when I found out that it was the third training he conducted. I thought he is much more experienced. He had great "contact with the audience", atmosphere was very friendly, nobody was afraid to ask questions or discuss. Thank you Damian!
&lt;/p&gt;&lt;p&gt;
Two days full of training is quite a much time, so there was also place for exercises. This was very good, nothing consolidates knowledge like some exercises and because Damian was always there to help if we were stuck, we were not wasting time. Doing exercises in groups was also very good idea. We worked as a team and helped each other. I never doubted in efficiency of pair programming :)
&lt;/p&gt;&lt;p&gt;
Scope of topics was impressive. I learned a lot about prototypes and constructors, which was a bit strange for Java programmer (but not so much if he was also learning Ruby ;)) I think we covered pretty much everything in JS, from basics (which we run through quite fast) to optimization.
&lt;/p&gt;&lt;p&gt;
I would also like to thank other participants for great atmosphere, discussions, questions, help and info about "pierogarnia" :)
I wish I could attend more such good trainings.
&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-1760198835299773801?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/gNfhob1ApUhnJ3Sh8LMIZlHOCF8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gNfhob1ApUhnJ3Sh8LMIZlHOCF8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/gNfhob1ApUhnJ3Sh8LMIZlHOCF8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gNfhob1ApUhnJ3Sh8LMIZlHOCF8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/pn8BExo738A" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2010/03/javascript-training.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-4013323705206492487</guid><pubDate>Fri, 19 Mar 2010 22:28:00 +0000</pubDate><atom:updated>2010-06-09T22:22:33.276+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">review</category><category domain="http://www.blogger.com/atom/ns#">scala</category><title>Review: Programming Scala, by Venkat Subramaniam</title><description>&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;p&gt;&lt;a imageanchor="1" target="_blank"  href="http://www.amazon.com/Programming-Scala-Multi-Core-Complexity-Programmers/dp/193435631X?ie=UTF8&amp;tag=pawelsblog-20&amp;link_code=bil&amp;camp=213689&amp;creative=392969"&gt;&lt;img alt="Programming Scala: Tackle Multi-Core Complexity on the Java Virtual Machine (Pragmatic Programmers)" src="http://ws.amazon.com/widgets/q?MarketPlace=US&amp;ServiceVersion=20070822&amp;ID=AsinImage&amp;WS=1&amp;Format=_SL160_&amp;ASIN=193435631X&amp;tag=pawelsblog-20" style="float: left; margin: 10px;" /&gt;&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=pawelsblog-20&amp;l=bil&amp;camp=213689&amp;creative=392969&amp;o=1&amp;a=193435631X" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important; padding: 0px !important" /&gt;Courtesy of &lt;a href="http://pragprog.com/"&gt;The Pragmatic Bookshelf&lt;/a&gt; I was able to read "Programming Scala" by Venkat Subramaniam. If you are a Java programmer, this book is a great introduction to Scala for you. It is packed with knowledge. There was not even one chapter after reading which I could say "well, this was quite obvious, I could expect this". Book is targeted for experienced Java programmers, so author does not cover things we already know. This was great for me, my time was not wasted learning what I don't need. Instead, I was led from easier topics in Scala (like classes, typing, closures) to more difficult ones (pattern matching, actors and concurrency) at a nice pace.  Most topics are explained quite clearly and understandable. There are few which I had difficulties understanding and I needed to fiddle with some code to get it. But fiddling with code is fun for programmer, isn't it? One of such topics were actors, which is a great feature in Scala and something completely new for Java programmer (unless he knows Erlang too ;)). It took me some time with IDE to understand actors, but it was also fun. &lt;/p&gt;&lt;p&gt;The book not only teaches how to program in Scala, but also shows tools to run these programs. Knowing that Scala doesn't necessarly need to be compiled to run and that it can be run as a script can be very useful if you need to do some simple job on your system. Author shows how to use it as a scripting language. I also liked the last chapter in which author creates Scala application using various features covered in the book. It was a good way to sum up. &lt;/p&gt;&lt;p&gt;The only weak point of this book are examples. Especially at the end of the book they become more and more difficult and not always clearly explained. Another disadvantage of examples is their little connection with reality. Have you ever need to count letters in blog URL? In some cases they even show bad practice like throwing general Exception. I know it's only example, but educational book should not promote bad practice even there. &lt;/p&gt;&lt;p&gt;Said all this, I would recommend this book to every Java programmer who wants to learn Scala. If you are not afraid to fiddle a little with code (and you should not be, you are a programmer after all;) ) it is a very good book for you and you are it's perfect target. &lt;/p&gt;&lt;p&gt;Last but not least, not only author, but also editors deserve praise. I have PDF edition and I can login on &lt;a href="http://pragprog.com/"&gt;pragprog.com&lt;/a&gt; page anytime and download it. I don't have to worry that if I loose it - it's lost for good. Moreover there are .mobi and .epub formats available. I could read the book on my phone on a bus or a tram which was very convenient. And there is even more - the books are DRM free, which shows publishers not only care for readers comfort, but also trust us. I appreciate that. &lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-4013323705206492487?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ja_O2dFlwMu0DZW06JsdSuHyCdw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ja_O2dFlwMu0DZW06JsdSuHyCdw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ja_O2dFlwMu0DZW06JsdSuHyCdw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ja_O2dFlwMu0DZW06JsdSuHyCdw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/W9sKOd0dco0" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2010/03/review-programming-scala-by-venkat.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-1369195693808479561</guid><pubDate>Tue, 02 Mar 2010 22:42:00 +0000</pubDate><atom:updated>2011-02-03T16:48:11.754+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">jsf2</category><category domain="http://www.blogger.com/atom/ns#">ajax</category><category domain="http://www.blogger.com/atom/ns#">jsf</category><title>Simple AJAX with JSF 2.0</title><description>&lt;div style="font-family:verdana;"&gt;&lt;p&gt;In JSF 2.0, there are tags added to make AJAX calls easy. Without further ado: &lt;/p&gt;&lt;pre class="brush: xml"&gt;&amp;lt;?xml version='1.0' encoding='UTF-8' ?&amp;gt;
&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;
&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core"&amp;gt;
&amp;lt;h:head&amp;gt;
   &amp;lt;h:outputScript name="jsf.js" library="javax.faces" target="body"&amp;gt;&amp;lt;/h:outputScript&amp;gt;
   &amp;lt;title&amp;gt;Ajax&amp;lt;/title&amp;gt;
&amp;lt;/h:head&amp;gt;
&amp;lt;h:body&amp;gt;
   &amp;lt;f:view contentType="text/html; charset=UTF-8"&amp;gt;
       &amp;lt;h1&amp;gt;Hello Ajax World!&amp;lt;/h1&amp;gt;
       &amp;lt;h:form id="form"&amp;gt;
           &amp;lt;h:inputText id="name" value="#{nameMBean.name}"/&amp;gt;

           &amp;lt;h:commandButton value="Reverse name via Ajax!"&amp;gt;
               &amp;lt;f:ajax execute="name" render="reverseName"/&amp;gt;
           &amp;lt;/h:commandButton&amp;gt;
           &amp;lt;h:outputText id="reverseName" value="#{nameMBean.reverseName}"/&amp;gt;
       &amp;lt;/h:form&amp;gt;
   &amp;lt;/f:view&amp;gt;
&amp;lt;/h:body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;&lt;p&gt;First things first. To use AJAX in JSF 2.0, we have to attach &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;jsf.js&lt;/span&gt; file (line 8). Then we are ready. &lt;/p&gt;&lt;p&gt;Most interesting is line 18. &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&amp;lt;f:ajax&amp;gt;&lt;/span&gt; added to command button makes AJAX action fire when button is pressed. We could as well put it into &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&amp;lt;h:inputText&amp;gt;&lt;/span&gt; element, then it would fire on change of text inside (onchange event). &lt;/p&gt;&lt;p&gt;Parameter &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;execute&lt;/span&gt; tells JSF which parts it should send to server for model update. This could be also &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;form&lt;/span&gt;, for all the parameters in the form, or list of element ids separated by space. Parameter &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;render&lt;/span&gt; denotes which parts of view should be rerendered after receiving AJAX response. Here we can also put more than one. &lt;/p&gt;&lt;p&gt;We can put more parameters to &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&amp;lt;f:ajax&amp;gt;&lt;/span&gt;, like &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;event&lt;/span&gt;, where we can specify on which event AJAX action should occur (not necessarly &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;click&lt;/span&gt; event), or &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;listener&lt;/span&gt;, where we can call some method on managed bean. &lt;/p&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-1369195693808479561?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/sE7vgWGE20ey9NjQxV4c8il3mVM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sE7vgWGE20ey9NjQxV4c8il3mVM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/sE7vgWGE20ey9NjQxV4c8il3mVM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sE7vgWGE20ey9NjQxV4c8il3mVM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/_7pBV_kndIc" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2010/03/simple-ajax-with-jsf-20.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-1458369886042972369</guid><pubDate>Thu, 11 Feb 2010 21:22:00 +0000</pubDate><atom:updated>2010-02-11T23:59:37.859+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">make ubuntu faster</category><category domain="http://www.blogger.com/atom/ns#">ubuntu</category><title>Make Ubuntu faster</title><description>&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;
&lt;p&gt;
There are few very simple methods to make Ubuntu faster. Some of them work not only on Ubuntu, but on other linux systems as well.
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;Change dynamic linking to static one&lt;/b&gt;
&lt;/p&gt;
&lt;p&gt;
When compiler generates binary file, elements which should connect with external libraries are only stubs. When running application for the first time (in a session), it is dynamically linked, which means stubs are replaced with real calls to libraries. This process takes some time. Open Office on my machine runs about 5 seconds for the first time, and 1-2 seconds every next time.
&lt;/p&gt;
&lt;p&gt;
Fortunately there is a program called &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;prelink&lt;/span&gt;, accessible from Ubuntu repositories.
&lt;/p&gt;
&lt;pre class="brush: bash"&gt;
sudo apt-get install prelink
sudo prelink -amR
&lt;/pre&gt;
&lt;p&gt;
After the second command &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;prelink&lt;/span&gt; scans binaries specified in &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;/etc/prelink.conf&lt;/span&gt; and modifies them replacing dynamic calls with static ones, but in binary files, so this change is permanent. Disadvantage of this solution is that after every update of processed program we need to run &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;prelink&lt;/span&gt; again.
&lt;/p&gt;
&lt;p&gt;
We can always go back to dynamic linking (undo &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;prelink&lt;/span&gt;):
&lt;/p&gt;
&lt;pre class="brush: bash"&gt;
sudo prelink -au
&lt;/pre&gt;
&lt;p&gt;
You HAVE TO go back to dynamic linking if you want to remove &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;prelink&lt;/span&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;Get now what I'll need in a few miliseconds&lt;/b&gt;
&lt;/p&gt;
&lt;p&gt;
Next useful program fastening Ubuntu is &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;preloader&lt;/span&gt;. It uses magic (complicated algorithms) to predict what data is going to be necessary next and loads it before application asks.
&lt;/p&gt;
&lt;p&gt;
You only need to install it:
&lt;/p&gt;
&lt;pre class="brush: bash"&gt;
sudo apt-get install preload
&lt;/pre&gt;
&lt;p&gt;
It should run automatically, but if for some reason it is not running:
&lt;/p&gt;
&lt;pre class="brush: bash"&gt;
sudo /etc/init.d/preload start
&lt;/pre&gt;
&lt;p&gt;
&lt;a href="http://koziolekweb.pl/"&gt;Koziołek&lt;/a&gt; says it consumes a lot of RAM, but I didn't notice :)
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;Run services in paralell&lt;/b&gt;
&lt;/p&gt;
&lt;p&gt;
If you have more than one core, you can set your system to start services in paralell during startup. This is potentially dangerous, as there might be services which depend on each other.
&lt;/p&gt;
&lt;p&gt;
Edit &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;/etc/init.d/rc&lt;/span&gt; and find line &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;CONCURRENCY=none&lt;/span&gt;. Change it to &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;CONCURRENCY=startpar&lt;/span&gt;.
&lt;/p&gt;
&lt;p&gt;
This post is here courtesy of Bartłomiej "Koziołek" Kuczyński, and is translation of &lt;a href="http://koziolekweb.pl/2010/01/30/robienie-sobie-szybkiego-ubuntu/"&gt;his post in Polish&lt;/a&gt;.
&lt;/p&gt;
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-1458369886042972369?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Ttk5aofhA58j3O1hrohP9mCEdv0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ttk5aofhA58j3O1hrohP9mCEdv0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Ttk5aofhA58j3O1hrohP9mCEdv0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ttk5aofhA58j3O1hrohP9mCEdv0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/TWahvdS5QQ8" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2010/02/make-ubuntu-faster.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-6862720425376520372</guid><pubDate>Tue, 12 Jan 2010 09:35:00 +0000</pubDate><atom:updated>2010-02-20T21:14:24.781+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">partial mocks</category><category domain="http://www.blogger.com/atom/ns#">mockito</category><title>Partial mocks in Mockito - Mock only what you need, left the rest to the original class</title><description>&lt;div style="font-family:verdana;"&gt;
&lt;div&gt;
In &lt;a href="http://mockito.org/"&gt;Mockito&lt;/a&gt; you can not only create "regular" mocks, but also partial mocks. Let's assume we need to use instance of class &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;A&lt;/span&gt;, and we want to mock it. We can do mock:
&lt;pre class="brush: java"&gt;
A aMock = Mockito.mock(A.class);
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
Sometimes, we want to use instance of real class &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;A&lt;/span&gt;, but mock only part of it. Only one or few methods. With Mockito it is possible:
&lt;pre class="brush: java"&gt;
A a = Mockito.spy(new A());
&lt;/pre&gt;
So we spy real object, we can verify it's method calls, but we can also do that:
&lt;pre class="brush: java"&gt;
Mockito.when(a.methodCall()).thenReturn(1);
&lt;/pre&gt;
We can mock some of &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;A&lt;/span&gt;'s methods, leaving the rest to the real &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;A&lt;/span&gt; instance.
&lt;/div&gt;
&lt;div&gt;
For me it was useful while I was creating test involving user. &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;User&lt;/span&gt; object's have ID, but there is only getter for it. ID is always set by database, and should never been changed by programmers, so there is only getter. Thanks to partial mocks, I mocked only &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;getId()&lt;/span&gt; method, without need to add &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;setId()&lt;/span&gt; just for testing purposes.
&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-6862720425376520372?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/tgCTngobvoQW009_9CwLpV_Gl54/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tgCTngobvoQW009_9CwLpV_Gl54/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/tgCTngobvoQW009_9CwLpV_Gl54/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tgCTngobvoQW009_9CwLpV_Gl54/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/SFiQe349rMc" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2010/01/partial-mocks-in-mockito-mock-only-what.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-5391931310071441904</guid><pubDate>Sun, 13 Dec 2009 23:32:00 +0000</pubDate><atom:updated>2009-12-15T18:49:35.074+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">couchdb</category><title>CouchDB</title><description>&lt;div style="font-family:verdana;"&gt;
&lt;p&gt;
&lt;a href="http://couchdb.apache.org/"&gt;CouchDB&lt;/a&gt; is a new kind of database. It's not a relational database, it's not
objective database. CouchDB just stores documents. A document is something like
java map, it has keys and values. Values can be strings, numbers, dates, lists,
maps, also binary attachments. Documents are accessible by pure http,
REST service, in JSON format. CouchDB is written in Erlang, so it is well
scalable for many processors/cores. (At least this is what it's authors claim ;))
Let's give it a try.
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-weight: bold;"&gt;Installation&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
On ubuntu issue:
&lt;/p&gt;
&lt;pre class="brush:bash"&gt;apt-get install couchdb&lt;/pre&gt;
&lt;p&gt;
During installation, couchdb user was created. Now you can run
database as a background process:
&lt;/p&gt;
&lt;pre class="brush:bash"&gt;sudo -i -u couchdb couchdb -b&lt;/pre&gt;
&lt;p&gt;
Ok, fire up your favorite browser and open page
&lt;span style="font-family:'courier new';"&gt;http://localhost:5984/&lt;/span&gt;
You should see something like:
&lt;span style="font-family:'courier new';"&gt;
{"couchdb":"Welcome","version":"0.10.0"}
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Not very useful, is it? Try going to
&lt;span style="font-family:'courier new';"&gt;http://localhost:5984/_utils/&lt;/span&gt;
This is Futon, CouchDB admin tool. From here you can create new databases and
documents and manage them. 
&lt;/p&gt;
&lt;span style="font-weight: bold;"&gt;Simple operations by Futon&lt;/span&gt;
&lt;p&gt;
Create database
&lt;span style="font-family:'courier new';"&gt;tryme&lt;/span&gt; and some document. Field
&lt;span style="font-family:'courier new';"&gt;_id&lt;/span&gt; is generated automatically,
add two more fields:
&lt;/p&gt;
&lt;pre&gt;firstname: "Pawel"
surname: "Stawicki"
&lt;/pre&gt;
&lt;p&gt;
Click "Save document". You can see that field
&lt;span style="font-family:'courier new';"&gt;_rev&lt;/span&gt; was added automatically.
Every change of every document is remembered, and you can always
get the old version.
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-weight: bold;"&gt;Protection&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
So there is one document in the database, let's protect it.
Go to &lt;span style="font-family:'courier new';"&gt;/etc/couchdb/local.ini&lt;/span&gt;
and edit &lt;span style="font-family:'courier new';"&gt;[admins]&lt;/span&gt; section. Add:
&lt;/p&gt;
&lt;pre&gt;admin = &amp;lt;admin_password&amp;gt;&lt;/pre&gt;
&lt;p&gt;
Password will be automatically hashed after run.
&lt;/p&gt;
&lt;p&gt;
If you want to enable access from any machine, change
&lt;span style="font-family:'courier new';"&gt;bind_address&lt;/span&gt; from
&lt;span style="font-family:'courier new';"&gt;127.0.0.1&lt;/span&gt; to
&lt;span style="font-family: 'courier new';"&gt;0.0.0.0&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-weight: bold;"&gt;Operations by RESTful HTTP interface&lt;/span&gt;
&lt;/p&gt;
        &lt;p&gt;
CouchDB can be accessed by RESTful http interface. Curl is one nice tool for it,
so install it if you don't have it already on your system:
        &lt;/p&gt;
&lt;pre class="brush:bash"&gt;sudo apt-get curl&lt;/pre&gt;
&lt;p&gt;
Now issue:
&lt;/p&gt;
&lt;pre class="brush:bash"&gt;curl http://localhost:5984&lt;/pre&gt;
&lt;p&gt;
You should see known welcome message. Try
&lt;/p&gt;
&lt;pre class="brush:bash"&gt;curl http://localhost:5984/tryme&lt;/pre&gt;
&lt;p&gt;
and some data about &lt;span style="font-family:'courier new';"&gt;tryme&lt;/span&gt;
database should appear. We can also list all existing databases:
&lt;/p&gt;
&lt;pre class="brush:bash"&gt;curl http://localhost:5984/_all_dbs&lt;/pre&gt;
        &lt;p&gt;
Ok, all this stuff above you can do by the browser. But you can also
create documents and databases in CouchDB by REST interface. Try this:
        &lt;/p&gt;
&lt;pre class="brush:bash"&gt;
curl -X PUT http://localhost:5984/tryme/1 -d '{ "firstname": "Leszek", "surname": "Gruchała" }'
&lt;/pre&gt;
        &lt;p&gt;
You just created a new document. In curly braces is document in JSON format.
It's id however is not long stream of characters, but just "1".
Much more predictable and repeatable.
&lt;a href="http://en.wikipedia.org/wiki/Uuid"&gt;UUIDs&lt;/a&gt; are generally better.
CouchDB can generate one for you:
        &lt;/p&gt;
&lt;pre class="brush:bash"&gt;curl http://leonidas:5984/_uuids&lt;/pre&gt;

It generates one id. If you need more, you can pass "count" parameter:

&lt;pre class="brush:bash"&gt;curl http://leonidas:5984/_uuids?count=3&lt;/pre&gt;
        &lt;p&gt;
So we've seen that CouchDB uses JSON as documents format, and we can do
operations by HTTP. However, from now on, I'll be using Futon because it is
just easier. Futon is CouchDB administration tool
(&lt;a href="http://localhost:5984/_utils"&gt;http://localhost:5984/_utils&lt;/a&gt;).
        &lt;/p&gt;
&lt;p&gt;
&lt;span style="font-weight: bold;"&gt;Creating view by map/reduce&lt;/span&gt;
&lt;/p&gt;
        &lt;p&gt;
JSON is JavaScript format, and it allows to put also functions into the
document. Map functions (from map/reduce) are useful to create
something similar to SQL view.
        &lt;/p&gt;
        &lt;p&gt;Let's add another document to our database,
with following fields:
        &lt;/p&gt;
        &lt;pre&gt;
firstname: "Leszek"
surname: "Kowalski"
&lt;/pre&gt;
        &lt;p&gt;
Now choose "Temporary view"
from selection box on the right. Here you can write map and reduce functions.
For view, map is enough, let's leave reduce empty for now. Create function:
        &lt;/p&gt;
&lt;pre class="brush:javascript"&gt;
function(doc) {
  if (doc.firstname == 'Leszek') {
    emit(doc.firstname, doc.surname);
  }
}
&lt;/pre&gt;
        &lt;p&gt;
It filters documents to those with firstname "Leszek" only.
        &lt;/p&gt;
        &lt;p&gt;
            So we can filter documents to only those which interest us.
What about joins? Can we get some document, and relevant documents data in one query?
It's also possible. Let's add addresses to those guys in database.
First, we need to distinguish documents related to persons from the ones
related to addresses. For that, add &lt;span style="font-family:'courier new';"&gt;type&lt;/span&gt; field to
each person, and as value enter "person". Now, we'll need their id's,
so copy/paste it somewhere.
        &lt;/p&gt;
        &lt;p&gt;
Create address as a new document, and add those fields:
        &lt;/p&gt;
&lt;pre&gt;
type: "address"
person_id: &amp;lt;id_of_person&amp;gt;
city: "New York"
&lt;/pre&gt;
        &lt;p&gt;
    The same for two remaining persons. Put some another city there.
    Ok, now our map function is a little more complicated:
        &lt;/p&gt;
&lt;pre class="brush:javascript"&gt;
function(doc) {
  if (doc.type == "person") {
    emit([doc._id, 0], doc);
  } else if (doc.type == "address") {
    emit([doc.person_id, 1], doc);
  }
}
&lt;/pre&gt;
        &lt;p&gt;
This way we have person always next to her address.
        &lt;/p&gt;
        &lt;p&gt;We learn another CouchDB
feature here - result of map is always sorted by key. In this case key is
2-element array, in which first element is the person id, and second one is 0
in case of person, 1 in case of her address. It's not like SQL join, we don't
get all the data in one document, but still it answers our needs - we have
person and it's address.
        &lt;/p&gt;
        &lt;p&gt;
If we are interested in specific person, we can add parameter to GET request.
But first we need to save our view in "desing document". Click "Save As..."
button, fill in design document name (e.g. "reader") and view name
(e.g. "person-address") and voila.
        &lt;/p&gt;
        &lt;p&gt;
Design documents are special documents in database for storing views. You can have
different design documents e.g. for readers and for writers or administrators.
In desing document you can set a lot of stuff telling CouchDB how to render it's
content (means how to change it into nice html). If you want to learn more about
design documents, look into
&lt;a href="http://books.couchdb.org/relax/"&gt;CouchDB book&lt;/a&gt;.
        &lt;/p&gt;
&lt;span style="font-weight: bold;"&gt;GET parameters for narrowing search&lt;/span&gt;
        &lt;p&gt;
Now when our view is saved, we can use GET request to get it's content, and set
parameters to limit what we get to person which we are interested in. Such URL:
&lt;span style="font-family:'courier new';"&gt;
http://localhost:5984/tryme/_design/reader/_view/person-address?startkey=["1",0]&amp;amp;endkey=["1",1]
&lt;/span&gt;
will return person with _id=1 and it's address documents.
&lt;/p&gt;
&lt;p&gt;
Another useful parameters are:
&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;span style="font-family:'courier new';"&gt;key&lt;/span&gt;
- for specific key (not range, like in case of startkey, endkey)&lt;/li&gt;
    &lt;li&gt;&lt;span style="font-family:'courier new';"&gt;descending=true&lt;/span&gt;
- by default view is ordered by ascending key, set this parameter to order it descending&lt;/li&gt;
    &lt;li&gt;&lt;span style="font-family:'courier new';"&gt;group_level&lt;/span&gt;
- sets reduce level. Default is 0.&lt;/li&gt;
    &lt;li&gt;&lt;span style="font-family:'courier new';"&gt;group=true&lt;/span&gt;
- behaves like &lt;span style="font-family:'courier new';"&gt;group_level&lt;/span&gt; set to maximum&lt;/li&gt;
    &lt;li&gt;&lt;span style="font-family:'courier new';"&gt;revs_info=true&lt;/span&gt;
- lists revisions of specified document. Applicable only to document selected by id, not to view&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
To understand &lt;span style="font-family:'courier new';"&gt;group_level&lt;/span&gt;,
we'll need reduce function. First, let's add some more parameters to our
persons. Let's add "position" and "salary":
&lt;/p&gt;
&lt;p&gt;
To one person add:
&lt;/p&gt;
&lt;pre&gt;
position: "manager"
salary: 5000
&lt;/pre&gt;
To second one:
&lt;pre&gt;
position: "developer"
salary: 3000
&lt;/pre&gt;
and to third one:
&lt;pre&gt;
position: "developer"
salary: 3500
&lt;/pre&gt;

Now create new view, with map and reduce functions:

&lt;pre class="brush:javascript"&gt;
//map:
function(doc) {
  emit([doc.position, doc._id], doc);
}

//reduce:
function(keys, values, rereduce) {
  var salaries = 0;
  for(i = 0; i &lt; values.length; i++) {
    salaries += values[i].salary;
  }
  return salaries;
}
&lt;/pre&gt;
&lt;p&gt;
    Save this view as "salaries". Now open URL
    &lt;span style="font-family:'courier new';"&gt;http://leonidas:5984/tryme/_design/bla/_view/salaries&lt;/span&gt;
    and output is:
&lt;/p&gt;
&lt;pre&gt;
    {"key":null,"value":11500}
&lt;/pre&gt;
&lt;p&gt;
    All values are grouped, and key is ignored.
&lt;/p&gt;
&lt;p&gt;
    Add parameter:
&lt;span style="font-family:'courier new';"&gt;
    http://leonidas:5984/tryme/_design/bla/_view/salaries?group_level=1
&lt;/span&gt; and it returns
&lt;/p&gt;
&lt;pre&gt;
{"key":["developer"],"value":6500},
{"key":["manager"],"value":5000}
&lt;/pre&gt;
&lt;p&gt;
    Values are grouped for first level of key (first element of key array).
&lt;/p&gt;
&lt;span style="font-family:'courier new';"&gt;group_level=2&lt;/span&gt; returns
&lt;pre&gt;
{"key":["developer","61fe9c6c226b978f74b76329191806b3"],"value":3000},
{"key":["developer","eb3873f48bb581df13762324b8ec0313"],"value":3500},
{"key":["manager","1"],"value":5000}
&lt;/pre&gt;
&lt;p&gt;
    Two elements of array are taken into account. In this case, it is the same like
    &lt;span style="font-family:'courier new';"&gt;group=true&lt;/span&gt;, which takes all
    elements of key array.
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-weight: bold;"&gt;What is rereduce for?&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
    As you noticed, reduce function has third parameter
    &lt;span style="font-family:'courier new';"&gt;rereduce&lt;/span&gt;

&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_zOPiqa0XBio/SyV5KGVKyxI/AAAAAAAAAMM/I09v6rsUVk0/s1600-h/btree-reducing.png"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 314px; height: 137px;" src="http://2.bp.blogspot.com/_zOPiqa0XBio/SyV5KGVKyxI/AAAAAAAAAMM/I09v6rsUVk0/s400/btree-reducing.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5414867341387942674" /&gt;&lt;/a&gt;



&lt;p&gt;
    Result of map function is kept as sorted B-tree.
Let's assume we want to summarize some value from each document (tree node).
Just like salaries.
&lt;/p&gt;
&lt;p&gt;
First, there are keys and whole nodes (because value of our map function is whole document)
passed to reduce function, and &lt;span style="font-family:'courier new';"&gt;rereduce&lt;/span&gt;
is set to &lt;span style="font-family:'courier new';"&gt;false&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Look at the picture, we can reduce branch of the tree
into 17, another branch into 4, and third one into 2. Assume each branch has
common key at specified group_level (e.g. all people from first branch are
developers, second are managers and third are administrators, if 
&lt;span style="font-family:'courier new';"&gt;group_level&lt;/span&gt; is set to 1).
&lt;/p&gt;
&lt;p&gt;
Then reduce function is called again, with following parameters:
&lt;/p&gt;
&lt;pre&gt;
function(["developer", "manager", "administrator"], [17, 4, 2], true);
&lt;/pre&gt;
&lt;p&gt;
There is common key for whole branch, reduced scalar value for that branch,
and &lt;span style="font-family:'courier new';"&gt;rereduce&lt;/span&gt; parameter set to
&lt;span style="font-family:'courier new';"&gt;true&lt;/span&gt;.
&lt;/p&gt;
&lt;p&gt;
Important thing here is to remember that not always
values are whole nodes, sometimes it can be already reduced values, and in such
case rereduce parameter is helpful to distinguish this situation. In fact, our
reduce function wouldn't work for big amount of nodes, because it handles only
nodes (only rereduce=false case), not reduced values. To work with a lot of data,
we should handle also scalar values:
&lt;/p&gt;
&lt;pre class="brush:javascript"&gt;
function(keys, values, rereduce) {
  if (rereduce) {
    return sum(values);
  } else {
    var salaries = 0;
    for(i = 0; i &amp;lt; values.length; i++) {
  }
}
&lt;/pre&gt;
&lt;p&gt;Now it should count and sum all the salaries.&lt;/p&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-5391931310071441904?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/onMIcP2s_W3oqe-Qdv31qF_lUik/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/onMIcP2s_W3oqe-Qdv31qF_lUik/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/onMIcP2s_W3oqe-Qdv31qF_lUik/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/onMIcP2s_W3oqe-Qdv31qF_lUik/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/64MfFLFHKVg" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2009/12/couchdb.html</link><author>noreply@blogger.com (pawelstawicki)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_zOPiqa0XBio/SyV5KGVKyxI/AAAAAAAAAMM/I09v6rsUVk0/s72-c/btree-reducing.png" height="72" width="72" /><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3646845225376270865.post-4141540825991970616</guid><pubDate>Wed, 18 Nov 2009 20:25:00 +0000</pubDate><atom:updated>2010-02-10T22:13:45.712+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">server</category><category domain="http://www.blogger.com/atom/ns#">mercurial</category><category domain="http://www.blogger.com/atom/ns#">hg-login</category><title>Mercurial installation and remote server interaction by hg-login</title><description>&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;div&gt;I want to have mercurial on my machine, but I also want to have "central repository" for continuous integration builds. I chosen &lt;a href="http://mercurial.selenic.com/"&gt;mercurial&lt;/a&gt; because it is fast (like git), and it has good support in &lt;a href="http://netbeans.org/"&gt;NetBeans&lt;/a&gt; (at least I heard it has ;)).&lt;/div&gt;
&lt;div&gt;To push/pull changes to/from server, I use &lt;a href="http://mercurial.selenic.com/wiki/HgLogin"&gt;hg-login&lt;/a&gt;. Ssh is also necessary. Ok, so here are the steps:&lt;/div&gt;
&lt;div&gt;1. Install mercurial on both client and server.
&lt;pre class="brush:bash"&gt;apt-get install mercurial&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;2. Create user mercurial on the server, and disable his shell.
&lt;pre class="brush:bash"&gt;sudo adduser mercurial&lt;/pre&gt; Edit /etc/shadow and set his password to "*".&lt;/div&gt;
&lt;div&gt;3. Go to server (ssh will suffice) and switch to user mercurial.
&lt;pre class="brush:bash"&gt;sudo su - mercurial&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;4. Go to /home/mercurial and create repositories directory.
&lt;pre class="brush:bash"&gt;cd /home/mercurial
mkdir repositories&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;5. Create file hg-login in /home/mercurial. Copy script there. Script can be found on &lt;a href="http://mercurial.selenic.com/wiki/HgLogin"&gt;http://mercurial.selenic.com/wiki/HgLogin&lt;/a&gt;
&lt;pre class="brush:bash"&gt;mcedit hg-login&lt;/pre&gt;It can be necessary to change the script. In my case I needed to change /usr/local/bin/hg to /usr/bin/hg. Change to where your hg command is located.&lt;/div&gt;
&lt;div&gt;6. Go back to client machine. Generate ssh keys pair for yourself.&lt;pre class="brush:bash"&gt;ssh-keygen&lt;/pre&gt;Add private key to your ssh agent.&lt;pre class="brush:bash"&gt;ssh-add&lt;/pre&gt; This way when you connect by ssh from client, you are automatically authenticated.&lt;/div&gt;
&lt;div&gt;7. Go to server again. In /home/mercurial/.ssh create file authorized_keys.&lt;pre class="brush:bash"&gt;cd /home/mercurial/.ssh
touch authorized_keys&lt;/pre&gt; In this file put line:&lt;pre&gt;command="/home/mercurial/hg-login franek",no-port-forwarding,no-X11-forwarding,no-agent-forwarding [key]&lt;/pre&gt;franek is user name. Replace [key] with content of your .ssh/id_rsa.pub file from client. Put whole content there (with ssh-rsa in the beginning and &amp;lt;user&amp;gt;@&amp;lt;host&amp;gt; at the end).&lt;/div&gt;
&lt;div&gt;8. Create repository in /home/mercurial/repositories/.&lt;pre class="brush:bash"&gt;cd /home/mercurial/repositories
mkdir myapplication
cd myapplication
hg init&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;9. Allow franek to access myapplication repository. In /home/mercurial/repositories create file myapplication.allow. In this file list users who has to have access to myapplication repository. In this case franek, so the file looks like this: &lt;pre&gt;franek
&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;10. On client machine, go to directory where your application is: cd &amp;lt;yourdir&amp;gt;/myapplication&lt;/div&gt;
&lt;div&gt;11. Create local mercurial repository.&lt;pre class="brush:bash"&gt;hg init&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;12. Add all what is in /myapplication directory to local repository.&lt;pre class="brush:bash"&gt;hg add&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;13. Commit added files.&lt;pre class="brush:bash"&gt;hg commit&lt;/pre&gt; You'll need to edit commit comment.&lt;/div&gt;
&lt;div&gt;14. Push changes to remote repository.&lt;pre class="brush:bash"&gt;hg push ssh://mercurial@yourserver/myapplication&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;While creating this recipe, &lt;a href="http://mercurial.selenic.com/wiki/HgLogin"&gt;hg-login&lt;/a&gt; site was very helpful.&lt;/div&gt;
&lt;div&gt;As I mentioned before, I chosen mercurial because of Netbeans. But I don't find Netbeans support of mercurial satisfactory. I am used to eclipse and it's great support for CVS. In eclipse, if there are some changes in CVS and I don't have them (incoming changes), I can see what has changed (file by file diff) before I update my code. I failed to do this in Netbeans with mercurial.
&lt;/div&gt;
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3646845225376270865-4141540825991970616?l=pawelstawicki.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/aTqoXv24pLi-c4RkAJ5ez6VYkpM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/aTqoXv24pLi-c4RkAJ5ez6VYkpM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/aTqoXv24pLi-c4RkAJ5ez6VYkpM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/aTqoXv24pLi-c4RkAJ5ez6VYkpM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaProgramowanieITakieTam/~4/rDRGpoVLANg" height="1" width="1"/&gt;</description><link>http://pawelstawicki.blogspot.com/2009/11/mercurial-installation-and-remote.html</link><author>noreply@blogger.com (pawelstawicki)</author><thr:total>1</thr:total></item></channel></rss>

