Holy on Dev

Archive for March, 2009

Seam Tutorial 1.2: RichFaces and paged table (datascroller)

Posted by Jakub Holý on March 23, 2009

In this two-part tutorial you will
learn how to get started with the development of Seam applications
with RichFaces using Eclipse with JBoss Tools. In the 1st
we’ve set up our environment, created, and run an empty shell
Seam application. In this 2nd part we will create a simple
web page with a table presenting data on multiple pages using Ajax (a
RichFaces component) and its model stored as a POJO Component in the
Seam Conversation scope. I assume that you already have some basic
knowledge of Seam and JSF, for instance that you know what a
Component or the Conversation scope are. I’ll present my path to this
goal with all the mistakes so that you too can learn from them.

My aim in this tutorial series is to
create a Seam portlet displaying data in a paged (and ideally also
sortable and filterable, but lets be realistic) table running in the
Liferay portal.

Read the rest of this entry »

Posted in Portlets | Tagged: , , , , , | 4 Comments »

The Forgotten Hells or God Save North Korea!

Posted by Jakub Holý on March 19, 2009

I intended this as an exclusively technological blog but after seeing the movie Yodok Stories yesterday I feel I can’t keep silent on the subject. I’m even more touched by the movie because the first years of my life I spent myself in a communist dictatorship though it was already in its last stage and can be by no means compared to the nightmare of Korea.

 On this planet there are hellish places where human life or dignity have no value, where people live in such a suffering, fear, and pain that we perhaps even can not call them human any more. These places are well hidden from our sight though as the recent Fritzl case has shown, it doesn’t need to be far away. I’d like to remind the world of two such places because pretending they do not exist only helps them to last longer. It’s very good that everybody speaks about the human rights violations in Tibet but there are countries that need our attention even more though they may not be as attractive and "in".

Democratic People’s Republic of Korea: The Hell on Earth

Simply known as North Korea, this country is a victim of likely the hardest totalitarian regime on the Earth. The inhabitants are cut off from the outside world and would only learn from the state media how great their fatherland, Party, and beloved General Kim Jong-il are. And I’d expect them to believe it because the propaganda is so strong and other voices inexistent that they’ve no way to resist it. And anyway they’ve enough trouble with trying to get something to eat (though today is far better than during the famine of 90’s that killed 2-3 million people).

On the bright side you can see mass parades demonstrating the people’s happiness and devotion to the country, Party, and the Eternal President and his son. On the dark side there are about 20* concentration camps. They are perhaps the most hellish places on the Earth. One of them you can leave if you are extremely lucky and live to the day, the others are till death. It’s estimated that maybe 100 or 200 000* people are imprisoned there, which is a higher number than the estimated size of North Korean elite of cca 150 000* (depends how you count). The Party is uncompromising in its fight against the internal enemy aiming at destroying the happy Republic and therefore if you commit a crime against the country, Party, or President/General, such as telling an unpleasant truth, trying to emigrate, or dishonoring the President, you will be sentenced to detention in a camp together with your children and parents. God be with you then (if there is any in North Korea at all).

In a camp you are not a human anymore and the only rights you have is the right to suffer and the right to die. You, your little child, and old parents are all class enemies. You will experience constant hunger, cold, health problems, torture, rape. You can trust nobody, nobody will help you, nobody cares about you. You’re a class enemy trying to destroy the north Korean communist paradise and therefore you deserve hell and you’ll get it.

* Of course any information about North Korea is uncertain because the regime tries to prevent the truth from coming out and certainly they’ve the means.

Democratic Republic of the Congo: Woman’s Nightmare

10 years of a civil war torture Congo, supported by battle forces from Rwanda, Zaire, Uganda,  Angola, Zimbabwe and Namibia taking the country for a place to exercise their influence and square accounts with one another.

The poor civilians of Congo are mere amusement for the rolling armies. It’s common for a woman to be kidnapped, hold as a sex slave and repeatedly raped until she dies or is perhaps released back to her home village where she’s often rejected and cast out by her husband, perhaps with all the children. Actually the term "woman" is misleading. Any female between birth and death is a potential subject to rape (and perhaps death as consequence), now and whenever another military force passes by, being Congolian or foreigner. An older woman was raped by a group of child soldiers that could have been her sons and grandsons. It’s a question whether those who die aren’t luckier. I’m a man (I must feel ashamed of that) and can hardly imagine the psychological trauma of a woman that has lived through such a terror and that she will carry till the death.


