You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by hn...@apache.org on 2018/08/02 07:32:09 UTC
[myfaces-tobago] branch master updated: fix testAll.xhtml and
testAccessAllPages.xhtml for tomcat
This is an automated email from the ASF dual-hosted git repository.
hnoeth 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 532ee17 fix testAll.xhtml and testAccessAllPages.xhtml for tomcat
532ee17 is described below
commit 532ee1775545fc742ff19c05b8a2621b5c676dda
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Thu Aug 2 09:32:02 2018 +0200
fix testAll.xhtml and testAccessAllPages.xhtml for tomcat
---
.../tobago/example/demo/TestController.java | 26 ++++++++++++++--------
.../src/main/webapp/testAccessAllPages.xhtml | 20 +++++++++--------
.../src/main/webapp/testAll.xhtml | 20 +++++++++--------
3 files changed, 39 insertions(+), 27 deletions(-)
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TestController.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TestController.java
index 8381f35..7f33dac 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TestController.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TestController.java
@@ -28,7 +28,9 @@ import javax.faces.context.FacesContext;
import javax.inject.Named;
import java.io.File;
import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
+import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
@@ -55,15 +57,18 @@ public class TestController implements Serializable {
return viewId.substring(1, viewId.length() - 6); //remove leading '/' and trailing '.xhtml'
}
- public List<TestPage> getAllTestPages() {
+ public List<TestPage> getAllTestPages() throws UnsupportedEncodingException {
final List<TestPage> pages = new ArrayList<>();
- final File rootDir = new File("src/main/webapp/content");
+ String realPath = FacesContext.getCurrentInstance().getExternalContext().getRealPath("/");
+ realPath = realPath.endsWith("/") ? realPath : realPath.concat("/");
+
+ final File rootDir = new File(realPath + "content");
if (rootDir.exists()) {
int idCount = 1;
for (final String page : getXHTMLs(rootDir)) {
- final String base = page.substring(16, page.length() - 6);
- pages.add(new TestPage("tp" + idCount++, base));
+ final String base = page.substring(realPath.length(), page.length() - ".xhtml".length());
+ pages.add(new TestPage("tp" + idCount++, URLEncoder.encode(base, "UTF-8")));
}
}
return pages;
@@ -82,15 +87,18 @@ public class TestController implements Serializable {
return xhtmls;
}
- public List<TestPage> getTestPages() {
+ public List<TestPage> getTestPages() throws UnsupportedEncodingException {
final List<TestPage> testPages = new ArrayList<>();
- int idCount = 1;
- final File rootDir = new File("src/main/webapp/content");
+ String realPath = FacesContext.getCurrentInstance().getExternalContext().getRealPath("/");
+ realPath = realPath.endsWith("/") ? realPath : realPath.concat("/");
+
+ final File rootDir = new File(realPath + "content");
if (rootDir.exists()) {
+ int idCount = 1;
for (final String testJs : getTestJs(rootDir)) {
- final String base = testJs.substring(16, testJs.length() - 8);
- testPages.add(new TestPage("tp" + idCount++, base));
+ final String base = testJs.substring(realPath.length(), testJs.length() - ".test.js".length());
+ testPages.add(new TestPage("tp" + idCount++, URLEncoder.encode(base, "UTF-8")));
}
}
return testPages;
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/testAccessAllPages.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/testAccessAllPages.xhtml
index 790cb93..87e5511 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/testAccessAllPages.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/testAccessAllPages.xhtml
@@ -25,14 +25,16 @@
<tc:style file="#{request.contextPath}/style/tobago.css"/>
<tc:script file="#{request.contextPath}/script/tobago-testAll.js"/>
- <c:forEach items="#{testController.allTestPages}" var="testPage">
- <div class="testframe-wrapper">
- <div>
- <tc:link label="open in new tab" link="test.xhtml?base=#{testPage.base}&accessTest=true" target="_blank"/>
+ <tc:panel rendered="#{facesContext.isProjectStage('Development')}">
+ <c:forEach items="#{testController.allTestPages}" var="testPage">
+ <div class="testframe-wrapper">
+ <div>
+ <tc:link label="open in new tab" link="test.xhtml?base=#{testPage.base}&accessTest=true" target="_blank"/>
+ </div>
+ <tc:object id="#{testPage.id}" name="test.xhtml?base=#{testPage.base}&accessTest=true">
+ <tc:style height="300px"/>
+ </tc:object>
</div>
- <tc:object id="#{testPage.id}" name="test.xhtml?base=#{testPage.base}&accessTest=true">
- <tc:style height="300px"/>
- </tc:object>
- </div>
- </c:forEach>
+ </c:forEach>
+ </tc:panel>
</ui:composition>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/testAll.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/testAll.xhtml
index 2b332da..3da2380 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/testAll.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/testAll.xhtml
@@ -25,14 +25,16 @@
<tc:style file="#{request.contextPath}/style/tobago.css"/>
<tc:script file="#{request.contextPath}/script/tobago-testAll.js"/>
- <c:forEach items="#{testController.testPages}" var="testPage">
- <div class="testframe-wrapper">
- <div>
- <tc:link label="open in new tab" outcome="/#{testPage.base}.xhtml" target="_blank"/>
+ <tc:panel rendered="#{facesContext.isProjectStage('Development')}">
+ <c:forEach items="#{testController.testPages}" var="testPage">
+ <div class="testframe-wrapper">
+ <div>
+ <tc:link label="open in new tab" outcome="/#{testPage.base}.xhtml" target="_blank"/>
+ </div>
+ <tc:object id="#{testPage.id}" name="test.xhtml?base=#{testPage.base}">
+ <tc:style height="300px" width="500px"/>
+ </tc:object>
</div>
- <tc:object id="#{testPage.id}" name="test.xhtml?base=#{testPage.base}">
- <tc:style height="300px" width="500px"/>
- </tc:object>
- </div>
- </c:forEach>
+ </c:forEach>
+ </tc:panel>
</ui:composition>