Repository navigation
Expand file tree
/
Copy pathGet_started.xml
More file actions
191 lines (156 loc) · 6.74 KB
/
Copy pathGet_started.xml
File metadata and controls
191 lines (156 loc) · 6.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="GettingStarted">
<title>Get Started</title>
<para>It should not be difficult to install PrettyFaces into any new or
existing Servlet-based application. Follow the next few steps and you
should have a working configuration in only a few minutes.
</para>
<section id="getstarted.getprettyfaces">
<title>Get PrettyFaces</title>
<para>
This step is pretty straight-forward, right? Copy the PrettyFaces JAR file into
your /WEB-INF/lib directory, or include a <ulink url="http://maven.apache.org/">
Maven</ulink> dependency in your pom.xml (recommended):
</para>
<para>
Non-Maven users may download JAR files manually from one of the following repositories:
(<ulink url="http://repo1.maven.org/maven2/com/ocpsoft/">Central</ulink>,
<ulink url="http://ocpsoft.com/repository/com/ocpsoft/">OcpSoft</ulink>). Be sure to
select the correct package for your version of JSF.
</para>
<note>
<para>
As of PrettyFaces 3.3.0, no additional JAR files for are required for Non-Maven users; installation is just a single download and install.
</para>
</note>
<para>
<command>List of Maven Dependencies:</command>
<programlisting><![CDATA[<!-- for JSF 2.x -->
<dependency>
<groupId>com.ocpsoft</groupId>
<artifactId>prettyfaces-jsf2</artifactId>
<version>${latest.prettyfaces.version}</version>
</dependency>
<!-- for JSF 1.2.x -->
<dependency>
<groupId>com.ocpsoft</groupId>
<artifactId>prettyfaces-jsf12</artifactId>
<version>${latest.prettyfaces.version}</version>
</dependency>
<!-- for JSF 1.1.x (UNSUPPORTED) -->
<dependency>
<groupId>com.ocpsoft</groupId>
<artifactId>prettyfaces-jsf11</artifactId>
<version>${latest.prettyfaces.version}</version>
</dependency>]]></programlisting>
</para>
</section>
<section id="getstarted.webxml">
<title>Configure PrettyFaces in web.xml</title>
<para>
If you are using a Servlet 3.0 compliant container, you may skip this
step because PrettyFaces will automatically register the required Servlet
Filter; otherwise, make sure PrettyFilter is the first filter in your
web.xml file. (The dispatcher elements are required to ensure
PrettyFaces intercepts both internal and external requests.)
</para>
<example>
<title>/WEB-INF/web.xml (Ignore if using Servlet 3.0)</title>
<programlisting><![CDATA[<filter>
<filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Pretty Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>]]></programlisting>
</example>
</section>
<section id="getstarted.prettyconfigxml">
<title>Create /WEB-INF/pretty-config.xml</title>
<para>
This is where you'll tell PrettyFaces what to do, which URLs to
rewrite. Each URL-mapping contained in the configuration must specify
a pattern and a viewId. The pattern specifies which inbound URL to
match, and the viewId specifies the location that URL should resolve
-be redirected- to.
</para>
<example>
<title>/WEB-INF/pretty-config.xml (You will need to customize this)</title>
<programlisting><![CDATA[<pretty-config xmlns="http://ocpsoft.com/prettyfaces/3.3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ocpsoft.com/prettyfaces/3.3.0
http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.0.xsd">
<!-- Begin Example RewriteRules
// These are custom rewrite-rules, and are probably not necessary for your application.
<rewrite match="^/old-url/(\w+)/$" substitute="/new_url/$1/" redirect="301" />
-->
<!-- Begin UrlMappings
// These are examples of URL mappings, and should be customized for your application.
<url-mapping id="home">
<pattern value="/" />
<view-id value="/faces/index.jsf" />
</url-mapping>
<url-mapping id="store">
<pattern value="/store/" />
<view-id value="/faces/shop/store.jsf" />
</url-mapping>
<url-mapping id="viewCategory">
<pattern value="/store/#{ cat : bean.category }/" />
<view-id value="/faces/shop/store.jsf" />
</url-mapping>
<url-mapping id="viewItem">
<pattern value="/store/#{ cat : bean.category }/#{ iid : bean.itemId }/" />
<view-id value="/faces/shop/item.jsf" />
<action>#{bean.loadItem}</action>
</url-mapping>
-->
</pretty-config>]]></programlisting>
</example>
<tip>
<para>
In JAR files, pretty-config.xml may also be placed in
/META-INF/pretty-config.xml - additionally, comma-separated
configuration file locations may be specified in web.xml, using the
servlet context-param configuration API:
<programlisting><![CDATA[<context-param>
<param-name>com.ocpsoft.pretty.CONFIG_FILES</param-name>
<param-value>/WEB-INF/custom-mappings.xml,/META-INF/another-config.xml</param-value>
</context-param>]]></programlisting>
</para>
</tip>
<para>
Congratulations! That's all you should have to do in order to use
PrettyFaces. The rest of this reference guide covers detailed
configuration options, framework integration with JavaServer Faces, and
special use-cases.
</para>
</section>
<section id="getstarted.dev_mode">
<title>PrettyFaces Development Mode</title>
<para>
During the development of your application you will typically have to make changes to your
<filename>pretty-config.xml</filename> very often. As server restarts take a lot of time and decrease productivity,
PrettyFaces is capable of reloading its configuration on a regular basis. As the configuration reloading
may be a time consuming process for large applications, PrettyFaces reloads its configuration only
if the application is executed in development mode.
</para>
<para>
To enable the development mode, add the following context parameter to your <filename>web.xml</filename>:
</para>
<programlisting><![CDATA[<context-param>
<param-name>com.ocpsoft.pretty.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>]]></programlisting>
<para>
If your are using the JSF 2.0 version of PrettyFaces, you typically won't have to explicitly enable
the development mode. In this case the development mode is automatically enabled for all project
stages except for <constant>Production</constant>.
</para>
</section>
</chapter>