Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
xml
xml
 <?xml version="1.0" encoding="UTF-8"?>
 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns="http://java.sun.com/xml/ns/javaee"
          xmlns:web="http://java.sun.com/xml/ns/javaee/webapp_2_5.xsd"
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                              http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
          id="WebApp_ID" version="2.5">
    <display-name>MyFaces Test Project</display-name>
    <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>
 </web-app> 
{code:xml}

The part between the {{{<servlet>}}} tags tells the application server that it has to instantiate an object of the {{{

The part between the <servlet> tags tells the application server that it has to instantiate an object of the javax.faces.webapp.FacesServlet

...

class

...

as

...

a

...

Servlet

...

and

...

name

...

it

...

Faces

...

Servlet

...

.

...

It

...

will

...

be

...

started

...

at

...

the

...

start

...

up

...

of

...

the

...

application.

...

The

...

part

...

between

...

the

...

<servlet-mapping>

...

tags

...

tells

...

the

...

web

...

server

...

that

...

any

...

URL

...

starting

...

with

...

/faces/

...

immediately

...

after

...

the

...

address

...

of

...

the

...

server

...

and

...

the

...

location

...

of

...

the

...

application

...

will

...

be

...

handled

...

by

...

that

...

Servlet.

...

The

...

faces-config.xml

...

configuration

...

file

...

The

...

faces-config.xml

...

file

...

defines

...

the

...

behavior

...

of

...

the

...

Faces

...

Servlet

...

that

...

is

...

at

...

the

...

heart

...

of

...

a

...

JSF

...

application.

...

Whereas

...

a

...

web.xml

...

file

...

is

...

generally

...

edited

...

only

...

at

...

the

...

start

...

of

...

a

...

project

...

or

...

when

...

structural

...

changes

...

are

...

made

...

to

...

the

...

application,

...

faces-config.xml

...

changes

...

all

...

the

...

time,

...

as

...

the

...

application

...

grows.

...

And

...

while

...

web.xml

...

mostly

...

contains

...

general

...

configuration

...

options,

...

a

...

faces-config.xml

...

file

...

tends

...

to

...

be

...

more

...

specific

...

to

...

a

...

certain

...

application,

...

as

...

it

...

may

...

contain

...

e.g.

...

navigation

...

details

...

and

...

other

...

application-specific

...

configurations.

...

In

...

JSF

...

2.0

...

the

...

presence

...

of

...

a

...

faces-config.xml

...

file

...

is

...

no

...

longer

...

required,

...

but

...

in

...

earlier

...

JSF

...

versions

...

it

...

is.

...

A

...

minimalistic

...

faces-config.xml

...

for

...

JSF

...

1.2

...

may

...

look

...

like this:

Code Block
xml
xml
titlefaces-config.xml
 this:
{{{#!xml
<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance"
              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                                  http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
              version="1.2">
    <application>
        <locale-config>
            <default-locale>en</default-locale>
            <supported-locale>en</supported-locale>
            <supported-locale>en_US</supported-locale>
        </locale-config>
        <message-bundle>my.company.Messages</message-bundle>
    </application>
</faces-config>
}}}

h3. Additional configuration for Glassfish
To use MyFaces Core as the JSF implementation on a Glassfish 2.x application server, we have to make some additional settings in a GlassFish-specific configuration file—{{{

Additional configuration for Glassfish

To use MyFaces Core as the JSF implementation on a Glassfish 2.x application server, we have to make some additional settings in a GlassFish-specific configuration file—sun-web.xml

...

.

...

This

...

file

...

has

...

to

...

be

...

in

...

the

...

WEB-INF

...

folder

...

of

...

our

...

project,

...

along

...

with

...

most

...

of

...

the

...

other

...

configuration

...

files,

...

such

...

as

...

web.xml

...

and

...

faces-config.xml

...

.

...

The

...

contents

...

of

...

the

...

file

...

should

...

look

...

like

...

this:

Code Block
xml
xml
titlesun-web.xml


{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN"
                             "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">
<sun-web-app>
    <class-loader delegate="false"/>
    <property name="useMyFaces" value="true"/>
</sun-web-app>

...