You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by ta...@apache.org on 2014/04/15 19:48:03 UTC
git commit: DELTASPIKE-573 f:viewAction is executed twice with LAZY
window handling mode + playground example
Repository: deltaspike
Updated Branches:
refs/heads/master a4f426cc5 -> ae9314971
DELTASPIKE-573 f:viewAction is executed twice with LAZY window handling mode + playground example
Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/ae931497
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/ae931497
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/ae931497
Branch: refs/heads/master
Commit: ae9314971c5023c72d344c5ba7b3704c6b73c573
Parents: a4f426c
Author: tandraschko <ta...@apache.org>
Authored: Tue Apr 15 19:47:52 2014 +0200
Committer: tandraschko <ta...@apache.org>
Committed: Tue Apr 15 19:47:52 2014 +0200
----------------------------------------------------------------------
deltaspike/examples/jsf-playground/pom.xml | 8 ++-
.../windowhandling/ViewActionController.java | 47 ++++++++++++++
.../views/windowhandling/lazy/viewAction.xhtml | 68 ++++++++++++++++++++
.../resources/deltaspike/windowhandler.js | 23 ++++---
4 files changed, 136 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae931497/deltaspike/examples/jsf-playground/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/examples/jsf-playground/pom.xml b/deltaspike/examples/jsf-playground/pom.xml
index 9780e15..0aced0c 100644
--- a/deltaspike/examples/jsf-playground/pom.xml
+++ b/deltaspike/examples/jsf-playground/pom.xml
@@ -65,7 +65,6 @@
<configuration>
<tomeeVersion>${tomee.version}</tomeeVersion>
</configuration>
-
</plugin>
</plugins>
</build>
@@ -112,6 +111,13 @@
<build>
<finalName>ds</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.wildfly.plugins</groupId>
+ <artifactId>wildfly-maven-plugin</artifactId>
+ <version>1.0.1.Final</version>
+ </plugin>
+ </plugins>
</build>
</project>
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae931497/deltaspike/examples/jsf-playground/src/main/java/org/apache/deltaspike/playground/windowhandling/ViewActionController.java
----------------------------------------------------------------------
diff --git a/deltaspike/examples/jsf-playground/src/main/java/org/apache/deltaspike/playground/windowhandling/ViewActionController.java b/deltaspike/examples/jsf-playground/src/main/java/org/apache/deltaspike/playground/windowhandling/ViewActionController.java
new file mode 100644
index 0000000..b2e7fe8
--- /dev/null
+++ b/deltaspike/examples/jsf-playground/src/main/java/org/apache/deltaspike/playground/windowhandling/ViewActionController.java
@@ -0,0 +1,47 @@
+/*
+ * 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.deltaspike.playground.windowhandling;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.RequestScoped;
+import javax.faces.context.FacesContext;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.apache.deltaspike.jsf.spi.scope.window.ClientWindow;
+
+@Named
+@RequestScoped
+public class ViewActionController
+{
+
+ @Inject
+ private ClientWindow clientWindow;
+
+ @PostConstruct
+ public void init()
+ {
+ System.out.println("@PostConstruct ViewActionController");
+ }
+
+ public void action()
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+ System.out.println("ViewActionController#action with windowId: " + clientWindow.getWindowId(context));
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae931497/deltaspike/examples/jsf-playground/src/main/webapp/views/windowhandling/lazy/viewAction.xhtml
----------------------------------------------------------------------
diff --git a/deltaspike/examples/jsf-playground/src/main/webapp/views/windowhandling/lazy/viewAction.xhtml b/deltaspike/examples/jsf-playground/src/main/webapp/views/windowhandling/lazy/viewAction.xhtml
new file mode 100644
index 0000000..989892c
--- /dev/null
+++ b/deltaspike/examples/jsf-playground/src/main/webapp/views/windowhandling/lazy/viewAction.xhtml
@@ -0,0 +1,68 @@
+<?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.
+-->
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ds="http://deltaspike.apache.org/jsf">
+
+<h:head>
+ <title>DeltaSpike JSF Playground</title>
+</h:head>
+
+<f:metadata>
+ <f:viewAction action="#{viewActionController.action()}"/>
+</f:metadata>
+
+<h:body>
+ <h:form>
+ DS WindowId: #{dsWindowContext.currentWindowId}
+ <br />
+ <br />
+ <h:link value="GET Link" outcome="test.xhtml" />
+ <br />
+ <br />
+ <ds:disableClientWindow>
+ <h:link value="GET Link - surrounded by ds:disableClientWindow" outcome="test.xhtml" />
+ </ds:disableClientWindow>
+ <br />
+ <br />
+ <h:commandLink value="Postback">
+ </h:commandLink>
+ <br />
+ <br />
+ <h:commandLink value="Postback with outcome" action="test.xhtml?faces-redirect=true">
+ </h:commandLink>
+ <br />
+ <br />
+ <h:commandLink value="AJAX Postback">
+ <f:ajax render="@form" execute="@this" />
+ </h:commandLink>
+ <br />
+ <br />
+ <h:commandLink value="AJAX Postback with outcome" action="test.xhtml?faces-redirect=true">
+ <f:ajax render="@form" execute="@this" />
+ </h:commandLink>
+ </h:form>
+
+</h:body>
+
+</html>
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae931497/deltaspike/modules/jsf/impl/src/main/resources/META-INF/resources/deltaspike/windowhandler.js
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/resources/META-INF/resources/deltaspike/windowhandler.js b/deltaspike/modules/jsf/impl/src/main/resources/META-INF/resources/deltaspike/windowhandler.js
index 1db8673..01f1605 100644
--- a/deltaspike/modules/jsf/impl/src/main/resources/META-INF/resources/deltaspike/windowhandler.js
+++ b/deltaspike/modules/jsf/impl/src/main/resources/META-INF/resources/deltaspike/windowhandler.js
@@ -154,18 +154,23 @@ function setUrlParam(baseUrl, paramName, paramValue) {
}
// this method runs to ensure that windowIds get checked even if no windowhandler.html is used
function assertWindowId() {
- if (!window.name || window.name.length < 1) {
- window.name = 'tempWindowId';
- window.location = setUrlParam(window.location.href, 'dswid', null);
+ if (window.deltaspikeClientWindowRenderMode === 'CLIENTWINDOW') {
+ if (!window.name || window.name.length < 1) {
+ window.name = 'tempWindowId';
+ window.location = setUrlParam(window.location.href, 'dswid', null);
+ }
}
else if (window.deltaspikeClientWindowRenderMode === 'LAZY') {
- var dswid = getUrlParameter('dswid');
- if (window.name === 'tempWindowId') {
- window.name = dswid;
+ if (!window.name || window.name.length < 1) {
+ window.name = window.deltaspikeWindowId;
}
- else if (window.name !== dswid) {
- // redirect with current window.name / windowId
- window.location = setUrlParam(window.location.href, 'dswid', window.name);
+ else {
+ var dswid = getUrlParameter('dswid');
+
+ if (window.name !== dswid) {
+ // redirect with current window.name / windowId
+ window.location = setUrlParam(window.location.href, 'dswid', window.name);
+ }
}
}
}