@@ -3,11 +3,16 @@ Christian Kaltepoth
33:description: This guide described the process of migrating existing PrettyFaces applications to Rewrite
44:keywords: PrettyFaces, Rewrite, Migration
55:toc:
6+ :toclevels: 4
67
7- == PrettyFaces 3.x Migration Guide
8+ = PrettyFaces 3.x Migration Guide
89
910This guide describes how to migrate existing applications built using PrettyFaces 3.x to Rewrite 2.0.
1011
12+ toc::[]
13+
14+ == Migration strategies
15+
1116There are basically two ways of migrating such applications to Rewrite:
1217
1318PrettyFaces compatibility module:: This Rewrite module allows you to keep your old PrettyFace 3.x
@@ -24,11 +29,11 @@ NOTE: Both ways of migrating will only work for JSF 2.x applications.
2429
2530The following sections will describe both ways in detail.
2631
27- === PrettyFaces compatibility module
32+ == PrettyFaces compatibility module
2833
2934Migrating application using PrettyFaces 3.x is very easy. Just follow the steps described below.
3035
31- ==== Update your dependencies
36+ === Update your dependencies
3237
3338First you have to remove the old `com.ocpsoft.prettyfaces` dependency from your project. Open
3439your +pom.xml+ and remove the following entry:
@@ -61,7 +66,7 @@ Now add the Rewrite servlet and the PrettyFaces compatibility module to your +po
6166Your code should still compile fine after updating the dependencies.
6267
6368
64- ==== Filter registration
69+ === Filter registration
6570
6671If you used PrettyFaces in a Servlet 3.0 environment, the required servlet filter is automatically
6772registered. In this case you typically don't have an entry for the +PrettyFilter+ in your +web.xml+
@@ -112,18 +117,18 @@ NOTE: Please not that if you are using a Servlet 3.x container and your +web.xml
112117+metadata-complete="true"+, you don't have to register the Rewrite filter manually, because
113118this is done automatically. In this case just make sure to remove the old +PrettyFilter+ entry.
114119
115- ==== Test your application
120+ === Test your application
116121
117122After having performed the changes described in the two sections, your migration is complete.
118123Although we consider the compatibility module to be very solid and stable, you should test your
119124application carefully. If something doesn't work as before, let us know. :)
120125
121- === JSF integration module
126+ == JSF integration module
122127
123128This section describes how to migrate existing PrettyFaces configuration to the Rewrite
124129JSF integration module.
125130
126- ==== Adding the Rewrite dependencies
131+ === Adding the Rewrite dependencies
127132
128133If you want to use the Rewrite JSF integration module, you have to add the following dependencies
129134to your project.
@@ -153,7 +158,7 @@ to your project.
153158Adding the dependencies in a Servlet 3.0 environment will automatically register the required
154159Servlet listeners and filters.
155160
156- ==== PrettyFaces XML configuration
161+ === PrettyFaces XML configuration
157162
158163PrettyFaces used an XML file called +pretty-config.xml+ to configure URL mappings and rewrite rules.
159164Rewrite uses a fluent Java API for configuration instead. XML files are not supported any more.
@@ -179,7 +184,7 @@ public class MyConfigurationProvider extends HttpConfigurationProvider {
179184}
180185----
181186
182- ===== URL Mappings
187+ ==== URL Mappings
183188
184189The URL mappings of PrettyFaces have been replace with a Rewrite rule called +Join+.
185190The concepts are very similar. You can specify a _virtual path_ that is mapped to a
@@ -209,7 +214,7 @@ public Configuration getConfiguration(ServletContext context) {
209214}
210215|===
211216
212- ===== Path Parameters
217+ ==== Path Parameters
213218
214219Path parameters are dynamic parts of an URL which you typically use to embed details about an addressed
215220resource. With PrettyFaces you had to use EL-like expressions in the pattern part of the mapping to
@@ -286,7 +291,7 @@ You have to write:
286291.bindsTo(PhaseBinding.to(El.property("bean.category"))).after(PhaseId.RESTORE_VIEW))
287292----
288293
289- ===== Page actions
294+ ==== Page actions
290295
291296PrettyFaces allowed the user to specify a _page action_ which is invoked when a request
292297for the mapping is received.
@@ -341,9 +346,9 @@ You have to write:
341346
342347
343348
344- ==== PrettyFaces Annotations
349+ === PrettyFaces Annotations
345350
346- ===== URL Mappings
351+ ==== URL Mappings
347352
348353As the URL mappings of PrettyFaces have been replaced with +Join+, the replacement
349354for the +@URLMapping+ annotation is called +@Join+.
@@ -367,7 +372,7 @@ public class CustomerDetailsBean {
367372}
368373|===
369374
370- ===== Path parameters
375+ ==== Path parameters
371376
372377With PrettyFaces, path parameters were specified using EL-like expressions in the pattern.
373378With Rewrite you simply specify the parameter in the path pattern using +\{name\}+. Rewrite
@@ -432,7 +437,7 @@ public class CustomerDetailsBean {
432437|===
433438
434439
435- ===== Query parameters
440+ ==== Query parameters
436441
437442Query parameters in Rewrite are handled the same way as path parameters. To inject the value
438443of a query parameter into your bean, add a +@Parameter+ to a field like this.
@@ -466,7 +471,7 @@ TIP: You can omit the parameter name when using the +@Parameter+ annotation if t
466471 parameter is the same as the name of the field.
467472
468473
469- ===== Page actions
474+ ==== Page actions
470475
471476
472477To invoke a specific method in your bean when the page is accessed, add a +@RequestAction+ annotation
@@ -563,7 +568,7 @@ public class CustomerDetailsBean {
563568}
564569|===
565570
566- ===== Creating links
571+ === Creating links
567572
568573PrettyFaces shipped with a special JSF component that simplified creating links to mapped URLs.
569574However JSF 2.0 introduced +<h:link>+, which works fine for creating such links. Rewrite doesn't
@@ -594,7 +599,7 @@ set their value using +<f:param>+.
594599|===
595600
596601
597- ===== Programmatic navigation
602+ === Programmatic navigation
598603
599604Programmatic navigation was very painful in PrettyFaces. To navigate to a page with path or
600605query parameters, you had to obtain a reference to the bean which the parameters were bound
0 commit comments