You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2018/04/18 12:30:59 UTC
[myfaces-tobago] branch master updated: Demo: using
?faces-redirect=true instead of a special NavigationHandler
This is an automated email from the ASF dual-hosted git repository.
lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/master by this push:
new e0052aa Demo: using ?faces-redirect=true instead of a special NavigationHandler
new 5463bc0 Merge remote-tracking branch 'origin/master'
e0052aa is described below
commit e0052aacae244baede5445a5c06e9e967697cfd3
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Wed Apr 18 13:49:59 2018 +0200
Demo: using ?faces-redirect=true instead of a special NavigationHandler
---
.../tobago/example/demo/ButtonLinkController.java | 4 +-
.../tobago/example/demo/ExecuteController.java | 4 +-
.../demo/PrettyUrlForMenuNavigationHandler.java | 60 ----------------------
.../demo/bestpractice/TransitionController.java | 2 +-
.../example/demo/nonfacesrequest/FishPond.java | 2 +-
.../src/main/webapp/WEB-INF/faces-config.xml | 3 --
.../23-transition/x-transition-after-sleep.xhtml | 2 +-
.../90-non-faces-request/x-fish-pond.xhtml | 3 +-
.../40-test/4000-button+link/button+link.xhtml | 8 +--
9 files changed, 11 insertions(+), 77 deletions(-)
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ButtonLinkController.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ButtonLinkController.java
index a06eea8..f6a77e1 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ButtonLinkController.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ButtonLinkController.java
@@ -32,12 +32,12 @@ public class ButtonLinkController implements Serializable {
public String linkToComponentsRoot() {
LOG.info("link to components root");
- return "/content/20-component/component.xhtml";
+ return "/content/20-component/component.xhtml?faces-redirect=true";
}
public String actionPage() {
LOG.info("link to action.xhtml");
- return "/content/40-test/4000-button+link/x-action.xhtml";
+ return "/content/40-test/4000-button+link/x-action.xhtml?faces-redirect=true";
}
public String targetActionPage() {
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ExecuteController.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ExecuteController.java
index 4856fda..7cccca1 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ExecuteController.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ExecuteController.java
@@ -44,13 +44,13 @@ public class ExecuteController implements Serializable {
value3=null;
value4=null;
log();
- return "/content/40-test/50000-java/20-ajax-execute/ajax-execute.xhtml";
+ return "/content/40-test/50000-java/20-ajax-execute/ajax-execute.xhtml?faces-redirect=true";
}
public String reload() {
LOG.info("reload");
log();
- return "/content/40-test/50000-java/20-ajax-execute/ajax-execute.xhtml";
+ return "/content/40-test/50000-java/20-ajax-execute/ajax-execute.xhtml?faces-redirect=true";
}
public String action() {
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/PrettyUrlForMenuNavigationHandler.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/PrettyUrlForMenuNavigationHandler.java
deleted file mode 100644
index 7d6af6a..0000000
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/PrettyUrlForMenuNavigationHandler.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.tobago.example.demo;
-
-import org.apache.commons.lang3.StringUtils;
-
-import javax.faces.application.NavigationHandler;
-import javax.faces.application.ViewHandler;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import java.io.IOException;
-import java.util.Collections;
-
-public class PrettyUrlForMenuNavigationHandler extends NavigationHandler {
-
- private NavigationHandler navigationHandler;
-
- public PrettyUrlForMenuNavigationHandler(final NavigationHandler navigationHandler) {
- this.navigationHandler = navigationHandler;
- }
-
- @Override
- public void handleNavigation(final FacesContext facesContext, final String fromAction, final String outcome) {
-
- if (StringUtils.startsWith(outcome, "/content/")) {
- final ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
- final UIViewRoot viewRoot = viewHandler.createView(facesContext, outcome);
- facesContext.setViewRoot(viewRoot);
- final ExternalContext externalContext = facesContext.getExternalContext();
- try {
- externalContext.redirect(
- externalContext.encodeRedirectURL(externalContext.getRequestContextPath() + outcome,
- Collections.emptyMap()));
- } catch (final IOException e) {
- // not nice?
- facesContext.renderResponse();
- }
- } else {
- navigationHandler.handleNavigation(facesContext, fromAction, outcome);
- }
- }
-}
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/bestpractice/TransitionController.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/bestpractice/TransitionController.java
index bac766f..80b98f9 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/bestpractice/TransitionController.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/bestpractice/TransitionController.java
@@ -36,7 +36,7 @@ public class TransitionController {
LOG.info("Waiting " + sleep + " millis.");
Thread.sleep(sleep);
- return "/content/30-concept/23-transition/x-transition-after-sleep.xhtml";
+ return "/content/30-concept/23-transition/x-transition-after-sleep.xhtml?faces-redirect=true";
}
public String sleep5s() throws InterruptedException {
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/nonfacesrequest/FishPond.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/nonfacesrequest/FishPond.java
index 9c6fdba..fcb4538 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/nonfacesrequest/FishPond.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/nonfacesrequest/FishPond.java
@@ -65,7 +65,7 @@ public class FishPond implements Serializable {
public String select(final Integer fishId) {
selectedFishId = fishId;
LOG.info("select via id: '" + getSelectedFish() + "'");
- return "/content/90-non-faces-request/x-fish-pond.xhtml";
+ return "/content/90-non-faces-request/x-fish-pond.xhtml?faces-redirect=true";
}
public String getSelectedFish() {
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/faces-config.xml b/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/faces-config.xml
index bdc31fd..e9c2a94 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/faces-config.xml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/faces-config.xml
@@ -24,9 +24,6 @@
version="2.0">
<application>
- <navigation-handler>
- org.apache.myfaces.tobago.example.demo.PrettyUrlForMenuNavigationHandler
- </navigation-handler>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>en_US</supported-locale>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/23-transition/x-transition-after-sleep.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/23-transition/x-transition-after-sleep.xhtml
index ce2d03c..79b0a97 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/23-transition/x-transition-after-sleep.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/23-transition/x-transition-after-sleep.xhtml
@@ -22,6 +22,6 @@
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:param name="title" value="Transition after sleep"/>
- <tc:button label="Back" action="/content/30-concept/23-transition/transition.xhtml"/>
+ <tc:button label="Back" outcome="/content/30-concept/23-transition/transition.xhtml"/>
</ui:composition>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/90-non-faces-request/x-fish-pond.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/90-non-faces-request/x-fish-pond.xhtml
index fcf16e4..035bd10 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/90-non-faces-request/x-fish-pond.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/90-non-faces-request/x-fish-pond.xhtml
@@ -38,7 +38,8 @@
<tc:button label="random" action="#{fishPond.random}">
<f:ajax render="pond :page:header:headerInfo" execute="pond"/>
</tc:button>
- <tc:button label="back to start" action="/content/30-concept/90-non-faces-request/non-faces-request.xhtml"/>
+ <tc:button label="back to start"
+ action="/content/30-concept/90-non-faces-request/non-faces-request.xhtml?faces-redirect=true"/>
</tc:buttons>
</tc:panel>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/4000-button+link/button+link.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/4000-button+link/button+link.xhtml
index 2be73d3..90b52b3 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/4000-button+link/button+link.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/4000-button+link/button+link.xhtml
@@ -31,8 +31,6 @@
<tc:link id="standardLinkAction" label="Action" action="#{buttonLinkController.actionPage}"/>
<tc:link id="standardLinkLink" label="Link" outcome="/content/40-test/4000-button+link/x-link.xhtml"/>
</tc:links>
- <br/>
- <br/>
</tc:section>
<tc:section label="Confirmation">
@@ -48,8 +46,6 @@
<tc:link id="confirmationLinkLink" label="Link" outcome="/content/40-test/4000-button+link/x-link.xhtml"
confirmation="Are you sure?"/>
</tc:links>
- <br/>
- <br/>
</tc:section>
<tc:section label="Target">
@@ -65,11 +61,11 @@
<tc:link id="targetLinkLink" label="Link" outcome="/content/40-test/4000-button+link/x-targetLink.html"
target="targetFrame"/>
</tc:links>
- <br/>
- <br/>
+ <tc:box label="iframe">
<tc:object id="targetFrame" name="targetFrame">
<tc:style width="100%" height="150px"/>
</tc:object>
+ </tc:box>
</tc:section>
<tc:section label="JavaScript">
--
To stop receiving notification emails like this one, please contact
lofwyr@apache.org.