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 05:07:35 UTC

svn commit: r1534466 - in /myfaces/shared/trunk_4.1.x/core: ./ src/main/java/org/apache/myfaces/shared/config/ src/main/java/org/apache/myfaces/shared/context/flash/ src/main/java/org/apache/myfaces/shared/renderkit/html/ src/main/java/org/apache/myfac...

Author: lu4242
Date: Tue Oct 22 03:07:32 2013
New Revision: 1534466

URL: http://svn.apache.org/r1534466
Log:
synch shared

Removed:
    myfaces/shared/trunk_4.1.x/core/src/test/java/org/apache/myfaces/shared/context/flash/FlashImplTest.java
Modified:
    myfaces/shared/trunk_4.1.x/core/pom.xml
    myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java
    myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java
    myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java
    myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java
    myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java
    myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java
    myfaces/shared/trunk_4.1.x/core/src/main/resources/META-INF/myfaces-metadata.xml

Modified: myfaces/shared/trunk_4.1.x/core/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.1.x/core/pom.xml?rev=1534466&r1=1534465&r2=1534466&view=diff
==============================================================================
--- myfaces/shared/trunk_4.1.x/core/pom.xml (original)
+++ myfaces/shared/trunk_4.1.x/core/pom.xml Tue Oct 22 03:07:32 2013
@@ -143,7 +143,7 @@
     <profile>
       <id>synch-myfaces-impl-shared</id>
       <properties>
-        <myfaces.impl.shared.version>2.1.12-SNAPSHOT</myfaces.impl.shared.version>
+        <myfaces.impl.shared.version>2.1.13-SNAPSHOT</myfaces.impl.shared.version>
       </properties>
       <activation>
         <property>

Modified: myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java?rev=1534466&r1=1534465&r2=1534466&view=diff
==============================================================================
--- myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java (original)
+++ myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java Tue Oct 22 03:07:32 2013
@@ -417,6 +417,19 @@ public class MyfacesConfig
     public static final String INIT_PARAM_GAE_JSF_ANNOTATIONS_JAR_FILES = 
             "org.apache.myfaces.GAE_JSF_ANNOTATIONS_JAR_FILES";
     public final static String INIT_PARAM_GAE_JSF_ANNOTATIONS_JAR_FILES_DEFAULT = null;
+    
+    /**
+     * If this param is set to true, a check will be done in Restore View Phase to check
+     * if the viewId exists or not and if it does not exists, a 404 response will be thrown.
+     * 
+     * This is applicable in cases where all the views in the application are generated by a 
+     * ViewDeclarationLanguage implementation.
+     */
+    @JSFWebConfigParam(since = "2.1.13", defaultValue="false", expectedValues="true,false", 
+            group="viewhandler")
+    public static final String INIT_PARAM_STRICT_JSF_2_VIEW_NOT_FOUND = 
+            "org.apache.myfaces.STRICT_JSF_2_VIEW_NOT_FOUND";
+    public final static boolean INIT_PARAM_STRICT_JSF_2_VIEW_NOT_FOUND_DEFAULT = false;
 
     private boolean _prettyHtml;
     private boolean _detectJavascript;
@@ -449,6 +462,7 @@ public class MyfacesConfig
     private boolean _supportJSPAndFacesEL;
     private String _gaeJsfJarFiles;
     private String _gaeJsfAnnotationsJarFiles;
+    private boolean _strictJsf2ViewNotFound;
 
     private static final boolean TOMAHAWK_AVAILABLE;
     private static final boolean MYFACES_IMPL_AVAILABLE;
@@ -549,6 +563,7 @@ public class MyfacesConfig
         setSupportJSPAndFacesEL(INIT_PARAM_SUPPORT_JSP_AND_FACES_EL_DEFAULT);
         setGaeJsfJarFiles(INIT_PARAM_GAE_JSF_JAR_FILES_DEFAULT);
         setGaeJsfAnnotationsJarFiles(INIT_PARAM_GAE_JSF_ANNOTATIONS_JAR_FILES_DEFAULT);
