Hello, how are you?
This post will be the biggest so far in my blog! We will see a full web application. It will be done will the newest technologies (until today), but I will give some hints to show how to adapt this post to older technologies.
In the end of this post you will find the source code to download. You can use it as you wish. Just go to the last page and do the download. \o/
If you downloaded the code and did not understand something, in this post I will explain every detail found in the code. Just read the subject inside this post that you want.
I will list bellow the technologies that I will use in this post:
- JSF 2.0 Mojarra – With ManagedBeans as RequestScope and SessionScope.
- Message Internationalization – File that will have all the messages of our system; it will be easier to translate you pages.
- Default CSS file that will be imported as a library.
- EJB 3 – Our DAOs and Façades will be @Stateless.
- Generic DAO – A generic DAO that will have the CRUD actions to make our life easier.
- JPA 2 – To map our classes in the DB
- JAAS – To control the login and the user access to the pages.
- MVC – I will use this pattern with small modifications.
- Postgres as database, but I will show how to set up your app to MySQL also.
I will not use TDD – JUnit to test our View/Model/Classes, but in the following link you can see a technique to use the JUnit to test your ManagedBeans: JUnit with HSQLDB, JPA and Hibernate.
Tools that we will use:
- Eclipse Indigo – http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/indigor
- I will use JBoss 7 (some readers of this blog asked me for it) – http://download.jboss.org/jbossas/7.0/jboss-as-7.0.2.Final/jboss-as-7.0.2.Final.zip the version is: JBoss 7 Everything (NOT Java EE6 Certified).
- Indigo JBoss Tools (milestone version) – https://www.jboss.org/tools/download/dev.html if you do not know how to install the JBoss Tools in this post I will show how to (User Login Validation with JAAS and JSF). Be aware that in the post I will show how to install to another eclipse version, but the difference is the URL; use this URL instead the URL used in the link above: http://download.jboss.org/jbosstools/updates/development/indigo/
- I will use the Postgres database but you can use any database you want; you will need only to download the database and the JDBC driver. Here you can download the latest Postgres JDBC: http://jdbc.postgresql.org/download.html; the latest version so far is the 4: http://jdbc.postgresql.org/download/postgresql-9.1-901.jdbc4.jar.
This post will have several pages; this first page is just to show the technical details of the post today.
I will not code to interface my model/DAO, just to save space. Remember that you should always code to interfaces (Design Pattern – Strategy).
Before you go to the next pages be sure that you installed the JBoss Tools and the JBoss 7 in this exactly order.