to create a Maven 2 Java EE 6 application. This will be primarily the UI part build with JSF. Primefaces is the library of choice to build the “windowshop” application. I will try to build a landing page similar to oscommerce. The figure 1 below shows a screenshot of the landing page mock up.
Figure 1 – Landing page prototype
Now let us create a Maven 2 web project using the - “maven-archetype-webapp”.
The listing below shows the pom.xml
Listing 1 – pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.windowshop</groupId>
<artifactId>shopweb</artifactId>
<packaging>war</packaging>
<version>1.0.0</version>
<name>shopweb Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<!-- Prime faces , JSF -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>2.2.RC1-SNAPSHOT</version>
<scope>runtime</scope>
<type>jar</type>
</dependency></dependencies>
<repositories>
<repository>
<id>prime-repo</id>
<name>Prime Technology Maven Repository</name>
<url>http://repository.prime.com.tr/</url>
</repository>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
</repository> </repositories>
<build>
<finalName>shopweb</finalName>
</build>
</project>
The web.xml need not have any entry as shown in listing 2. As per JSF 2 auto – registers FacesServlet which is required for JSF URL interpretation following the pluggability feature of Servlet 3. I will write about this feature and how this is enabled in JSF 2 in the next post.
Listing.2 – web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>shopweb</display-name>
</web-app>
Now let us modify the index.jsp page to redirect to the default home landing page as shown in listing 3.
Listing 3 – index.jsp
<html>
<body>
<jsp:forward page="ui/home.jsf"></jsp:forward>
</body>
</html>
I will add the facelet templates and the home page. These are all in the SVN now. I am lazy copying them over here.
You can add the JBOSS 5 server adapter in Eclipse to start stop JBOSS 6 for now. Add the shopweb project and start the server. Once deployment is over, browse to - http://localhost:8080/shopweb/. This should display the guest home page. I will work to make this page similar to the prototype in Figure 1.
Comments
Post a Comment