+        setStrictJsf2ViewNotFound(INIT_PARAM_STRICT_JSF_2_VIEW_NOT_FOUND_DEFAULT);
     }
 
     private static MyfacesConfig createAndInitializeMyFacesConfig(ExternalContext extCtx)
@@ -655,6 +670,9 @@ public class MyfacesConfig
                 INIT_PARAM_GAE_JSF_JAR_FILES, INIT_PARAM_GAE_JSF_JAR_FILES_DEFAULT));
         myfacesConfig.setGaeJsfAnnotationsJarFiles(WebConfigParamUtils.getStringInitParameter(extCtx, 
                 INIT_PARAM_GAE_JSF_ANNOTATIONS_JAR_FILES, INIT_PARAM_GAE_JSF_ANNOTATIONS_JAR_FILES_DEFAULT));
+
+        myfacesConfig.setStrictJsf2ViewNotFound(WebConfigParamUtils.getBooleanInitParameter(extCtx, 
+                INIT_PARAM_STRICT_JSF_2_VIEW_NOT_FOUND, INIT_PARAM_STRICT_JSF_2_VIEW_NOT_FOUND_DEFAULT));
         
         if (TOMAHAWK_AVAILABLE)
         {
@@ -1174,4 +1192,13 @@ public class MyfacesConfig
         this._gaeJsfAnnotationsJarFiles = gaeJsfAnnotationsJarFiles;
     }
 
+    public boolean isStrictJsf2ViewNotFound()
+    {
+        return _strictJsf2ViewNotFound;
+    }
+
+    public void setStrictJsf2ViewNotFound(boolean strictJsf2ViewNotFound)
+    {
+        this._strictJsf2ViewNotFound = strictJsf2ViewNotFound;
+    }
 }

Modified: myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java?rev=1534466&r1=1534465&r2=1534466&view=diff
==============================================================================
--- myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java (original)
+++ myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java Tue Oct 22 03:07:32 2013
@@ -537,7 +537,10 @@ public class FlashImpl extends Flash
         final PhaseId currentPhaseId = facesContext.getCurrentPhaseId();
         
         boolean lastPhaseNormalRequest = PhaseId.RENDER_RESPONSE.equals(currentPhaseId);
-        boolean lastPhaseIfRedirect = PhaseId.INVOKE_APPLICATION.equals(currentPhaseId) 
+        // According to the spec, if there is a redirect, responseComplete() 
+        // has been called, and Flash.setRedirect() has been called too,
+        // so we just need to check both are present.
+        boolean lastPhaseIfRedirect = facesContext.getResponseComplete()
                 && _isRedirectTrueOnThisRequest(facesContext);
         
         return lastPhaseNormalRequest || lastPhaseIfRedirect;

Modified: myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java?rev=1534466&r1=1534465&r2=1534466&view=diff
==============================================================================
--- myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java (original)
+++ myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java Tue Oct 22 03:07:32 2013
@@ -68,7 +68,9 @@ public class HtmlButtonRendererBase
                 facesContext, uiComponent, UICommand.class);
 
         //super.decode must not be called, because value is handled here
-        if (!isReset(uiComponent) && isSubmitted(facesContext, uiComponent))
+        boolean disabled = isDisabled(facesContext, uiComponent);
+        if (!isReset(uiComponent) && isSubmitted(facesContext, uiComponent) &&
+            !disabled)
         {
             uiComponent.queueEvent(new ActionEvent(uiComponent));
 
@@ -77,7 +79,7 @@ public class HtmlButtonRendererBase
         }
         
         if (uiComponent instanceof ClientBehaviorHolder &&
-                !HtmlRendererUtils.isDisabled(uiComponent))
+                !disabled)
         {
             HtmlRendererUtils.decodeClientBehaviors(facesContext, uiComponent);
         }

