You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2013/10/22 18:55:09 UTC

svn commit: r1534701 - in /myfaces/current20/test-webapp/webapp: ./ src/main/java/org/apache/myfaces/flash/ src/main/webapp/

Author: lu4242
Date: Tue Oct 22 16:55:09 2013
New Revision: 1534701

URL: http://svn.apache.org/r1534701
Log:
MYFACES-3752 Flash.setKeepMessages(true) does not work with immediate-Commandbutton (add flash tests for keep on immediate)

Added:
    myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep4.xhtml
      - copied, changed from r1533296, myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep1.xhtml
    myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep4_1.xhtml
      - copied, changed from r1533296, myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep2.xhtml
    myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep4_2.xhtml
      - copied, changed from r1533296, myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep3.xhtml
Modified:
    myfaces/current20/test-webapp/webapp/pom.xml
    myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/flash/HelloWorldFlashBean.java
    myfaces/current20/test-webapp/webapp/src/main/webapp/home.xhtml

Modified: myfaces/current20/test-webapp/webapp/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/pom.xml?rev=1534701&r1=1534700&r2=1534701&view=diff
==============================================================================
--- myfaces/current20/test-webapp/webapp/pom.xml (original)
+++ myfaces/current20/test-webapp/webapp/pom.xml Tue Oct 22 16:55:09 2013
@@ -367,7 +367,7 @@
     <properties>
         <!-- 2.0.3-20100630 -->
         <jsf-ri.version>2.0.6</jsf-ri.version>
-        <jsf-myfaces.version>2.0.12</jsf-myfaces.version>
+        <jsf-myfaces.version>2.1.13-SNAPSHOT</jsf-myfaces.version>
         <maven.jetty.plugin.version>6.1.16</maven.jetty.plugin.version>
         <log4j.version>1.2.13</log4j.version>
         <cargo.version>1.0</cargo.version>

Modified: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/flash/HelloWorldFlashBean.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/flash/HelloWorldFlashBean.java?rev=1534701&r1=1534700&r2=1534701&view=diff
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/flash/HelloWorldFlashBean.java (original)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/flash/HelloWorldFlashBean.java Tue Oct 22 16:55:09 2013
@@ -19,6 +19,7 @@
 package org.apache.myfaces.flash;
 
 import javax.faces.application.FacesMessage;
+import javax.faces.component.UIInput;
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.faces.context.Flash;
@@ -125,6 +126,26 @@ public class HelloWorldFlashBean {
         return "flashKeep2.xhtml?faces-redirect=true";
     }
     
+    public String keepMessageRedirect()
+    {
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+        ExternalContext externalContext = facesContext.getExternalContext();
+        Flash flash = externalContext.getFlash();
+        
+        // If this is called using an immediate button, getName() is null,
+        // so in this case we are going to take the value from the button.
+        
+        UIInput input = (UIInput) facesContext.getViewRoot().findComponent("mainForm:name");
+        
+        flash.putNow("name", input.getSubmittedValue() != null ? 
+            input.getSubmittedValue() : getName());
+        flash.keep("name");
+        
+        facesContext.addMessage(null, new FacesMessage("This message should be keep"));
+        flash.setKeepMessages(true);
+        return "flashKeep4_1.xhtml?faces-redirect=true";
+    }
+    
     public String keepPostback()
     {
         FacesContext facesContext = FacesContext.getCurrentInstance();
@@ -135,6 +156,18 @@ public class HelloWorldFlashBean {
         
         return "flashKeep3.xhtml";
     }
+    
+    public String keepPostbackMessaged()
+    {
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+        ExternalContext externalContext = facesContext.getExternalContext();
+        Flash flash = externalContext.getFlash();
+        
+        flash.keep("name"); // does not work here anymore
+        flash.setKeepMessages(true);
+        
+        return "flashKeep4_2.xhtml";
+    }
 
     
     public String back(){

Copied: myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep4.xhtml (from r1533296, myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep1.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep4.xhtml?p2=myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep4.xhtml&p1=myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep1.xhtml&r1=1533296&r2=1534701&rev=1534701&view=diff
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep1.xhtml (original)
+++ myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep4.xhtml Tue Oct 22 16:55:09 2013
@@ -34,8 +34,10 @@
 		    <h:outputLabel value="Name" for="name" />
 		    <h:inputText id="name" value="#{helloWorldFlashBean.name}" />
 		</h:panelGrid>
-		<h:commandButton action="#{helloWorldFlashBean.keepRedirect}" 
-		        value="Keep over Redirect" />
+		<h:commandButton action="#{helloWorldFlashBean.keepMessageRedirect}" 
+		        value="Keep over Redirect (normal)" />
+		<h:commandButton action="#{helloWorldFlashBean.keepMessageRedirect}" 
+                value="Keep over Redirect (immediate)" immediate="true"/>
 	</h:form>
 </h:body>
 </html>

Copied: myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep4_1.xhtml (from r1533296, myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep2.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep4_1.xhtml?p2=myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep4_1.xhtml&p1=myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep2.xhtml&r1=1533296&r2=1534701&rev=1534701&view=diff
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep2.xhtml (original)
+++ myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep4_1.xhtml Tue Oct 22 16:55:09 2013
@@ -23,6 +23,9 @@
 	xmlns:h="http://java.sun.com/jsf/html"
 	xmlns:f="http://java.sun.com/jsf/core"
 	xmlns:c="http://java.sun.com/jsp/jstl/core">
+<f:metadata>
+    <f:viewParam name="id"/>
+</f:metadata>
 <h:head>
 </h:head>
 <h:body>
@@ -32,7 +35,8 @@
 		<h3><h:outputText value="Flash Keep" /></h3>
 		
 		Your name is: #{flash.name} <br/>
-		<h:commandButton action="#{helloWorldFlashBean.keepPostback}" 
+        <h:messages/>
+		<h:commandButton action="#{helloWorldFlashBean.keepPostbackMessaged}" 
 		        value="Do another postback" />
 	</h:form>
 </h:body>

Copied: myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep4_2.xhtml (from r1533296, myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep3.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep4_2.xhtml?p2=myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep4_2.xhtml&p1=myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep3.xhtml&r1=1533296&r2=1534701&rev=1534701&view=diff
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep3.xhtml (original)
+++ myfaces/current20/test-webapp/webapp/src/main/webapp/flashKeep4_2.xhtml Tue Oct 22 16:55:09 2013
@@ -32,6 +32,7 @@
 		<h3><h:outputText value="Flash Keep" /></h3>
 		
 		This is now empty: #{flash.name}
+        <h:messages/>
 	</h:form>
 </h:body>
 </html>

Modified: myfaces/current20/test-webapp/webapp/src/main/webapp/home.xhtml
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/webapp/home.xhtml?rev=1534701&r1=1534700&r2=1534701&view=diff
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/webapp/home.xhtml (original)
+++ myfaces/current20/test-webapp/webapp/src/main/webapp/home.xhtml Tue Oct 22 16:55:09 2013
@@ -30,6 +30,9 @@
             <h:outputLink value="flashKeep1.jsf">
                 <h:outputText value="Flash keep()" />
             </h:outputLink>
+            <h:outputLink value="flashKeep4.jsf">
+                <h:outputText value="Flash keep() check immediate" />
+            </h:outputLink>            
             <h:outputLink value="ajax1n.jsf">
                 <h:outputText value="Ajax 1" />
             </h:outputLink>