myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Charbel Abdul-Massih" <cabdulmas...@soundbite.com>
Subject RE: Simple <redirect/> appending jsf extension
Date Mon, 18 Dec 2006 20:56:22 GMT
Simon,

But I thought the whole point of the <redirect/> is to tell JSF that the
view-id is external...

Charbel

-----Original Message-----
From: Simon Kitching [mailto:simon.kitching@rhe.co.nz] 
Sent: Monday, December 18, 2006 3:50 PM
To: MyFaces Discussion
Subject: Re: Simple <redirect/> appending jsf extension

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

Mime
View raw message