Dimman
Dimman

Reputation: 1206

Issue with PrettyFaces 3.32 / JSF 2 / Servlet 3.0

I have an issue. It looks like PrettyFaces is overriding my webservlet url pattern.

Part of my pretty-config.xml

<url-mapping id="searchClassifiedAdsBeanRewrite">
     <pattern value="/#{prefixDummy}/#{region:searchBean.region}/#{category:searchBean.category}" />
     <view-id value="/searchClassifiedAds.html" />
</url-mapping>

My servlet urlPattern follows

@WebServlet(urlPatterns = {"/images/*", "/images/temp/*"})

Now every time i have url that applies to my pretty faces definition my webservlet urlpattern is never invoked. Not the first one or the second url pattern.

If i dont have a pretty faces match then everything works. (even if i change the #{prefixDummy} and hard code it will not work.

I'm using a file servlet (Actually its an example from BalusC) in order to display dynamic images!

Any help appreciated, Thanks

Upvotes: 0

Views: 359

Answers (1)

Lincoln
Lincoln

Reputation: 3191

The PrettyFaces support forum is probably the place where you want to start for this question: http://ocpsoft.org/support/forum/prettyfaces-users

But since you asked here :) basically what you are seeing is expected behavior. PrettyFaces will match ANY inbound Servlet request, forward, error, or include matching the given pattern. And if your image URL happens to match that pattern, then those will be matched by your Pretty URL mapping just like any other URL.

You need to more closely restrict the pattern so that it does not conflict with your other URLs.

This will be easier to address in PrettyFaces 4 when the Rewrite core framework (http://ocpsoft.org/rewrite/) is included. You will be able to match a URL while excluding URLs that are mapped by an existing Servlet.)

This is already possible in rewrite:

ConfigurationProvider.begin()
.addRule(Join.path("/{prefixDummy}/{region}/{category}").to()
         .when(Not.any(ServletMapping.includes("/{prefixDummy}/{region}/{category}")))
         .where("region").bindsTo(PhaseBinding.to(El.parameter("searchBean.region")))
         .where("category").bindsTo(PhaseBinding.to(El.parameter("searchBean.category"))))

Notice the negative constraint: ServletMapping.includes("/{prefixDummy}/{region}/{category}") which prevents the rule from matching when a Servlet in the container could otherwise handle the request.

Upvotes: 1

Related Questions