myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject [myfaces-tobago] branch tobago-2.0.x updated: TOBAGO-1927: PageState width/height should be used for layout, if defined * Demo: example for multi-window support
Date Thu, 06 Sep 2018 15:05:11 GMT
This is an automated email from the ASF dual-hosted git repository.

lofwyr pushed a commit to branch tobago-2.0.x
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/tobago-2.0.x by this push:
     new 4884a36  TOBAGO-1927: PageState width/height should be used for layout, if defined
* Demo: example for multi-window support
4884a36 is described below

commit 4884a3686d802c80e15e92e71d907eccf6e9ccd8
Author: Udo Schnurpfeil <lofwyr@apache.org>
AuthorDate: Thu Sep 6 17:04:58 2018 +0200

    TOBAGO-1927: PageState width/height should be used for layout, if defined
    * Demo: example for multi-window support
---
 .../myfaces/tobago/example/demo/MultiWindow.java   | 25 ++++++++
 .../main/webapp/WEB-INF/tags/layout/overview.xhtml |  5 +-
 .../src/main/webapp/WEB-INF/web.xml                | 12 ++++
 .../content/95-multi-window/multi-window.xhtml     | 57 +++++++++++++++++++
 .../content/95-multi-window/x-multi-window.xhtml   | 66 ++++++++++++++++++++++
 5 files changed, 163 insertions(+), 2 deletions(-)

diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/MultiWindow.java
b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/MultiWindow.java
new file mode 100644
index 0000000..1729898
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/MultiWindow.java
@@ -0,0 +1,25 @@
+package org.apache.myfaces.tobago.example.demo;
+
+import org.apache.deltaspike.core.api.scope.WindowScoped;
+import org.apache.myfaces.tobago.model.PageState;
+
+import javax.inject.Named;
+import java.io.Serializable;
+
+/**
+ * Bean to store the browsers windows size for better multi-window support.
+ */
+@Named
+@WindowScoped
+public class MultiWindow implements Serializable {
+
+  private PageState state;
+
+  public PageState getState() {
+    return state;
+  }
+
+  public void setState(PageState state) {
+    this.state = state;
+  }
+}
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/tags/layout/overview.xhtml
b/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/tags/layout/overview.xhtml
index c8a25f7..9a1288f 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/tags/layout/overview.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/tags/layout/overview.xhtml
@@ -21,11 +21,12 @@
         xmlns:f="http://java.sun.com/jsf/core"
         xmlns:tc="http://myfaces.apache.org/tobago/component"
         xmlns:tx="http://myfaces.apache.org/tobago/extension"
-        xmlns:ui="http://java.sun.com/jsf/facelets">
+        xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core">
 
   <ui:insert name="metadata"/>
 
-  <tc:page applicationIcon="icon/favicon.ico" label="#{overviewBundle.pageTitle} - #{title}"
id="page">
+  <tc:page applicationIcon="icon/favicon.ico" label="#{overviewBundle.pageTitle} - #{title}"
id="page"
+           state="#{multiWindow.state}">
 
     <tc:script file="script/demo.js"/>
 
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml b/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml
index 44c606a..4a27572 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml
@@ -66,11 +66,23 @@
     <param-value>20</param-value>
   </context-param>
 
+  <!-- required for multi-window with MyFaces -->
   <context-param>
     <param-name>org.apache.myfaces.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION</param-name>
     <param-value>4</param-value>
   </context-param>
 
+  <!--
+  required for multi-window with WAS 8.5.5.x
+  this parameter fixes the problem
+  See: http://www-01.ibm.com/support/docview.wss?uid=swg1PI27290
+  But they don't tell, how the fix works
+   -->
+  <context-param>
+    <param-name>com.ibm.ws.jsf.enableRemoveRestoredViewState</param-name>
+    <param-value>true</param-value>
+  </context-param>
+
   <filter>
     <filter-name>multipartFormdataFilter</filter-name>
     <filter-class>org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter</filter-class>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/95-multi-window/multi-window.xhtml