Modified: myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java?rev=1534466&r1=1534465&r2=1534466&view=diff
==============================================================================
--- myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java (original)
+++ myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java Tue Oct 22 03:07:32 2013
@@ -84,7 +84,8 @@ public abstract class HtmlLinkRendererBa
         {
             String clientId = component.getClientId(facesContext);
             FormInfo formInfo = findNestingForm(component, facesContext);
-            if (formInfo != null)
+            boolean disabled = HtmlRendererUtils.isDisabled(component);
+            if (formInfo != null && !disabled)
             {
                 String reqValue = (String) facesContext.getExternalContext().getRequestParameterMap().get(
                         HtmlRendererUtils.getHiddenCommandLinkFieldName(formInfo, facesContext));
@@ -97,7 +98,7 @@ public abstract class HtmlLinkRendererBa
                 }
             }
             if (component instanceof ClientBehaviorHolder &&
-                    !HtmlRendererUtils.isDisabled(component))
+                    !disabled)
             {
                 HtmlRendererUtils.decodeClientBehaviors(facesContext, component);
             }

Modified: myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java?rev=1534466&r1=1534465&r2=1534466&view=diff
==============================================================================
--- myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java (original)
+++ myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java Tue Oct 22 03:07:32 2013
@@ -483,6 +483,7 @@ public class HtmlTableRendererBase exten
                 }
 
                 List children = null;
+                int columnStyleIndex = 0;
                 for (int j = 0, size = getChildCount(component); j < size; j++)
                 {
                     if (children == null)
@@ -496,16 +497,18 @@ public class HtmlTableRendererBase exten
                         
                         if (columnRendering)
                         {
-                            beforeColumn(facesContext, uiData, j);
+                            beforeColumn(facesContext, uiData, columnStyleIndex);
                         }
                            
                         encodeColumnChild(facesContext, writer, uiData, child, 
-                                styles, nc * uiData.getChildCount() + j);                    
+                                styles, nc * uiData.getChildCount() + columnStyleIndex);
                        
                         if (columnRendering)
                         {
-                            afterColumn(facesContext, uiData, j);
+                            afterColumn(facesContext, uiData, columnStyleIndex);
                         }
+                        columnStyleIndex = columnStyleIndex + 
+                            getColumnCountForComponent(facesContext, uiData, child);
                     }
                 }
 
@@ -582,6 +585,7 @@ public class HtmlTableRendererBase exten
             renderRowStart(facesContext, writer, uiData, styles, currentRow);
             
             List<UIComponent> children = null;
+            int columnStyleIndex = 0;
             for (int j = 0, size = getChildCount(component); j < size; j++)
             {
                 if (children == null)
@@ -595,16 +599,18 @@ public class HtmlTableRendererBase exten
                     
                     if (columnRendering)
                     {
-                        beforeColumn(facesContext, uiData, j);
+                        beforeColumn(facesContext, uiData, columnStyleIndex);
                     }
                        
                     encodeColumnChild(facesContext, writer, uiData, child, 
-                            styles, j);                    
+                            styles, columnStyleIndex);
                    
                     if (columnRendering)
                     {
-                        afterColumn(facesContext, uiData, j);
+                        afterColumn(facesContext, uiData, columnStyleIndex);
                     }
+                    columnStyleIndex = columnStyleIndex + 
+                            getColumnCountForComponent(facesContext, uiData, child);
                 }
             }
 