I’ve been neither to a North Korean concentration camp (thanks!!!) nor have I been a raped woman in Kongo and inevitably my information about this is very limited. But my knowledge of the world and of the truth of Nazi and Czech and Soviet concentration camps lead me to believe the worst. During World War II people in America or England were unwilling to believe the brutal truth of concentration camps and Holocaust and of course it’s always easy to deny the existence of something unpleasant (barely adequate term!). That’s why I cannot deny these things do happen.


Posted in General | 1 Comment »

When will we see JSR 286 in JSF portlets?

Posted by Jakub Holý on March 17, 2009

Since June 2008 we have the final release of Portlet 2.0 (JSR 286) specification bringing the long sought after features like inter-portlet communication (IPC – events, shared/public render parameters), support for Ajax (resource request), portlet filters and more. It’s already implemented in the latest versions of leading portals including Liferay 5.0, JBoss 2.7, Websphere 6.1 (though you can still encounter some bugs).

Now we would like to know when the lovers of JSF will be able to profit from these features in their JSF portlets.

Current state

Currently it’s possible to embed a JSF 1.2 application into a JSR 168 portal using a Portlet Bridge 1.0 (JSR 301). This is all still quite new – JSR 301 is only a proposed final draft as of June 8th 2009. So you can expect that it will take time to see also support for JSR 286 (or the upcoming JSF 2.0).

Note: Of course you can run JSF portlet bridge 1.0 applications in JSR 286 compliant portals but won’t have an easy access to the new features.


A specification of  Portlet Bridge 2.0 that would bring JSR 286 to the JSF world is being born but it’s still so young that it even hasn’t a JSR number yet. While creating the specification for Portlet Bridge 1.0 took 2-3 years we may hope that 2.0 could be faster as the foundation is already laid by 1.0 but still it will surely take at least half a year, much more likely a year or more. For the time being the only option is to take any of the open source implementations and try to hack the feature you need.

Update: The JSR for Portlet 2.0 Bridge for JSF 1.2 is #329 (thanks, balz).


MyFaces Portlet Bridge 2.0, a reference implementation of the new specification being formed, already has some alpha code. They’re quite ahead of time 🙂

According to some posts WebSphere Portal 6.1 implementation of portlet bridge seems to support JSR 286 though it is not yet perfect.

JBoss Portlet Bridge (now 1.0.0 beta 6) and Sun JSF Portlet Bridge (1.2.3, 8/2008) plan this perhaps in their 2.0 versions. We can also see that the authors of ICEFaces plan to incorporate this in v2.0 (currently 1.8.0RC1), but likely all of them depend on the specification coming to some stable state.

But a limited support is already available, for instance you can use public render parameters in JSF Portlet Bridge.


It will take at least months to have a JSR 286 enabled Portlet Bridge buth work is already under way.

Posted in Portlets | 5 Comments »

Seam Tutorial 1.1: RichFaces and paged table (datascroller)

Posted by Jakub Holý on March 7, 2009

In this two-part tutorial you will
learn how to get started with the development of Seam applications
with RichFaces using Eclipse with JBoss Tools. In the 2nd
we will create a simple page with a table presenting data on
multiple pages using Ajax and its model stored as a POJO Component in
the Seam Conversation scope. I assume that you already have some
basic knowledge of Seam and JSF, for instance that you know what a
Component or the Conversation scope are.

My aim in this tutorial series is to
create a Seam portlet displaying data in a paged (and ideally also
sortable and filterable, but let’s be realistic) table running in the
Liferay portal. The tutorial will follow my steps with all the dead ends and mistakes so that you too can learn from them.

Why Seam?

In my opinion, Seam is one of the best application frameworks for
Java web application development. It’s not the best one because none
is and it always depends on the task at hand what solution/tool is the most
suitable one. I like Seam because it integrates so well some of the most
popular and standard or de facto standard technologies (all of them
are optional in a Seam application) including JSF, EJB 3.0, JPA, and
Hibernate. Not only does it integrate them but also fixes their
shortcomings (especially in JSF) and adds invaluable features you’ve
been looking for for ages, like the conversation scope, eventing, or
runtime component injection.

Why RichFaces?

The answer is simple: go to see
the RichFaces demo
:-). RichFaces is a library of good-looking,
dynamic (Ajax) JSF components and support for ajaxifying just about
anything. With RichFaces you can easily create Web 2.0 applications
with a professional look and feel that let users forget that they’re
working in a browser with a remote server. You can use context menus,
modal dialogs, sortable, filterable, and pageable tables, rich text
editor, cool visual effects, and more.

