You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by mraible <ma...@raibledesigns.com> on 2011/01/27 05:51:40 UTC

Is it possible to do extensionless URLs with JSF?

I'm trying to integrate extensionless URLs in my app using the
UrlRewriteFilter. I'm using a technique similar to the one expressed in the
following blog post:

http://raibledesigns.com/rd/entry/extensionless_urls_in_java_web

However, I'm using path-mapping instead of suffix-mapping, but can't get it
to work. In web.xml, I have:

    <servlet-mapping>
        <servlet-name>faces</servlet-name>
        <url-pattern>/app/*</url-pattern>
    </servlet-mapping>

In my urlrewrite.xml, I have:

    <!-- Add rules here for anything that shouldn't be served up by JSF. -->
    <rule>
        <from>/</from>
        <to type="redirect" last="true">mainMenu</to>
    </rule>
    <rule>
        <from>/app/mainMenu</from>
        <to last="true" type="redirect">../mainMenu</to>
    </rule>
    <rule>
        <from>/j_security_check</from>
        <to>/j_security_check</to>
    </rule>
    <rule>
        <from>/common/**</from>
        <to>/common/$1</to>
    </rule>
    <rule>
        <from>/images/**</from>
        <to>/images/$1</to>
    </rule>
    <rule>
        <from>/scripts/**</from>
        <to>/scripts/$1</to>
    </rule>
    <rule>
        <from>/styles/**</from>
        <to>/styles/$1</to>
    </rule>
    <rule>
        <from>/crossdomain.xml</from>
        <to>/crossdomain.xml</to>
    </rule>
    <rule>
        <from>/favicon.ico</from>
        <to>/favicon.ico</to>
    </rule>
    <rule>
        <from>/login*</from>
        <to>/login.jsp</to>
    </rule>
    <rule>
        <from>/logout*</from>
        <to>/logout.jsp</to>
    </rule>

    <!-- JSF -->
    <rule>
        <from>/**</from>
        <to>/app/$1</to>
    </rule>
    <outbound-rule>
        <from>/app/**</from>
        <to>/$1</to>
    </outbound-rule>

Is it possible to get extensionless URLs work in a JSF app? I'm using 2.0.3
When I use the configuration above, nothing happens, I just get 404 errors.
My faces-config.xml references navigation rules like the following:

    <navigation-rule>
        <from-view-id>/mainMenu.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>ajax4jsf</from-outcome>
            <to-view-id>/ajax4jsf.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>
    <navigation-rule>
        <from-view-id>/mainMenu.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>selectFile</from-outcome>
            <to-view-id>/selectFile.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>

Any help would be great.

Thanks,

Matt
-- 
View this message in context: http://old.nabble.com/Is-it-possible-to-do-extensionless-URLs-with-JSF--tp30774240p30774240.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Is it possible to do extensionless URLs with JSF?

Posted by Bruno Aranda <br...@gmail.com>.
Yes, I use PrettyFaces for this as well. Works like a charm, except when
using with MyFaces Orchestra. The bug has been fixed in the trunk, so
Orchestra 1.5-SNAPSHOT should be fine,

Cheers,

Bruno

On 27 January 2011 05:25, Matthias Wessendorf <ma...@apache.org> wrote:

> Use PrettyFaces
>
> On Thursday, January 27, 2011, mraible <ma...@raibledesigns.com> wrote:
> >
> > I'm trying to integrate extensionless URLs in my app using the
> > UrlRewriteFilter. I'm using a technique similar to the one expressed in
> the
> > following blog post:
> >
> > http://raibledesigns.com/rd/entry/extensionless_urls_in_java_web
> >
> > However, I'm using path-mapping instead of suffix-mapping, but can't get
> it
> > to work. In web.xml, I have:
> >
> >     <servlet-mapping>
> >         <servlet-name>faces</servlet-name>
> >         <url-pattern>/app/*</url-pattern>
> >     </servlet-mapping>
> >
> > In my urlrewrite.xml, I have:
> >
> >     <!-- Add rules here for anything that shouldn't be served up by JSF.
> -->
> >     <rule>
> >         <from>/</from>
> >         <to type="redirect" last="true">mainMenu</to>
> >     </rule>
> >     <rule>
> >         <from>/app/mainMenu</from>
> >         <to last="true" type="redirect">../mainMenu</to>
> >     </rule>
> >     <rule>
> >         <from>/j_security_check</from>
> >         <to>/j_security_check</to>
> >     </rule>
> >     <rule>
> >         <from>/common/**</from>
> >         <to>/common/$1</to>
> >     </rule>
> >     <rule>
> >         <from>/images/**</from>
> >         <to>/images/$1</to>
> >     </rule>
> >     <rule>
> >         <from>/scripts/**</from>
> >         <to>/scripts/$1</to>
> >     </rule>
> >     <rule>
> >         <from>/styles/**</from>
> >         <to>/styles/$1</to>
> >     </rule>
> >     <rule>
> >         <from>/crossdomain.xml</from>
> >         <to>/crossdomain.xml</to>
> >     </rule>
> >     <rule>
> >         <from>/favicon.ico</from>
> >         <to>/favicon.ico</to>
> >     </rule>
> >     <rule>
> >         <from>/login*</from>
> >         <to>/login.jsp</to>
> >     </rule>
> >     <rule>
> >         <from>/logout*</from>
> >         <to>/logout.jsp</to>
> >     </rule>
> >
> >     <!-- JSF -->
> >     <rule>
> >         <from>/**</from>
> >         <to>/app/$1</to>
> >     </rule>
> >     <outbound-rule>
> >         <from>/app/**</from>
> >         <to>/$1</to>
> >     </outbound-rule>
> >
> > Is it possible to get extensionless URLs work in a JSF app? I'm using
> 2.0.3
> > When I use the configuration above, nothing happens, I just get 404
> errors.
> > My faces-config.xml references navigation rules like the following:
> >
> >     <navigation-rule>
> >         <from-view-id>/mainMenu.xhtml</from-view-id>
> >         <navigation-case>
> >             <from-outcome>ajax4jsf</from-outcome>
> >             <to-view-id>/ajax4jsf.xhtml</to-view-id>
> >         </navigation-case>
> >     </navigation-rule>
> >     <navigation-rule>
> >         <from-view-id>/mainMenu.xhtml</from-view-id>
> >         <navigation-case>
> >             <from-outcome>selectFile</from-outcome>
> >             <to-view-id>/selectFile.xhtml</to-view-id>
> >         </navigation-case>
> >     </navigation-rule>
> >
> > Any help would be great.
> >
> > Thanks,
> >
> > Matt
> > --
> > View this message in context:
> http://old.nabble.com/Is-it-possible-to-do-extensionless-URLs-with-JSF--tp30774240p30774240.html
> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >
> >
>
> --
> Matthias Wessendorf
>
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> twitter: http://twitter.com/mwessendorf
>

Re: Is it possible to do extensionless URLs with JSF?

Posted by Matthias Wessendorf <ma...@apache.org>.
Use PrettyFaces

On Thursday, January 27, 2011, mraible <ma...@raibledesigns.com> wrote:
>
> I'm trying to integrate extensionless URLs in my app using the
> UrlRewriteFilter. I'm using a technique similar to the one expressed in the
> following blog post:
>
> http://raibledesigns.com/rd/entry/extensionless_urls_in_java_web
>
> However, I'm using path-mapping instead of suffix-mapping, but can't get it
> to work. In web.xml, I have:
>
>     <servlet-mapping>
>         <servlet-name>faces</servlet-name>
>         <url-pattern>/app/*</url-pattern>
>     </servlet-mapping>
>
> In my urlrewrite.xml, I have:
>
>     <!-- Add rules here for anything that shouldn't be served up by JSF. -->
>     <rule>
>         <from>/</from>
>         <to type="redirect" last="true">mainMenu</to>
>     </rule>
>     <rule>
>         <from>/app/mainMenu</from>
>         <to last="true" type="redirect">../mainMenu</to>
>     </rule>
>     <rule>
>         <from>/j_security_check</from>
>         <to>/j_security_check</to>
>     </rule>
>     <rule>
>         <from>/common/**</from>
>         <to>/common/$1</to>
>     </rule>
>     <rule>
>         <from>/images/**</from>
>         <to>/images/$1</to>
>     </rule>
>     <rule>
>         <from>/scripts/**</from>
>         <to>/scripts/$1</to>
>     </rule>
>     <rule>
>         <from>/styles/**</from>
>         <to>/styles/$1</to>
>     </rule>
>     <rule>
>         <from>/crossdomain.xml</from>
>         <to>/crossdomain.xml</to>
>     </rule>
>     <rule>
>         <from>/favicon.ico</from>
>         <to>/favicon.ico</to>
>     </rule>
>     <rule>
>         <from>/login*</from>
>         <to>/login.jsp</to>
>     </rule>
>     <rule>
>         <from>/logout*</from>
>         <to>/logout.jsp</to>
>     </rule>
>
>     <!-- JSF -->
>     <rule>
>         <from>/**</from>
>         <to>/app/$1</to>
>     </rule>
>     <outbound-rule>
>         <from>/app/**</from>
>         <to>/$1</to>
>     </outbound-rule>
>
> Is it possible to get extensionless URLs work in a JSF app? I'm using 2.0.3
> When I use the configuration above, nothing happens, I just get 404 errors.
> My faces-config.xml references navigation rules like the following:
>
>     <navigation-rule>
>         <from-view-id>/mainMenu.xhtml</from-view-id>
>         <navigation-case>
>             <from-outcome>ajax4jsf</from-outcome>
>             <to-view-id>/ajax4jsf.xhtml</to-view-id>
>         </navigation-case>
>     </navigation-rule>
>     <navigation-rule>
>         <from-view-id>/mainMenu.xhtml</from-view-id>
>         <navigation-case>
>             <from-outcome>selectFile</from-outcome>
>             <to-view-id>/selectFile.xhtml</to-view-id>
>         </navigation-case>
>     </navigation-rule>
>
> Any help would be great.
>
> Thanks,
>
> Matt
> --
> View this message in context: http://old.nabble.com/Is-it-possible-to-do-extensionless-URLs-with-JSF--tp30774240p30774240.html
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

-- 
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf