myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Myfaces Wiki] Update of "Drafts/Site/Core" by BartKummel
Date Sat, 12 Feb 2011 15:17:32 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The "Drafts/Site/Core" page has been changed by BartKummel.
http://wiki.apache.org/myfaces/Drafts/Site/Core?action=diff&rev1=3&rev2=4

--------------------------------------------------

  So you want to use MyFaces Core as the JSF implementation in your project. This section
tells you how to get started.
  
  === Maven ===
- If you're using Maven to manage dependencies, you can use on of the Maven archetypes provided
by the [[Drafts/Site/MavenArchetypes|Maven archetypes]] sub project to generate an empty project
with all of the libraries you need already in place. See the [[Drafts/Site/MavenArchetypes|Maven
archetypes]] for details.
+ If you're using Maven to manage dependencies, you can use on of the Maven archetypes provided
by the [[Drafts/Site/MavenArchetypes|Maven archetypes]] sub project to generate an empty project
with all of the libraries you need already in place. See the [[Drafts/Site/MavenArchetypes|Maven
archetypes]] for details. After you've created a project, continue with the [[#Configuring
MyFaces]] section.
  
  === Managing dependencies manually ===
  If you're not using Maven, you'll have to manage your dependencies manually. This section
describes what's needed to add MyFaces Core as a dependency to you project.
@@ -30, +30 @@

      * {{{myfaces-api-x.y.z.jar}}}: the JSF API. These are all the interfaces and classes
that are called from the outside. In other words, these are those things you import from the
{{{javax.faces}}} package.
      * {{{myfaces-bundle-x.y.z.jar}}}: a combination of the previous two in one single JAR.

      * {{{commons-......jar}}}: a series of libraries from the Apache Commons project, that
MyFaces Core depends on. 
-    You should add either the {{{myfaces-impl-x.y.z.jar}}} and {{{myfaces-api-x.y.z.jar}}}
or the {{{myfaces-bundle-x.y.z.jar}}} to your project's classpath. Further more, all {{{commons-......jar}}}
files should also be added to the classpath. The procedure to add JARs to a classpath differs,
depending on the IDE you are using for your project.
+  You should add either the {{{myfaces-impl-x.y.z.jar}}} and {{{myfaces-api-x.y.z.jar}}}
or the {{{myfaces-bundle-x.y.z.jar}}} to your project's classpath. Further more, all {{{commons-......jar}}}
files should also be added to the classpath. The procedure to add JARs to a classpath differs,
depending on the IDE you are using for your project. After you've set the dependencies for
you project, continue with the [[#Configuring MyFaces]] section.
  
+ == Configuring MyFaces ==
+ There are two important configuration files for a JSF application—{{{web.xml}}} and {{{faces-config.xml}}}.
We will discuss the basics of both of them.
+ 
+ === The web.xml configuration file ===
+ The {{{web.xml}}} configuration file resides in the {{{/WEB-INF/}}} directory of the (to
be) deployed web application. It configures the web server part of the application. The {{{web.xml}}}
file can be used to define which file types may be requested by users, which directories can
be accessed, and so on. With regards to JSF, the most important task of {{{web.xml}}} is to
tell the web server that there is such a thing as a Faces Servlet, and that URLs containing
a certain pattern should be forwarded to that Faces Servlet. A minimal {{{web.xml}}} could
look like this:
+ 
+ {{{#!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> 
+ }}}
+ 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:
+ {{{#!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>
+ }}}
+ 

Mime
View raw message