You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Charbel Abdul-Massih <ca...@soundbite.com> on 2006/12/18 21:43:17 UTC

Simple appending jsf extension

I have a myfaces app running with Facelets...

 

In my web.xml, I set my javax.faces.DEFAULT_SUFFIX to .xhtml

 

When I try to have a redirect outside the JSF app like so

 

<navigation-case>

      <from-outcome>success</from-outcome>

      <to-view-id>/servlet/someservlet</to-view-id>

      <redirect/>

</navigation-case>

 

I end up with the page going to /servlet/someservlet.xhtml

 

.xhtml is being appending for every redirect...How can I turn that
off???

 

Thanks,
Charbel

 


Re: Simple appending jsf extension

Posted by Simon Kitching <si...@rhe.co.nz>.
Charbel Abdul-Massih wrote:
> I have a myfaces app running with Facelets…
> In my web.xml, I set my javax.faces.DEFAULT_SUFFIX to .xhtml
> When I try to have a redirect outside the JSF app like so
> <navigation-case>
>       <from-outcome>success</from-outcome>
>       <to-view-id>/servlet/someservlet</to-view-id>
>       <redirect/>
> </navigation-case>
> 
> I end up with the page going to /servlet/someservlet.xhtml
> .xhtml is being appending for every redirect…How can I turn that off???

I doubt that you can when using the navigation file. Note that the 
target is <to-view-id>, ie a VIEW name, not a URL. As you've told 
myfaces that all your VIEWs have the suffix ".xhtml" the current 
behaviour seems logical to me.

You could do this in your action method:

public String goToSomeServlet() {
   ExternalContext ec =
    FacesContext.getCurrentInstance()
     .getExternalContext();

   ec.redirect("/whatever/url/you/want");
   return null;
}


This bypasses normal JSF navigation, which seems reasonable as you are 
NOT doing normal JSF navigation here.

Regards,

Simon