RichFaces isn’t the only such library, another popular one is
ICEfaces, which has been embraced by Sun. But RichFaces is supported
by JBoss and works well with its server, portal, and Seam. Remember I
told you Seam is an integration framework?

Why Liferay portal?

Though developing portlet applications is considerably more
difficult than plain old web applications as has been discussed
and as we will certainly yet see, there are also the
benefits of content integration, unified front-end to applications
etc. that sometimes outweigh the problems.

I use Liferay because that’s the portal chosen (for the majority
that can’t afford WebSphere Portal) by the bright guys in the portal
group of my company, IBA CZ.
And also because, as a user, I find it more appealing than JBoss

Environment setup

You will need the software listed below. Make
sure to have the same versions or  unexpected problems may happen (examples

  • JBoss Portal 2.7.1
    (with bundled JBoss AS 4.2.3)

  • JDK 1.5 (mine is jdk1.5.0_17 )

  • Seam 2.0.2 SP1 (I’ve preferred this to the latest 2.1.1 GA as it works better with JBoss Tools)It’s already bundled with RichFaces, no separate download of them needed.

    • Check the unpacked folder – there most interesting things are the documentation example applications.
  • Eclipse Ganymede for Java EE v. 3.4.1 (SR1) though you can prefer to try your luck with the latest one (3.4.2 as of today).
  • JBoss Tools as of 2008-12-19 – Seam Tools and JBoss Tools RichFaces 3.0.0
    CR1-R200, JBossAS Tools 2.0.0 CR1-R200, JBoss Portlet 1.0.0 CR1-R200, plus some others. I’ve installed them via Eclipse Update Manager (Help > Software Updates) from the update site http://download.jboss.org/jbosstools/updates/development/ Today it contains an updated version CR2 from 2009-01-28. You can install an older version after unchecking "Show only the latest versions …"

For the sake of completeness I should say that I’m developing
under Linux, namely Ubuntu 8.04 Hardy.

I won’t describe how to install Eclipse and JBoss Tools, you’ll
surely manage that :-). The other items you can just download and
unpack somewhere. for example to /tmp/tutorial/.

Eclipse preparation

After having installed Eclipse and its JBoss Tools plugins:

  1. Let Eclipse know about the JDK 1.5: Window > Preferences >
    Java > Installed JREs > Add… > Standard VM > enter
    path to the unpacked JDK etc.
    Name it “jholy-jdk1.5.0_17 (sorry, I was lazy to rename mine for this tutorial).

  2. Let Eclipse know about the JBoss server: Window >
    Preferences > Server > Runtime Environments > Add… >
    select JBoss, a division of Red-Hat – JBoss 4.2 runtime, …,
    browse to/enter the directory where you unpacked JBoss to
    (/tmp/tutorial/jboss-portal-2.7.1/), and make sure select the previously defined
    JRE (JDK) 1.5. "jholy-jdk1.5.0_17".
    Name it “JBoss 4.2.3 Runtime and Portal

Creating the project

Create the project: File > New > Project > Seam > Seam
Web Project

  • Project name: seamTutorial1
    Seam requires the project name to start with a lower-case letter.

  • Target Runtime: JBoss 4.2.3 Runtime and Portal 2.7.1

  • Dynamic Web Module Version: 2.5

  • Target Server: click New > select JBoss AS 4.2, enter
    Server name JBoss_4.2.3, select the recently defined Server runtime environment
    JBoss 4.2.3 Runtime and Portal 2.7.1, click Next >, enter
    Name JBoss_4.2.3, Next, Finish.

  • Configuration: select Dynamic Web Project with Seam 2.0
    (and not the default 1.2).

Screenshot - NewSeamProject 1 (Seam Web Project)

Click Next, don’t modify anything

Screenshot - NewSeamProject 2 (Web Module)

Click Next, don’t modify anything

Screenshot - NewSeamProject 1 (JSF Capabilities)

Click Next to get to the Seam Facet page:

  • Seam Runtime: click Add…, browse to the directory where you
    unpacked Seam to (/tmp/tutorial/jboss-seam-2.0.2.SP1/), give it the
    name jboss-seam-2.0.2.SP1 and set version to 2.0.

  • Deploy as: WAR

  • Database

    • Database Type: Derby

    • Connection profile: click New… > select Derby, enter
      Name SeamTutorial1Derby, Next >, from Drivers select
      “Derby Embedded JDBC Driver 10.2 Default” (if you haven’t it
      there, download it and add it via the small (+) icon), enter a
      non-existent folder as the Database location (e.g.
      /tmp/tutorial/SeamTutorial1Derby), User name sa, leave the password

      • Test Connection. This will fail if the database location
        folder already exists otherwise it says Ping succeeded!

      • Finish the connection profile creation.

  • Leave the other fields as they are and click Finish to finish the new Seam project wizard.