b/tobago-example/tobago-example-demo/src/main/webapp/content/95-multi-window/multi-window.xhtml
new file mode 100644
index 0000000..8f70b22
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/95-multi-window/multi-window.xhtml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * 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.
+-->
+
+<ui:composition template="/WEB-INF/tags/layout/overview.xhtml"
+                xmlns:tc="http://myfaces.apache.org/tobago/component"
+                xmlns:tx="http://myfaces.apache.org/tobago/extension"
+                xmlns:ui="http://java.sun.com/jsf/facelets"
+                xmlns:f="http://java.sun.com/jsf/core">
+  <ui:param name="title" value="Multi-Window"/>
+
+  <tc:panel>
+    <tc:flowLayout>
+      <p>
+        This page opens a different window while loading.
+        The second window might be a status of a background process, but in this demo it
only show the server time.
+      </p>
+      <p>
+        In the basic configuration of JSF 2.0, there is a problem, with server site state
saving. If a number of
+        views reloaded in the 2nd window, the 1st window will lost it's view state and cannot
process a submit.
+      </p>
+      <p>
+        This will result in a ViewExpiredException.
+      </p>
+    </tc:flowLayout>
+
+
+    <tc:script onload="openMyPopup('#{request.contextPath}/faces/content/95-multi-window/x-multi-window.xhtml')">
+      /* <![CDATA[ */
+        var kalkFenster;
+
+        function openMyPopup(url) {
+            if (!kalkFenster || kalkFenster.closed) {
+                kalkFenster = window.open(url,'iOPCKalkStatus','width=320,height=200,left=22,top=220,resizable=1,location=0,directories=0,status=0,menubar=0,scrollbars=0,toolbar=0,dependent=1');
+            }
+        }
+    /* ]]> */
+    </tc:script>
+
+
+  </tc:panel>
+</ui:composition>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/95-multi-window/x-multi-window.xhtml
b/tobago-example/tobago-example-demo/src/main/webapp/content/95-multi-window/x-multi-window.xhtml
new file mode 100644
index 0000000..f57d93b
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/95-multi-window/x-multi-window.xhtml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * 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.
+-->
+
+<ui:composition template="/WEB-INF/tags/layout/plain.xhtml"
+                xmlns:tc="http://myfaces.apache.org/tobago/component"
+                xmlns:tx="http://myfaces.apache.org/tobago/extension"
+                xmlns:ui="http://java.sun.com/jsf/facelets"
+                xmlns:f="http://java.sun.com/jsf/core">
+  <ui:param name="title" value="Partial Update (AJAX)"/>
+  <tc:panel id="parent">
+    <f:facet name="layout">
+      <tc:gridLayout rows="200px" columns="640px"/>
+    </f:facet>
+    <!--
+        <tc:script>
+          setTimeout(function () { location.reload(true); }, 2000);
+        </tc:script>
+    -->
+
+    <f:facet name="reload">
+      <tc:reload frequency="1000"/>
+    </f:facet>
+
+    <tc:style file="content/50-partial/partial.css"/>
+
+    <tc:panel>
+      <f:facet name="layout">
+        <tc:gridLayout columns="1*;1*"/>
+      </f:facet>
+      <tc:box label="Left panel" id="left">
+        <f:facet name="layout">
+          <tc:gridLayout rows="auto;*"/>
+        </f:facet>
+        <tc:label value="Current seconds on server: "/>
+        <tc:out value="#{partialReloadController.currentDate}" markup="demoSeconds">
+          <f:convertDateTime pattern="ss:SSS"/>
+        </tc:out>
+      </tc:box>
+      <tc:box label="Right panel" id="right">
+        <f:facet name="layout">
+          <tc:gridLayout rows="auto;*"/>
+        </f:facet>
+        <tc:label value="Current seconds on server: "/>
+        <tc:out value="#{partialReloadController.currentDate}" markup="demoSeconds">
+          <f:convertDateTime pattern="ss:SSS"/>
+        </tc:out>
+      </tc:box>
+    </tc:panel>
+  </tc:panel>
+</ui:composition>


Mime
View raw message