SlideShare a Scribd company logo
1 of 13
1



  The author has made every effort in the preparation of this book to ensure the accuracy of the information.
 However, information in this book is sold without warranty either expressed or implied. The author will not be
     held liable for any damages caused or alleged to be caused either directly or indirectly by this book.




       Ajax, JSF, Facelets, Eclipse & Maven
                     tutorials
   Ajax is a method of employing JavaScript, DHTML, and the XMLHttp behaviour in the
 browser to provide truly dynamic content on a Web page without a page refresh. There are
  quantifiable benefits to be realized for end users and businesses, which include improved
usability and faster applications. In this tutorial I will look at a simple example using Ajax4JSF
                           with JSF, Facelets, Maven2 and Eclipse.




                                                     By




                                         K. Arulkumaran

                                                      &

                                              A. Sivayini




                Website: http://www.lulu.com/java-success


              Feedback email: java-interview@hotmail.com
2

                                                 Table Of Contents


Notations ..................................................................................................................... 3
Tutorial 15 – Ajax4jsf with JSF & Facelets......................................................... 4
3
                                     Notations

Command prompt:




Eclipse:




File Explorer or Windows Explorer:




Internet Explorer:
4
Tutorial 15 – Ajax4jsf with JSF & Facelets


This tutorial will guide you through building a simple Ajax based Web
application. This tutorial assumes that you have gone through Tutorials 1-10
& the source code for tutorials 1-10. Also refer to Ajax4jsf developer guide at
https://ajax4jsf.dev.java.net/nonav/documentation/ajax-
documentation/developerGuide.html ) for further information.


