Let FacesViews support MultiViews #20

Closed
BalusC opened this Issue Apr 17, 2014 · 1 comment

Projects

None yet

1 participant

@BalusC
Member
BalusC commented Apr 17, 2014

https://code.google.com/p/omnifaces/issues/detail?id=292

It would be useful if FacesViews supported the following:

  • /foo/bar is requested
  • /foo/bar.xhtml doesn't exist, but /foo.xhtml does
  • instead of 404, forward to /foo.xhtml, preferably with "/bar" as request.getPathInfo()

This rather useful feature is in Apache HTTPD+PHP world known as "MultiViews".

@BalusC
Member
BalusC commented Aug 14, 2016 edited

MultiViews support is added. It's basically a matter of suffixing the org.omnifaces.FACES_VIEWS_SCAN_PATHS value with /* like so

<context-param>
    <param-name>org.omnifaces.FACES_VIEWS_SCAN_PATHS</param-name>
    <param-value>/*.xhtml/*</param-value>
</context-param>

The path parameters are due to technical limitations unfortunately not available by request.getPathInfo() (as JSF itself internally uses it). But @Param has been enhanced to support injecting path parameters via new @Param(pathIndex) attribute.

Given an URL of http://example.com/context/foo/bar/baz on which neither /foo/bar/baz.xhtml nor /foo/bar.xhtml exist but /foo.xhtml does exist will forward to /foo.xhtml and path parameters are injectable in associated managed bean as below

@Inject @Param(pathIndex=0)
private String bar;

@Inject @Param(pathIndex=1)
private String baz;

@Param built-in conversion/validation is also supported on them.

@BalusC BalusC closed this Aug 14, 2016
@BalusC BalusC added a commit that referenced this issue Aug 14, 2016
@BalusC BalusC #20 fix javadoc error 5e2f04b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment