Reputation: 606
In my web application I have a converter which converts from String to java.util.LinkedHashMap (and vice versa). When I try to use Prettyfaces I'm getting 404 resource not found errors. Here's my setup :
First of all according to this post, I tried decorating the converter with
@FacesConverter(forClass = LinkedHashMap.class)
I also tried adding
<converter>
<converter-for-class>java.util.LinkedHashMap</converter-for-class>
<converter-class>util.UrlConverter</converter-class>
</converter>
to my faces-config,xml.
Now the relevant code of my pretty-config.xml is :
<url-mapping id="details">
<pattern value="/dataset/#{id}" />
<view-id value="/faces/details.xhtml" />
</url-mapping>
The URL rewriting itself works so I end up at URL : http://server.com/appname/dataset//someID IMPORTANT : Here's what I think might be the problem : All my ID's start with a "/" so after the part "/dataset" there are always two "/". If this is the reason for my problem how can I rewrite these slashes then ?
Upvotes: 1
Views: 636
Reputation: 5668
I think that the /
character is really the cause of your problems. By default PrettyFaces uses the regular expression [^/]+
to match path parameters. So the mapping won't match if your path parameters contains /
characters.
You should use a custom regular expression for the path parameter like described here:
http://ocpsoft.org/docs/prettyfaces/3.3.3/en-US/html/Configuration.html#config.pathparams.regex
This means that something like this should work:
<url-mapping id="details">
<pattern value="/dataset/#{ /.+/ id }" />
<view-id value="/faces/details.xhtml" />
</url-mapping>
Another option would be to replace the /
character with something else in your converter.
Upvotes: 1