Screenshot - NewSeamProject 4 (Seam Facet)

Two new projects are created: seamTutorial1 and
seamTutorial1-test. The project seamTutorial1 contains quite a
handful of files:

Screenshot - Package Explorer view of the project seamTutorial1

Open the Seam perspective: Window > Open > Other… >
. This gives you some useful views, including Seam Components (shows name, scope) and (for page development) JBoss Tools Palette. I’d recommend you to open also JBoss Server View to view and manage your JBoss and Tomcat servers.

Running the generated application

Attempt 1:

  • Right-click on the file seamTutorial1/WebContent/home.xhtml > Run As > Run on Server > select Choose an
    existing server and select the previously defined JBoss_4.2.3.

  • Click Next, you should see the page Add and Remove Projects
    with the Configured projects
    seamTutorial1/resources/seamTutorial1-ds.xml and seamTutorial1,
    click Finish.

  • There may be the warning “The connection was refused when
    attempting to contact localhost:8080”. That’s nothing to worry
    about, the browser is just faster than the server.

  • A Console view should pop up where you can see the log of the
    starting JBoss application server.

    • If you see there errors similar
      setProperty must be overridden by all subclasses of

      then you haven’t been attentive enough and are
      running the server with Java 1.6 instead of 1.5. Either switch to
      1.5 or read the release notes of JBoss to learn how to fix this.

    • You may see there
      Exception setting property org.jboss.seam.core.init.jndiPattern on
      component org.jboss.seam.core.init. Expression @jndiPattern@
      evaluated to null.

      • Seam applications are prepared for
        being deployed by Ant, which would replace the token @jndiPattern@ in
        components.xml with a correct value. Unfortunately this version of
        JBoss Tools forgets to do it so you must do it manually.

      • Replace the token @jndiPattern@
        in components.xml with a valid expression, for example #{ejbName}/local.
        See Seam reference, chapter 26.1.5. Integrating Seam with your
        EJB container
        Or better change the project’s build path to WebContent/WEB-INF/classes to get this token replaced with a valid value automatically, see the update from 2009-03-23 at the end of this post.

Attempt 2:

  • Start the application as before. It may take over 7 minutes,
    get a cup of tee. You might notice in the Console view that Seam
    prints name, scope, and type of each installed component. The
    interesting lines there are:
    [Server] JBoss (MX MicroKernel) [4.2.3.GA (build:
    SVNTag=JBoss_4_2_3_GA date=200807181417)] Started in

    INFO [TomcatDeployer] deploy,
    ctxPath=/seamTutorial1, warUrl=…
    INFO [ServletContextListener]
    Welcome to Seam 2.0.2.SP1

    INFO [SeamFilter] Initializing
    filter: org.jboss.seam.debug.hotDeployFilter
    (the last line)

  • Enter the address
    to your browser. It may take a couple of minutes to load.

Screenshot -  seamTutorial1's home.xhtml running in Firefox

Request for feedback

If you find anything inaccurate or not enough clear in this tutorial or if you encounter some other problems that you would like to share with others to help them avoid these, please let me know. Make the continuous improvement through collaboration possible :-).


We have set up a Seam development environment, overcame some
problems, and managed to get a simple application running.

In the next part we will develop our own conversation-scope
Component and a page with a RichFaces paged table.

Update 2009-03-23

Replacing  @jndiPattern@ with a valid value in the correct way

During the first deploy we’ve got the following error:

Exception setting property org.jboss.seam.core.init.jndiPattern on
component org.jboss.seam.core.init. Expression @jndiPattern@
evaluated to null.

As Dan Allen has pointed out, the token @jndiPattern@ should be replaced by Seam in runtime using the property jndiPatter from components.properties. And actually this property is defined in the project’s src/main/components.properties as jndiPattern=\#{ejbName}/local (‘\’ tells the properties that the # isn’t a comment start). So why it doesn’t replace the token? It turns out that the project has its compile path set incorrectly and a likely side effect is that this file isn’t deployed to the server.

To fix it, In Project > Properties > Java Build Path > Source change the Default output folder from seamTutorial1/build/classes to seamTutorial1/WebContent/WEB-INF/classes. After a redeployment, everything is suddenly working.

By the way I really recommend you reading Allen’s article about improving Seam application performance.

Posted in Portlets | Tagged: , , , , , | 8 Comments »