A Simple Example of JSF Application

A Simple Example of JSF Application Using Eclipse

Jar To Be Downlod:

1.     CREATE PROJECT (ECLIPSE IDE)

 

2.     SELECT DYNAMIC WEB PROJECT

 

3.     Keep All the things default

 

4.     For deployment Need to select approprieate Configuration server Click on Modify

 

5.     Click on Runtime  on your Right Side

 

6.     Click on New Right hand side Down

 

7.     Select apache version (latest) 9

 

8.     Browse apache version which you have already downloaded from the apache side ()

 

9.     Select Apache and OK

 

10.                       Now default Apache will be yours selected version

 

11.                       Simple Java Dynamic Web Project Created

 

12.                       Go to properties in project

 

13.                       Click on Project Facets

 

14.                       Click on JavaServer Faces (CheckBox)

 

15.                       Clicko n Further Configuration required down

 

16.                       Need given two jar which is already downloaded from internate

 

17.                       Click on Manage Lib on give screen shot

 

18.                       Click on New

 

19.                       Create new UserLib name like JSF_LIB (Click OK)

 

20.                       Click Add External Jar

 

21.                       Find your external jar from the folder and add them here

 

22.                       Download given 2 jar from internate

 

23.                       Apply and Close

 

24.                       Create new xHtml file (in web Content Folder of the project)

 

25.                       Make it Empty that file and click CTRL+Space

 

26.                       Select given below

 

27.                       File with some content creted

 

28.                       WEB-INF folder will have faces-config.xml file which means we enabled JavaServer Faces Properly

 

29.                       Click on Project Run On Server

 

30.                       Working Fine Application

Index.xHtml Content 
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<div style="width:100%;font-size:36px;line-height:48px;background-color:navy;color:white">My Facelet Application</div>

</body>
</html>
web.xml Content
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>TestJSF</display-name>
  <welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
</web-app>
Jar To Be Downlod:


NEXT --> Managed Bean In JSF Application

Comments

Popular posts from this blog

JunitTest

Log4j2 Setup