New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let FacesViews support MultiViews #20

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

Comments

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

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC Aug 14, 2016

Member

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.

Member

BalusC commented Aug 14, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment