Skip to main content

First Java EE 6 application

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.

landing-proto

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

Popular posts from this blog

CKEDITOR 3.x - Simplest Ajax Submit Plugin

  I have assumed that you have downloaded and got started with CKEDITOR. Step 1 – The html file is shown below: <html> <head> <title>Writer</title> <meta content="text/html; charset=utf-8" http-equiv="content-type" /> <script type="text/javascript" src="ckeditor/ckeditor.js"></script> <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> <style> .cke_contents { height: 400px !important; } </style> </head> <body> <form action="sample_posteddata.php" method="post"> <textarea id="editor" > </textarea> <script type="text/javascript"> //<![CDATA[ CKEDITOR.replace( 'editor', { fullPage : true, uiColor : '#9AB8F3', toolbar : 'MyToolbar' }); //]]> </script> </form> </body> </html> Note that the jquery js

Part 3 - Integrating Tiles, Thymeleaf and Spring MVC 3

In this post I will demonstrate how to integrate Apache Tiles with Thymeleaf. This is very simple. The first step is to include the tiles and thymeleaf-tiles extension dependencies. I will include them in the pom.xml. Note we wil lbe using Tiles 2.2.2 Listing 1 - parent/pom.xml --- thymeleaf-tiles and tiles dependencies <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> <!-- Tiles --> <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> <dependency> <groupId>org.apache.tiles</groupId> <artifactId>tiles-core</artifactId> <version>${tiles.version}</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.tiles</groupId> <artifactId>tiles-template</artifactId> <version>${tiles.version}</version> <scope>compile</s

How to Stand up a Spring Cloud Config Server?

Setup and Configure Spring Cloud Config Server Project Spring Cloud Config Server is just another Spring Boot application. It provides several infrastructure micro services to centralize access to configuration information backed by a version controlled (well at least in the case of default GIT storage) repository. Step 1 - Create a Spring Boot project in STS with the dependencies shown in Figure 2. Figure 1 - Creating Spring Boot project to setup Spring Cloud Config Server Figure 2 - Spring Cloud Config Server dependencies Click on 'Finish' to complete the creation of the Spring Boot project in STS. The build.gradle file is shown in listing below. There is only one dependency to the Spring Cloud Config Server. Also Spring Cloud release train 'Dalston.SR1'. Step 2 - Annotate the class containing main method The next step is to annotate the ConfigServerInfraApplication class with  @EnableConfigServer That's all is needed on the Java si