File tree Expand file tree Collapse file tree
config-prettyfaces-tests/src/test
java/org/ocpsoft/rewrite/prettyfaces/interaction
integration-faces/src/main/java/org/ocpsoft/rewrite/faces Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package org .ocpsoft .rewrite .prettyfaces .interaction ;
2+
3+ import org .ocpsoft .rewrite .faces .navigate .Navigate ;
4+
5+ import javax .enterprise .context .RequestScoped ;
6+ import javax .inject .Named ;
7+
8+ @ Named ("facesInteraction" )
9+ @ RequestScoped
10+ public class FacesNavigateInteractionBean
11+ {
12+
13+ public Navigate navigate ()
14+ {
15+ return Navigate .to ("/page.jsf" );
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ package org .ocpsoft .rewrite .prettyfaces .interaction ;
2+
3+ import com .gargoylesoftware .htmlunit .html .HtmlPage ;
4+ import org .jboss .arquillian .container .test .api .Deployment ;
5+ import org .jboss .arquillian .junit .Arquillian ;
6+ import org .jboss .shrinkwrap .api .spec .WebArchive ;
7+ import org .junit .Test ;
8+ import org .junit .runner .RunWith ;
9+ import org .ocpsoft .rewrite .prettyfaces .PrettyFacesTestBase ;
10+ import org .ocpsoft .rewrite .test .RewriteTestBase ;
11+
12+ import static org .junit .Assert .assertEquals ;
13+
14+ @ RunWith (Arquillian .class )
15+ public class FacesNavigateInteractionTest extends RewriteTestBase
16+ {
17+ @ Deployment (testable = false )
18+ public static WebArchive createDeployment ()
19+ {
20+ return PrettyFacesTestBase .getDeployment ()
21+ .addClass (FacesNavigateInteractionBean .class )
22+ .addAsWebResource ("interaction/faces-navigate-page.xhtml" , "page.xhtml" )
23+ .addAsWebInfResource ("interaction/faces-navigate-pretty-config.xml" , "pretty-config.xml" );
24+ }
25+
26+ @ Test
27+ public void testNavigate () throws Exception
28+ {
29+ HtmlPage firstPage = getWebClient ("/page" ).getPage ();
30+ HtmlPage secondPage = firstPage .getElementById ("navigate" ).click ();
31+ assertEquals (secondPage .getUrl ().getPath (), getContextPath () + "/page" );
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3+ < html xmlns ="http://www.w3.org/1999/xhtml "
4+ xmlns:f ="http://java.sun.com/jsf/core "
5+ xmlns:h ="http://java.sun.com/jsf/html "
6+ xmlns:pretty ="http://ocpsoft.com/prettyfaces "
7+ xmlns:ui ="http://java.sun.com/jsf/facelets ">
8+
9+ < head >
10+ < title > Navigate Test</ title >
11+ </ head >
12+
13+ < body >
14+
15+ < h1 > Navigate Test</ h1 >
16+
17+ < h:form prependId ="false ">
18+ < h:commandLink id ="navigate " action ="#{facesInteraction.navigate} " value ="navigate " />
19+ </ h:form >
20+
21+ </ body >
22+ </ html >
23+
Original file line number Diff line number Diff line change 1+ <pretty-config xmlns =" http://ocpsoft.com/prettyfaces/3.3.2" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
2+ xsi : schemaLocation =" http://ocpsoft.com/prettyfaces/3.3.2 http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.2.xsd" >
3+
4+ <!-- Simple URL mapping -->
5+ <url-mapping >
6+ <pattern value =" /page" ></pattern >
7+ <view-id >/page.jsf</view-id >
8+ </url-mapping >
9+
10+ </pretty-config >
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ else if (outcome != null && outcome.startsWith(REDIRECT_PREFIX)) {
155155 private String prependContextPath (ExternalContext externalContext , String url )
156156 {
157157 String contextPath = externalContext .getRequestContextPath ();
158- if ("/" .equals (contextPath )) {
158+ if ("/" .equals (contextPath ) || ( url . startsWith ( contextPath )) ) {
159159 return url ;
160160 }
161161 return contextPath + url ;
You can’t perform that action at this time.
0 commit comments