True Abstraction Revisited: Composite UI Components in JSF 2.0
I got some difficulties following the tutorial about creating components with JSF 2.0, mainly due to some obsolete instructions and Maven dependencies of the more than 1 year old original articles of Ed Burns. I wrote down upgrades instructions in a hope to help other newbies to create composite UI with JSF 2.0. Nevertheless, you should read the original text because I won't explain the concepts behind creating Composite User Interfaces and neither rephrase Ed Burns. I will just give you en updated version of the same project, with the same xhtml code. I am using Eclipse on the Karmic Koala Ubuntu 9.10 but the below instructions should work everywhere :)
The original articles from Ed Burns:
- True Abstraction: Composite UI Components in JSF 2.0 -- Part 1
- True Abstraction: Composite UI Components in JSF 2.0 -- Part 2
There are tons of related material on the web, but after reading several blogs and tutorials I've choosen the Mr. Burns' ones due to the simplicity of the example. If you know other good material to start learning UI composite elements with JSF 2.0, please write the URL in the bottom of this page. The original text is based on Netbeans and depends on a local copy of javaee and jsf libs. I replaced that for Maven dependencies and I also adapted the example to Eclipse but there is no dependency to any Eclipse feature, you are free to choose your IDE since the code is a pure Maven project. I also added an external css file instead of the original inline style tag.
-
Install Glassfish v3 and Maven 2.x
-
Download the sample project and unzip it somewhere
-
Go to the folder you unziped the sample project and type the following commands:
mvn -Dwtpversion=2.0 compile package eclipse:eclipseasadmin start-domainasadmin deploy target/jsf-example01.war -
Open the project URL with your browser: http://localhost:8080/jsf-example01/index.jsf
You should see something like the below image:

You should be able to import the project in Eclipse and also to use the Glassfish Eclipse Plugin to run and/or debug the project directly inside the IDE. Be my guest to ask about this example, I am also learning here but eventually I am one step further :). And if you need advanced hints about JSF, please join the Mojarra mailing list, the quality and the velocity of the responses are impressive.
| Attachment | Size |
|---|---|
| uicomposite.png | 22.22 KB |
| example01.zip | 8.7 KB |
- Printer-friendly version
- felipegaucho's blog
- 2050 reads






Comments
missing artifacts
by andyhot - 2009-12-30 18:06
Missing: ---------- 1) javax:javaee-api:jar:6.0-SNAPSHOT Path to dependency: 1) 200808-techtip:jsf-example01:war:0.1 2) javax:javaee-api:jar:6.0-SNAPSHOT 2) javax.faces:jsf-api:jar:2.0 Path to dependency: 1) 200808-techtip:jsf-example01:war:0.1 2) javax.faces:jsf-api:jar:2.0 ---------- 2 required artifacts are missing.repositories updated in the pom.xml
by felipegaucho - 2009-12-31 13:26
ok, repositories missed in the first file. I updated the file and now it should be working fine.
* my local repository contains the javaee files, that's why I didn't detected the missed repos first. Thanks for your feedback.