@@ -821,6 +827,22 @@ public class HtmlTableRendererBase exten
     {        
     }
     /**
+     * Indicates the number of columns the component represents. By default each UIColumn instance
+     * is 1 column
+     * @param facesContext
+     * @param uiData
+     * @param child
+     * @return 
+     */
+    protected int getColumnCountForComponent(FacesContext facesContext, UIData uiData, UIComponent child)
+    {
+        if (child instanceof UIColumn)
+        {
+            return 1;
+        }
+        return 0;
+    }
+    /**
      *Perform any operations necessary immediately before each column child's header or footer is rendered
      *
      * @param facesContext the <code>FacesContext</code>.

Modified: myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java?rev=1534466&r1=1534465&r2=1534466&view=diff
==============================================================================
--- myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java (original)
+++ myfaces/shared/trunk_4.1.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java Tue Oct 22 03:07:32 2013
@@ -103,6 +103,14 @@ public abstract class HTMLEncoder
                     default:
                         break;
                 }
+                // http://www.w3.org/MarkUp/html3/specialchars.html
+                // From C0 extension U+0000-U+001F only U+0009, U+000A and
+                // U+000D are valid control characters
+                if (c <= 0x1F && c != 0x09 && c != 0x0A && c != 0x0D)
+                {
+                    // Ignore escape character
+                    app = "";
+                }
             }
             else if (encodeNonLatin && (int)c > 0x80)
             {
@@ -226,6 +234,14 @@ public abstract class HTMLEncoder
                     default:
                         break;
                 }
+                // http://www.w3.org/MarkUp/html3/specialchars.html
+                // From C0 extension U+0000-U+001F only U+0009, U+000A and
+                // U+000D are valid control characters
+                if (c <= 0x1F && c != 0x09 && c != 0x0A && c != 0x0D)
+                {
+                    // Ignore escape character
+                    app = "";
+                }
             }
             else if (encodeNonLatin && (int)c > 0x80)
             {
@@ -377,6 +393,14 @@ public abstract class HTMLEncoder
                     default:
                         break;
                 }
+                // http://www.w3.org/MarkUp/html3/specialchars.html
+                // From C0 extension U+0000-U+001F only U+0009, U+000A and
+                // U+000D are valid control characters
+                if (c <= 0x1F && c != 0x09 && c != 0x0A && c != 0x0D)
+                {
+                    // Ignore escape character
+                    app = "";
+                }
             }
             else if (encodeNonLatin && (int)c > 0x80)
             {

Modified: myfaces/shared/trunk_4.1.x/core/src/main/resources/META-INF/myfaces-metadata.xml
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.1.x/core/src/main/resources/META-INF/myfaces-metadata.xml?rev=1534466&r1=1534465&r2=1534466&view=diff
==============================================================================
--- myfaces/shared/trunk_4.1.x/core/src/main/resources/META-INF/myfaces-metadata.xml (original)
+++ myfaces/shared/trunk_4.1.x/core/src/main/resources/META-INF/myfaces-metadata.xml Tue Oct 22 03:07:32 2013
@@ -8279,6 +8279,22 @@ delay on startup).</longDesc>
       <tags>performance, GAE</tags>
     </webConfigParam>
     <webConfigParam>
+      <name>org.apache.myfaces.STRICT_JSF_2_VIEW_NOT_FOUND</name>
+      <fieldName>INIT_PARAM_STRICT_JSF_2_VIEW_NOT_FOUND</fieldName>
+      <desc>If this param is set to true, a check will be done in Restore View Phase to check
+if the viewId exists or not and if it does not exists, a 404 response will be thrown</desc>
+      <longDesc>If this param is set to true, a check will be done in Restore View Phase to check
+if the viewId exists or not and if it does not exists, a 404 response will be thrown.
+
+This is applicable in cases where all the views in the application are generated by a 
+ViewDeclarationLanguage implementation.</longDesc>
+      <defaultValue>false</defaultValue>
+      <expectedValues>true,false</expectedValues>
+      <sourceClassName>org.apache.myfaces.shared.config.MyfacesConfig</sourceClassName>
+      <since>2.1.13</since>
+      <group>viewhandler</group>
+    </webConfigParam>
+    <webConfigParam>
       <name>org.apache.myfaces.FLASH_SCOPE_DISABLED</name>
       <fieldName>FLASH_SCOPE_DISABLED_PARAM</fieldName>
       <desc>Defines whether flash scope is disabled, preventing add the Flash cookie to the response</desc>