Step 1: This tutorial will extend simpleWeb project we created earlier in Tutorials 1-10. We
will Ajax enable this Web application. We will be using Ajax4jsf (check
https://ajax4jsf.dev.java.net/ & http://labs.jboss.com/jbossajax4jsf/). Firstly add the Ajax4jsf
depedendency jar into pom.xml.

                <!-- AJAX -->
                <dependency>
                      <groupId>net.java.dev.ajax4jsf</groupId>
                      <artifactId>ajax4jsf</artifactId>
                      <version>1.0.6</version>
                </dependency>




The complete pom.xml file should look like:

<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>
         <parent>
                  <groupId>com.mytutorial</groupId>
                  <artifactId>simple-tutorial</artifactId>
                  <version>1.0</version>
         </parent>

        <groupId>com.mytutorial</groupId>
        <artifactId>simpleWeb</artifactId>
        <packaging>war</packaging>
        <version>1.0-SNAPSHOT</version>
        <name>simpleWeb Maven Webapp</name>
        <url>http://maven.apache.org</url>
        <dependencies>
                  <dependency>
                          <groupId>com.mytutorial</groupId>
                          <artifactId>simple</artifactId>
5
        <version>1.0-SNAPSHOT</version>
        <type>jar</type>
</dependency>

<dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
</dependency>

<dependency>
        <groupId>commons-digester</groupId>
        <artifactId>commons-digester</artifactId>
        <version>1.8</version>
</dependency>

<dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.2</version>
</dependency>

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring</artifactId>
        <version>2.0.6</version>
</dependency>

<!-- JSF/JSTL/Facelets -->
<dependency>
         <groupId>javax.faces</groupId>
         <artifactId>jsf-api</artifactId>
         <version>1.2</version>
</dependency>
<dependency>
         <groupId>javax.faces</groupId>
         <artifactId>jsf-impl</artifactId>
         <version>1.2_04</version>
</dependency>
<dependency>
         <groupId>com.sun.facelets</groupId>
         <artifactId>jsf-facelets</artifactId>
         <version>1.1.11</version>
</dependency>
<dependency>
         <groupId>javax.servlet</groupId>
         <artifactId>jstl</artifactId>
         <version>1.1.2</version>
</dependency>
<dependency>
         <groupId>javax.el</groupId>
         <artifactId>el-api</artifactId>
         <version>1.0</version>
         <scope>provided</scope>
</dependency>
<dependency>
         <groupId>com.sun.el</groupId>
         <artifactId>el-ri</artifactId>
         <version>1.0</version>
</dependency>

<!-- AJAX -->
<dependency>
        <groupId>net.java.dev.ajax4jsf</groupId>
        <artifactId>ajax4jsf</artifactId>
        <version>1.0.6</version>
</dependency>
6
        </dependencies>
        <build>

                    <finalName>simpleWeb</finalName>
                    <pluginManagement />
         </build>
</project>


Step 2: Now, you need to go back to the command prompt and run the following command to add the
ajax4jsf jar to your build path.

C:tutorialssimple-tutorialsimpleWeb>mvn eclipse:clean eclipse:eclipse

STEP: WorkAround

The JSF 1.2 requires eclipse web facet 2.5. You need to open the file
“org.eclipse.wst.common.project.facet.core.xml” under C:tutorialssimple-
tutorialsimpleWeb.settings as shown below from version=2.4 to version=2.5. Every time you use
the eclipse:clean command, you will have to manually fix this up as shown below.




Step 3: Refresh the “simpleWeb” project.
7
Step 4: Following changes are required in the deployment descriptor files web.xml & faces-
config.xml as shown below:


faces-config.xml

Comment out the following line:

<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>




web.xml

Following need to be added:

       <!-- ajax4jsf -->

       <context-param>
               <param-name>org.ajax4jsf.SKIN</param-name>
               <param-value>classic</param-value>
       </context-param>

       <context-param>
              <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
              <param-value>com.sun.facelets.FaceletViewHandler</param-value>
       </context-param>


       <!-- ajax4jsf -->

       <filter>
                   <filter-name>ajax4jsf</filter-name>
                   <display-name>Ajax4jsf Filter</display-name>
                   <filter-class>org.ajax4jsf.Filter</filter-class>
       </filter>
8
        <filter-mapping>
                  <filter-name>ajax4jsf</filter-name>
                  <servlet-name>Faces Servlet</servlet-name>
        </filter-mapping>


The complete web.xml should look like:

<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
           <!-- JSF        -->
           <context-param>
                     <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
                     <param-value>server</param-value>
           </context-param>
           <context-param>
                     <param-name>javax.faces.CONFIG_FILES</param-name>
                     <param-value>/WEB-INF/faces-config.xml</param-value>
           </context-param>
           <context-param>
                     <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                     <param-value>.jspx</param-value>
           </context-param>

        <!-- Spring -->
        <context-param>
                  <param-name>contextConfigLocation</param-name>

                  <param-value>
                           <![CDATA[
                           /WEB-INF/applicationContext.xml
                           classpath:applicationContext-mytutorial.xml
                           ]]>
                  </param-value>
        </context-param>

        <!-- Special Debug Output for Development -->
        <context-param>
                   <param-name>facelets.DEVELOPMENT</param-name>
                   <param-value>true</param-value>
        </context-param>
        <!-- Optional JSF-RI Parameters to Help Debug -->
        <context-param>
                   <param-name>com.sun.faces.validateXml</param-name>
                   <param-value>true</param-value>
        </context-param>
        <context-param>
                   <param-name>com.sun.faces.verifyObjects</param-name>
                   <param-value>true</param-value>
        </context-param>

        <!-- ajax4jsf -->

        <context-param>
                  <param-name>org.ajax4jsf.SKIN</param-name>
                  <param-value>classic</param-value>
        </context-param>

        <context-param>
            <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
            <param-value>com.sun.facelets.FaceletViewHandler</param-value>
        </context-param>


        <!-- ajax4jsf -->

        <filter>
                   <filter-name>ajax4jsf</filter-name>
                   <display-name>Ajax4jsf Filter</display-name>
                   <filter-class>org.ajax4jsf.Filter</filter-class>
        </filter>
        <filter-mapping>
                   <filter-name>ajax4jsf</filter-name>
                   <servlet-name>Faces Servlet</servlet-name>
        </filter-mapping>
9


        <!-- Listeners -->
        <listener>
                   <listener-class>
                              org.springframework.web.context.ContextLoaderListener
                   </listener-class>
        </listener>

        <listener>
                   <listener-class>
                              org.springframework.web.context.request.RequestContextListener
                   </listener-class>
        </listener>


        <!-- Faces Servlet -->
        <servlet>
                   <servlet-name>Faces Servlet</servlet-name>
                   <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                   <load-on-startup>1</load-on-startup>
        </servlet>

        <!-- Faces Servlet Mapping -->
        <servlet-mapping>
                  <servlet-name>Faces Servlet</servlet-name>
                  <url-pattern>*.jsf</url-pattern>
        </servlet-mapping>


</web-app>




Step 5: Modify one of the pages to demonstrate Ajax in action using Ajax4JSF. We will
modify the inputname.jspx page to provide some Ajax functionality. We will provide Ajax
support to the <h:inputText …> where the person name is entered and behind the scenes
(with the help of Ajax) as we type in the name the managed bean “personBean” is updated
10
and contains the freshest value. This can be demonstrated by outputting the
#{personBean.personName} as shown below.

<?xml version="1.0" encoding="ISO-8859-1" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
         xmlns:h="http://java.sun.com/jsf/html"
         xmlns:f="http://java.sun.com/jsf/core"
         xmlns:ui="http://java.sun.com/jsf/facelets"
         xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
         version="2.0">

         <ui:composition>
                 <html>
                 <head>
                 <meta http-equiv="Content-Type"
                           content="text/html; charset=ISO-8859-1" />
                 <title>Insert title here</title>
                 </head>
                 <body>
                 <f:view>
                           <f:loadBundle basename="com.mytutorial.messages" var="msg" />
                           <h3><h:form id="helloForm">

                                 <h:outputText value="#{msg.prompt}" />
                                 <h:inputText value="#{personBean.personName}" >
                                    <a4j:support event="onkeyup" reRender="rep" />
                                 </h:inputText>

                                 <h:commandButton action="greeting" value="#{msg.button_text}" />

                                 <br/>
                                   Ajax in action by repeating what you type -->
                                 <b>
                                 <h:outputText value="#{personBean.personName}" id="rep" /> </b>

                              </h:form></h3>
                  </f:view>
                  </body>
                  </html>
          </ui:composition>
</jsp:root>
11
Step 6: Make sure that your HSQLDB is running, if not start it.

        Start the HSQL database server by executing the following command in a command
        prompt as shown below:

C:javahsqldb>java -cp ./lib/hsqldb.jar org.hsqldb.Server




Open another command prompt and run the following command:

C:javahsqldb>java -cp ./lib/hsqldb.jar org.hsqldb.util.DatabaseManager




This will spawn a new window as shown:




Step 7: Deploy the “simpleWeb” to Tomcat within eclipse.
12




Step 8: Open an Web browser and type the following URL:

http://localhost:8080/simpleWeb/index.jsf




Click on “Click Me”.
13
As you type the name in “onkeyup” JavaScript event will be fired. Each time this event is fired
on the parent tag, our application sends an AJAX request to the server. This means that the
“personName” on our managed “personBean” is updated with the freshest value of our
input. Isn’t this cool and useful?

Now, click on the “Hello” command button to retrieve data from the database.




That’s all to it.




Please feel free to email any errors to java-interview@hotmail.com. Also stay tuned at
    http://www.lulu.com/java-success for more tutorials and Java/J2EE interview
                                        resources.

More Related Content

What's hot

What You Need To Build Cool Enterprise Applications With JSF
What You Need To Build Cool Enterprise Applications With JSFWhat You Need To Build Cool Enterprise Applications With JSF
What You Need To Build Cool Enterprise Applications With JSFMax Katz
 
Andy Bosch - JavaServer Faces in the cloud
Andy Bosch -  JavaServer Faces in the cloudAndy Bosch -  JavaServer Faces in the cloud
Andy Bosch - JavaServer Faces in the cloudAndy Bosch
 
Empowering users: modifying the admin experience
Empowering users: modifying the admin experienceEmpowering users: modifying the admin experience
Empowering users: modifying the admin experienceBeth Soderberg
 
Troubleshooting APEX Performance Issues
Troubleshooting APEX Performance IssuesTroubleshooting APEX Performance Issues
Troubleshooting APEX Performance IssuesRoel Hartman
 
How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0Takuya Tejima
 
Open mic ibm connections and ibm verse on premise integration 1
Open mic  ibm connections and ibm verse on premise integration 1Open mic  ibm connections and ibm verse on premise integration 1
Open mic ibm connections and ibm verse on premise integration 1sreeJk
 
Javatwo2012 java frameworkcomparison
Javatwo2012 java frameworkcomparisonJavatwo2012 java frameworkcomparison
Javatwo2012 java frameworkcomparisonJini Lee
 
Laravel 로 배우는 서버사이드 #5
Laravel 로 배우는 서버사이드 #5Laravel 로 배우는 서버사이드 #5
Laravel 로 배우는 서버사이드 #5성일 한
 
MySQL crash course by moshe kaplan
MySQL crash course by moshe kaplanMySQL crash course by moshe kaplan
MySQL crash course by moshe kaplanMoshe Kaplan
 
Websphere portal theme menu framework
Websphere portal theme menu frameworkWebsphere portal theme menu framework
Websphere portal theme menu frameworkmichele buccarello
 
Ionic tabs template explained
Ionic tabs template explainedIonic tabs template explained
Ionic tabs template explainedRamesh BN
 
AngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.jsAngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.jsMark
 
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dep...
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dep...Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dep...
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dep...Uniface
 
Ionic으로 모바일앱 만들기 #4
Ionic으로 모바일앱 만들기 #4Ionic으로 모바일앱 만들기 #4
Ionic으로 모바일앱 만들기 #4성일 한
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen LjuSkills Matter
 
Angular JS blog tutorial
Angular JS blog tutorialAngular JS blog tutorial
Angular JS blog tutorialClaude Tech
 

What's hot (20)

What You Need To Build Cool Enterprise Applications With JSF
What You Need To Build Cool Enterprise Applications With JSFWhat You Need To Build Cool Enterprise Applications With JSF
What You Need To Build Cool Enterprise Applications With JSF
 
Andy Bosch - JavaServer Faces in the cloud
Andy Bosch -  JavaServer Faces in the cloudAndy Bosch -  JavaServer Faces in the cloud
Andy Bosch - JavaServer Faces in the cloud
 
The Rails Way
The Rails WayThe Rails Way
The Rails Way
 
Empowering users: modifying the admin experience
Empowering users: modifying the admin experienceEmpowering users: modifying the admin experience
Empowering users: modifying the admin experience
 
Troubleshooting APEX Performance Issues
Troubleshooting APEX Performance IssuesTroubleshooting APEX Performance Issues
Troubleshooting APEX Performance Issues
 
How to use soap component
How to use soap componentHow to use soap component
How to use soap component
 
How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0
 
Open mic ibm connections and ibm verse on premise integration 1
Open mic  ibm connections and ibm verse on premise integration 1Open mic  ibm connections and ibm verse on premise integration 1
Open mic ibm connections and ibm verse on premise integration 1
 
Javatwo2012 java frameworkcomparison
Javatwo2012 java frameworkcomparisonJavatwo2012 java frameworkcomparison
Javatwo2012 java frameworkcomparison
 
Vuex
VuexVuex
Vuex
 
Laravel 로 배우는 서버사이드 #5
Laravel 로 배우는 서버사이드 #5Laravel 로 배우는 서버사이드 #5
Laravel 로 배우는 서버사이드 #5
 
MySQL crash course by moshe kaplan
MySQL crash course by moshe kaplanMySQL crash course by moshe kaplan
MySQL crash course by moshe kaplan
 
Websphere portal theme menu framework
Websphere portal theme menu frameworkWebsphere portal theme menu framework
Websphere portal theme menu framework
 
Ionic tabs template explained
Ionic tabs template explainedIonic tabs template explained
Ionic tabs template explained
 
AngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.jsAngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.js
 
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dep...
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dep...Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dep...
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dep...
 
Ionic으로 모바일앱 만들기 #4
Ionic으로 모바일앱 만들기 #4Ionic으로 모바일앱 만들기 #4
Ionic으로 모바일앱 만들기 #4
 
Xml sitemap content 500 pages
Xml sitemap content 500 pagesXml sitemap content 500 pages
Xml sitemap content 500 pages
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
 
Angular JS blog tutorial
Angular JS blog tutorialAngular JS blog tutorial
Angular JS blog tutorial
 

Viewers also liked

Logminingsurvey
LogminingsurveyLogminingsurvey
Logminingsurveydrewz lin
 
IBM Web Content Management - Melhores práticas
IBM Web Content Management - Melhores práticasIBM Web Content Management - Melhores práticas
IBM Web Content Management - Melhores práticasrodrigoareis
 
Tomislav Capan - Muzika Hr (IT Showoff)
Tomislav Capan - Muzika Hr (IT Showoff)Tomislav Capan - Muzika Hr (IT Showoff)
Tomislav Capan - Muzika Hr (IT Showoff)IT Showoff
 
Métricas em mídias sociais (versão 2010)
Métricas em mídias sociais (versão 2010)Métricas em mídias sociais (versão 2010)
Métricas em mídias sociais (versão 2010)Edney Souza
 
互联网搜索技巧
互联网搜索技巧互联网搜索技巧
互联网搜索技巧bemyfriend
 
Attack_Simulation_and_Threat_Modeling
Attack_Simulation_and_Threat_ModelingAttack_Simulation_and_Threat_Modeling
Attack_Simulation_and_Threat_ModelingOluseyi Akindeinde
 
Shanghai big tradeshow calendar 2014 collection by MARKYE@LIERJIA.CN
Shanghai big tradeshow calendar 2014 collection by MARKYE@LIERJIA.CN Shanghai big tradeshow calendar 2014 collection by MARKYE@LIERJIA.CN
Shanghai big tradeshow calendar 2014 collection by MARKYE@LIERJIA.CN YiMu Exhibition Services Co.,Ltd.
 
2011 New Product Showcase
2011 New Product Showcase2011 New Product Showcase
2011 New Product Showcasebmmitt
 
Medication Reconciliation in Electronic Health Information Exchange
Medication Reconciliation in Electronic Health Information ExchangeMedication Reconciliation in Electronic Health Information Exchange
Medication Reconciliation in Electronic Health Information ExchangeTomasz Adamusiak
 
Web Application Hacking 2004
Web Application Hacking 2004Web Application Hacking 2004
Web Application Hacking 2004Mike Spaulding
 
Adobe Digital Publishing Suite by dualpixel
Adobe Digital Publishing Suite by dualpixelAdobe Digital Publishing Suite by dualpixel
Adobe Digital Publishing Suite by dualpixeldualpixel
 

Viewers also liked (20)

Ticer2005
Ticer2005Ticer2005
Ticer2005
 
Logminingsurvey
LogminingsurveyLogminingsurvey
Logminingsurvey
 
IBM Web Content Management - Melhores práticas
IBM Web Content Management - Melhores práticasIBM Web Content Management - Melhores práticas
IBM Web Content Management - Melhores práticas
 
Xakep
XakepXakep
Xakep
 
Recherche
RechercheRecherche
Recherche
 
Tomislav Capan - Muzika Hr (IT Showoff)
Tomislav Capan - Muzika Hr (IT Showoff)Tomislav Capan - Muzika Hr (IT Showoff)
Tomislav Capan - Muzika Hr (IT Showoff)
 
Unemployment
UnemploymentUnemployment
Unemployment
 
Catalog
CatalogCatalog
Catalog
 
Search engines
Search enginesSearch engines
Search engines
 
Métricas em mídias sociais (versão 2010)
Métricas em mídias sociais (versão 2010)Métricas em mídias sociais (versão 2010)
Métricas em mídias sociais (versão 2010)
 
互联网搜索技巧
互联网搜索技巧互联网搜索技巧
互联网搜索技巧
 
Attack_Simulation_and_Threat_Modeling
Attack_Simulation_and_Threat_ModelingAttack_Simulation_and_Threat_Modeling
Attack_Simulation_and_Threat_Modeling
 
Shanghai big tradeshow calendar 2014 collection by MARKYE@LIERJIA.CN
Shanghai big tradeshow calendar 2014 collection by MARKYE@LIERJIA.CN Shanghai big tradeshow calendar 2014 collection by MARKYE@LIERJIA.CN
Shanghai big tradeshow calendar 2014 collection by MARKYE@LIERJIA.CN
 
document
documentdocument
document
 
2011 New Product Showcase
2011 New Product Showcase2011 New Product Showcase
2011 New Product Showcase
 
Medication Reconciliation in Electronic Health Information Exchange
Medication Reconciliation in Electronic Health Information ExchangeMedication Reconciliation in Electronic Health Information Exchange
Medication Reconciliation in Electronic Health Information Exchange
 
Google
GoogleGoogle
Google
 
Web Application Hacking 2004
Web Application Hacking 2004Web Application Hacking 2004
Web Application Hacking 2004
 
Adobe Digital Publishing Suite by dualpixel
Adobe Digital Publishing Suite by dualpixelAdobe Digital Publishing Suite by dualpixel
Adobe Digital Publishing Suite by dualpixel
 
Asp net (versione 1 e 2)
Asp net (versione 1 e 2)Asp net (versione 1 e 2)
Asp net (versione 1 e 2)
 

Similar to Ajax, JSF, Facelets, Eclipse & Maven tutorials

JavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオンJavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオンharuki ueno
 
Jsf, facelets, spring, hibernate, maven2
Jsf, facelets, spring, hibernate, maven2Jsf, facelets, spring, hibernate, maven2
Jsf, facelets, spring, hibernate, maven2Raghavan Mohan
 
JSF, Facelets, Spring-JSF & Maven
JSF, Facelets, Spring-JSF & MavenJSF, Facelets, Spring-JSF & Maven
JSF, Facelets, Spring-JSF & MavenRaghavan Mohan
 
Pom configuration java xml
Pom configuration java xmlPom configuration java xml
Pom configuration java xmlakmini
 
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
Java, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorialJava, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorialRaghavan Mohan
 
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010Arun Gupta
 
Spring into rails
Spring into railsSpring into rails
Spring into railsHiro Asari
 
JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011Arun Gupta
 
Jlook web ui framework
Jlook web ui frameworkJlook web ui framework
Jlook web ui frameworkHongSeong Jeon
 
How to create a skeleton of a Java console application
How to create a skeleton of a Java console applicationHow to create a skeleton of a Java console application
How to create a skeleton of a Java console applicationDmitri Pisarenko
 
Spring Web Service, Spring JMS, Eclipse & Maven tutorials
Spring Web Service, Spring JMS, Eclipse & Maven tutorialsSpring Web Service, Spring JMS, Eclipse & Maven tutorials
Spring Web Service, Spring JMS, Eclipse & Maven tutorialsRaghavan Mohan
 
Stepbystepguideforbuidlingsimplestrutsapp 090702025438-phpapp02
Stepbystepguideforbuidlingsimplestrutsapp 090702025438-phpapp02Stepbystepguideforbuidlingsimplestrutsapp 090702025438-phpapp02
Stepbystepguideforbuidlingsimplestrutsapp 090702025438-phpapp02Rati Manandhar
 

Similar to Ajax, JSF, Facelets, Eclipse & Maven tutorials (20)

JavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオンJavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオン
 
Jsf, facelets, spring, hibernate, maven2
Jsf, facelets, spring, hibernate, maven2Jsf, facelets, spring, hibernate, maven2
Jsf, facelets, spring, hibernate, maven2
 
JSF, Facelets, Spring-JSF & Maven
JSF, Facelets, Spring-JSF & MavenJSF, Facelets, Spring-JSF & Maven
JSF, Facelets, Spring-JSF & Maven
 
Jsf
JsfJsf
Jsf
 
Pom
PomPom
Pom
 
Pom configuration java xml
Pom configuration java xmlPom configuration java xml
Pom configuration java xml
 
JSF 2.0 Preview
JSF 2.0 PreviewJSF 2.0 Preview
JSF 2.0 Preview
 
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
 
Java, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorialJava, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorial
 
AOP sec3.pptx
AOP sec3.pptxAOP sec3.pptx
AOP sec3.pptx
 
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
 
Google app engine by example
Google app engine by exampleGoogle app engine by example
Google app engine by example
 
Spring into rails
Spring into railsSpring into rails
Spring into rails
 
JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011
 
Jlook web ui framework
Jlook web ui frameworkJlook web ui framework
Jlook web ui framework
 
How to create a skeleton of a Java console application
How to create a skeleton of a Java console applicationHow to create a skeleton of a Java console application
How to create a skeleton of a Java console application
 
Spring Web Service, Spring JMS, Eclipse & Maven tutorials
Spring Web Service, Spring JMS, Eclipse & Maven tutorialsSpring Web Service, Spring JMS, Eclipse & Maven tutorials
Spring Web Service, Spring JMS, Eclipse & Maven tutorials
 
Sel study notes
Sel study notesSel study notes
Sel study notes
 
Web-Performance
Web-PerformanceWeb-Performance
Web-Performance
 
Stepbystepguideforbuidlingsimplestrutsapp 090702025438-phpapp02
Stepbystepguideforbuidlingsimplestrutsapp 090702025438-phpapp02Stepbystepguideforbuidlingsimplestrutsapp 090702025438-phpapp02
Stepbystepguideforbuidlingsimplestrutsapp 090702025438-phpapp02
 

More from Raghavan Mohan

Accelerate with BIRT and Actuate11
Accelerate with BIRT and Actuate11Accelerate with BIRT and Actuate11
Accelerate with BIRT and Actuate11Raghavan Mohan
 
Sachin Tendulkar Resume
Sachin Tendulkar ResumeSachin Tendulkar Resume
Sachin Tendulkar ResumeRaghavan Mohan
 
Senator Barrack Obama Resume
Senator Barrack Obama ResumeSenator Barrack Obama Resume
Senator Barrack Obama ResumeRaghavan Mohan
 
Hibernate, Spring, Eclipse, HSQL Database & Maven tutorial
Hibernate, Spring, Eclipse, HSQL Database & Maven tutorialHibernate, Spring, Eclipse, HSQL Database & Maven tutorial
Hibernate, Spring, Eclipse, HSQL Database & Maven tutorialRaghavan Mohan
 
23617968 digit-fast-track-jan-2009-php
23617968 digit-fast-track-jan-2009-php23617968 digit-fast-track-jan-2009-php
23617968 digit-fast-track-jan-2009-phpRaghavan Mohan
 
Quality - Douglas Crockford
Quality - Douglas CrockfordQuality - Douglas Crockford
Quality - Douglas CrockfordRaghavan Mohan
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming LanguageRaghavan Mohan
 

More from Raghavan Mohan (13)

Accelerate with BIRT and Actuate11
Accelerate with BIRT and Actuate11Accelerate with BIRT and Actuate11
Accelerate with BIRT and Actuate11
 
Who is BIRT
Who is BIRTWho is BIRT
Who is BIRT
 
Introduction to BIRT
Introduction to BIRTIntroduction to BIRT
Introduction to BIRT
 
Sachin Tendulkar Resume
Sachin Tendulkar ResumeSachin Tendulkar Resume
Sachin Tendulkar Resume
 
Manmohan Singh Resume
Manmohan Singh ResumeManmohan Singh Resume
Manmohan Singh Resume
 
Senator Barrack Obama Resume
Senator Barrack Obama ResumeSenator Barrack Obama Resume
Senator Barrack Obama Resume
 
Java/J2EE CV Guide
Java/J2EE CV GuideJava/J2EE CV Guide
Java/J2EE CV Guide
 
Java/J2EE Companion
Java/J2EE CompanionJava/J2EE Companion
Java/J2EE Companion
 
Hibernate, Spring, Eclipse, HSQL Database & Maven tutorial
Hibernate, Spring, Eclipse, HSQL Database & Maven tutorialHibernate, Spring, Eclipse, HSQL Database & Maven tutorial
Hibernate, Spring, Eclipse, HSQL Database & Maven tutorial
 
Fast Track to Ajax.
Fast Track to Ajax.Fast Track to Ajax.
Fast Track to Ajax.
 
23617968 digit-fast-track-jan-2009-php
23617968 digit-fast-track-jan-2009-php23617968 digit-fast-track-jan-2009-php
23617968 digit-fast-track-jan-2009-php
 
Quality - Douglas Crockford
Quality - Douglas CrockfordQuality - Douglas Crockford
Quality - Douglas Crockford
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
 

Recently uploaded

Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxFIDO Alliance
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfAnubhavMangla3
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهMohamed Sweelam
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfSrushith Repakula
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe中 央社
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxMasterG
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?Paolo Missier
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireExakis Nelite
 
Navigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiNavigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiRaviKumarDaparthi
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsLeah Henrickson
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Paige Cruz
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctBrainSell Technologies
 
Microsoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdfMicrosoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdfOverkill Security
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024Lorenzo Miniero
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxFIDO Alliance
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdfMuhammad Subhan
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...panagenda
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...FIDO Alliance
 

Recently uploaded (20)

Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Navigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiNavigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi Daparthi
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Microsoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdfMicrosoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdf
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 

Ajax, JSF, Facelets, Eclipse & Maven tutorials

  • 1. 1 The author has made every effort in the preparation of this book to ensure the accuracy of the information. However, information in this book is sold without warranty either expressed or implied. The author will not be held liable for any damages caused or alleged to be caused either directly or indirectly by this book. Ajax, JSF, Facelets, Eclipse & Maven tutorials Ajax is a method of employing JavaScript, DHTML, and the XMLHttp behaviour in the browser to provide truly dynamic content on a Web page without a page refresh. There are quantifiable benefits to be realized for end users and businesses, which include improved usability and faster applications. In this tutorial I will look at a simple example using Ajax4JSF with JSF, Facelets, Maven2 and Eclipse. By K. Arulkumaran & A. Sivayini Website: http://www.lulu.com/java-success Feedback email: java-interview@hotmail.com
  • 2. 2 Table Of Contents Notations ..................................................................................................................... 3 Tutorial 15 – Ajax4jsf with JSF & Facelets......................................................... 4
  • 3. 3 Notations Command prompt: Eclipse: File Explorer or Windows Explorer: Internet Explorer:
  • 4. 4 Tutorial 15 – Ajax4jsf with JSF & Facelets This tutorial will guide you through building a simple Ajax based Web application. This tutorial assumes that you have gone through Tutorials 1-10 & the source code for tutorials 1-10. Also refer to Ajax4jsf developer guide at https://ajax4jsf.dev.java.net/nonav/documentation/ajax- documentation/developerGuide.html ) for further information. Step 1: This tutorial will extend simpleWeb project we created earlier in Tutorials 1-10. We will Ajax enable this Web application. We will be using Ajax4jsf (check https://ajax4jsf.dev.java.net/ & http://labs.jboss.com/jbossajax4jsf/). Firstly add the Ajax4jsf depedendency jar into pom.xml. <!-- AJAX --> <dependency> <groupId>net.java.dev.ajax4jsf</groupId> <artifactId>ajax4jsf</artifactId> <version>1.0.6</version> </dependency> The complete pom.xml file should look like: <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> <parent> <groupId>com.mytutorial</groupId> <artifactId>simple-tutorial</artifactId> <version>1.0</version> </parent> <groupId>com.mytutorial</groupId> <artifactId>simpleWeb</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>simpleWeb Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>com.mytutorial</groupId> <artifactId>simple</artifactId>
  • 5. 5 <version>1.0-SNAPSHOT</version> <type>jar</type> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>commons-digester</groupId> <artifactId>commons-digester</artifactId> <version>1.8</version> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.2</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> <version>2.0.6</version> </dependency> <!-- JSF/JSTL/Facelets --> <dependency> <groupId>javax.faces</groupId> <artifactId>jsf-api</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>javax.faces</groupId> <artifactId>jsf-impl</artifactId> <version>1.2_04</version> </dependency> <dependency> <groupId>com.sun.facelets</groupId> <artifactId>jsf-facelets</artifactId> <version>1.1.11</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>javax.el</groupId> <artifactId>el-api</artifactId> <version>1.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.sun.el</groupId> <artifactId>el-ri</artifactId> <version>1.0</version> </dependency> <!-- AJAX --> <dependency> <groupId>net.java.dev.ajax4jsf</groupId> <artifactId>ajax4jsf</artifactId> <version>1.0.6</version> </dependency>
  • 6. 6 </dependencies> <build> <finalName>simpleWeb</finalName> <pluginManagement /> </build> </project> Step 2: Now, you need to go back to the command prompt and run the following command to add the ajax4jsf jar to your build path. C:tutorialssimple-tutorialsimpleWeb>mvn eclipse:clean eclipse:eclipse STEP: WorkAround The JSF 1.2 requires eclipse web facet 2.5. You need to open the file “org.eclipse.wst.common.project.facet.core.xml” under C:tutorialssimple- tutorialsimpleWeb.settings as shown below from version=2.4 to version=2.5. Every time you use the eclipse:clean command, you will have to manually fix this up as shown below. Step 3: Refresh the “simpleWeb” project.
  • 7. 7 Step 4: Following changes are required in the deployment descriptor files web.xml & faces- config.xml as shown below: faces-config.xml Comment out the following line: <view-handler>com.sun.facelets.FaceletViewHandler</view-handler> web.xml Following need to be added: <!-- ajax4jsf --> <context-param> <param-name>org.ajax4jsf.SKIN</param-name> <param-value>classic</param-value> </context-param> <context-param> <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name> <param-value>com.sun.facelets.FaceletViewHandler</param-value> </context-param> <!-- ajax4jsf --> <filter> <filter-name>ajax4jsf</filter-name> <display-name>Ajax4jsf Filter</display-name> <filter-class>org.ajax4jsf.Filter</filter-class> </filter>
  • 8. 8 <filter-mapping> <filter-name>ajax4jsf</filter-name> <servlet-name>Faces Servlet</servlet-name> </filter-mapping> The complete web.xml should look like: <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <!-- JSF --> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>server</param-value> </context-param> <context-param> <param-name>javax.faces.CONFIG_FILES</param-name> <param-value>/WEB-INF/faces-config.xml</param-value> </context-param> <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.jspx</param-value> </context-param> <!-- Spring --> <context-param> <param-name>contextConfigLocation</param-name> <param-value> <![CDATA[ /WEB-INF/applicationContext.xml classpath:applicationContext-mytutorial.xml ]]> </param-value> </context-param> <!-- Special Debug Output for Development --> <context-param> <param-name>facelets.DEVELOPMENT</param-name> <param-value>true</param-value> </context-param> <!-- Optional JSF-RI Parameters to Help Debug --> <context-param> <param-name>com.sun.faces.validateXml</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>com.sun.faces.verifyObjects</param-name> <param-value>true</param-value> </context-param> <!-- ajax4jsf --> <context-param> <param-name>org.ajax4jsf.SKIN</param-name> <param-value>classic</param-value> </context-param> <context-param> <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name> <param-value>com.sun.facelets.FaceletViewHandler</param-value> </context-param> <!-- ajax4jsf --> <filter> <filter-name>ajax4jsf</filter-name> <display-name>Ajax4jsf Filter</display-name> <filter-class>org.ajax4jsf.Filter</filter-class> </filter> <filter-mapping> <filter-name>ajax4jsf</filter-name> <servlet-name>Faces Servlet</servlet-name> </filter-mapping>
  • 9. 9 <!-- Listeners --> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <listener> <listener-class> org.springframework.web.context.request.RequestContextListener </listener-class> </listener> <!-- Faces Servlet --> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- Faces Servlet Mapping --> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> </web-app> Step 5: Modify one of the pages to demonstrate Ajax in action using Ajax4JSF. We will modify the inputname.jspx page to provide some Ajax functionality. We will provide Ajax support to the <h:inputText …> where the person name is entered and behind the scenes (with the help of Ajax) as we type in the name the managed bean “personBean” is updated
  • 10. 10 and contains the freshest value. This can be demonstrated by outputting the #{personBean.personName} as shown below. <?xml version="1.0" encoding="ISO-8859-1" ?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="https://ajax4jsf.dev.java.net/ajax" version="2.0"> <ui:composition> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Insert title here</title> </head> <body> <f:view> <f:loadBundle basename="com.mytutorial.messages" var="msg" /> <h3><h:form id="helloForm"> <h:outputText value="#{msg.prompt}" /> <h:inputText value="#{personBean.personName}" > <a4j:support event="onkeyup" reRender="rep" /> </h:inputText> <h:commandButton action="greeting" value="#{msg.button_text}" /> <br/> Ajax in action by repeating what you type --> <b> <h:outputText value="#{personBean.personName}" id="rep" /> </b> </h:form></h3> </f:view> </body> </html> </ui:composition> </jsp:root>
  • 11. 11 Step 6: Make sure that your HSQLDB is running, if not start it. Start the HSQL database server by executing the following command in a command prompt as shown below: C:javahsqldb>java -cp ./lib/hsqldb.jar org.hsqldb.Server Open another command prompt and run the following command: C:javahsqldb>java -cp ./lib/hsqldb.jar org.hsqldb.util.DatabaseManager This will spawn a new window as shown: Step 7: Deploy the “simpleWeb” to Tomcat within eclipse.
  • 12. 12 Step 8: Open an Web browser and type the following URL: http://localhost:8080/simpleWeb/index.jsf Click on “Click Me”.
  • 13. 13 As you type the name in “onkeyup” JavaScript event will be fired. Each time this event is fired on the parent tag, our application sends an AJAX request to the server. This means that the “personName” on our managed “personBean” is updated with the freshest value of our input. Isn’t this cool and useful? Now, click on the “Hello” command button to retrieve data from the database. That’s all to it. Please feel free to email any errors to java-interview@hotmail.com. Also stay tuned at http://www.lulu.com/java-success for more tutorials and Java/J2EE interview resources.