myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [myfaces] 01/02: refactored
Date Tue, 13 Aug 2019 15:44:42 GMT
This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git

commit dd629adfb4dca75df1d23ba3680ec67065f14ee8
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Tue Aug 13 17:42:34 2019 +0200

    refactored
---
 .../search/ChildSearchKeywordResolver.java         |  3 +-
 .../renderkit/html/HtmlCommandScriptRenderer.java  |  8 ++-
 .../html/base/HtmlButtonRendererBase.java          |  5 +-
 .../renderkit/html/base/HtmlLinkRendererBase.java  | 10 +--
 .../renderkit/html/util/OutcomeTargetUtils.java    | 81 ++++++++++++----------
 5 files changed, 54 insertions(+), 53 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/component/search/ChildSearchKeywordResolver.java
b/impl/src/main/java/org/apache/myfaces/component/search/ChildSearchKeywordResolver.java
index da6e22e..6e39dc8 100644
--- a/impl/src/main/java/org/apache/myfaces/component/search/ChildSearchKeywordResolver.java
+++ b/impl/src/main/java/org/apache/myfaces/component/search/ChildSearchKeywordResolver.java
@@ -55,11 +55,10 @@ public class ChildSearchKeywordResolver extends SearchKeywordResolver
                           childNumber + "\". Expression: \"" + keyword + '"');
             }
 
-            List<UIComponent> list = current.getChildren();
             int count = 0;
             for (int i = 0; i < current.getChildCount(); i++)
             {
-                if (! (list.get(i) instanceof UntargetableComponent))
+                if (!(current.getChildren().get(i) instanceof UntargetableComponent))
                 {
                     count++;
                 }
diff --git a/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlCommandScriptRenderer.java
b/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlCommandScriptRenderer.java
index 3b404fe..ada067a 100644
--- a/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlCommandScriptRenderer.java
+++ b/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlCommandScriptRenderer.java
@@ -343,8 +343,14 @@ public class HtmlCommandScriptRenderer extends HtmlRenderer
             }
         }
         
+        List<UIComponent> childrenList = null;
+        if (getChildCount(commandScript) > 0)
+        {
+            childrenList = getChildren(commandScript);
+        }
+
         List<UIParameter> uiParams = HtmlRendererUtils.getValidUIParameterChildren(
-                facesContext, commandScript.getChildren(), false, false);
+                facesContext, childrenList, false, false);
         if (uiParams != null && uiParams.size() > 0)
         {
             for (int i = 0, size = uiParams.size(); i < size; i++)
diff --git a/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlButtonRendererBase.java
b/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlButtonRendererBase.java
index f0cee55..949a746 100644
--- a/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlButtonRendererBase.java
+++ b/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlButtonRendererBase.java
@@ -140,10 +140,7 @@ public class HtmlButtonRendererBase extends HtmlRenderer
         {
             childrenList = getChildren(uiComponent);
         }
-        else
-        {
-           childrenList = Collections.emptyList();
-        }
+
         List<UIParameter> validParams = HtmlRendererUtils.getValidUIParameterChildren(
                 facesContext, childrenList, false, false);
 
diff --git a/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlLinkRendererBase.java
b/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlLinkRendererBase.java
index 4d5ef12..7de1fdb 100644
--- a/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlLinkRendererBase.java
+++ b/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlLinkRendererBase.java
@@ -636,10 +636,7 @@ public abstract class HtmlLinkRendererBase extends HtmlRenderer
         {
             childrenList = getChildren(component);
         }
-        else
-        {
-           childrenList = Collections.emptyList();
-        }
+
         List<UIParameter> validParams = HtmlRendererUtils.getValidUIParameterChildren(
                 context, childrenList, false, false);
         for (int j = 0, size = validParams.size(); j < size; j++) 
@@ -715,10 +712,7 @@ public abstract class HtmlLinkRendererBase extends HtmlRenderer
         {
             childrenList = getChildren(linkComponent);
         }
-        else
-        {
-           childrenList = Collections.emptyList();
-        }
+
         List<UIParameter> validParams = HtmlRendererUtils.getValidUIParameterChildren(
                 facesContext, childrenList, false, false);
         
diff --git a/impl/src/main/java/org/apache/myfaces/renderkit/html/util/OutcomeTargetUtils.java
b/impl/src/main/java/org/apache/myfaces/renderkit/html/util/OutcomeTargetUtils.java
index a53f702..e10ca03 100644
--- a/impl/src/main/java/org/apache/myfaces/renderkit/html/util/OutcomeTargetUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/renderkit/html/util/OutcomeTargetUtils.java
@@ -98,7 +98,7 @@ public class OutcomeTargetUtils
                     true, false);
             if (validParams.size() > 0)
             {
-                parameters = new HashMap<String, List<String>>();
+                parameters = new HashMap<>();
             }
             for (int i = 0, size = validParams.size(); i < size; i++)
             {
@@ -111,7 +111,7 @@ public class OutcomeTargetUtils
                 }
                 else
                 {
-                    List<String> list = new ArrayList<String>(1);
+                    List<String> list = new ArrayList<>(1);
                     list.add(value.toString());
                     parameters.put(name, list);
                 }
@@ -124,7 +124,7 @@ public class OutcomeTargetUtils
         {
             if (parameters == null)
             {
-                parameters = new HashMap<String, List<String>>();
+                parameters = new HashMap<>();
             }
             if (!parameters.containsKey(FlowHandler.TO_FLOW_DOCUMENT_ID_REQUEST_PARAM_NAME))
             {
@@ -238,56 +238,61 @@ public class OutcomeTargetUtils
             boolean skipNullValue, boolean skipUnrendered, boolean skipNullName)
     {
         List<UIParameter> params = null;
-        for (int i = 0, size = children.size(); i < size; i++)
+        if (children != null)
         {
-            UIComponent child = children.get(i);
-            if (child instanceof UIParameter)
+            for (int i = 0, size = children.size(); i < size; i++)
             {
-                UIParameter param = (UIParameter) child;
-                // check for the disable attribute (since 2.0)
-                // and the render attribute (only if skipUnrendered is true)
-                if (param.isDisable() || (skipUnrendered && !param.isRendered()))
+                UIComponent child = children.get(i);
+                if (child instanceof UIParameter)
                 {
-                    // ignore this UIParameter and continue
-                    continue;
-                }
+                    UIParameter param = (UIParameter) child;
+                    // check for the disable attribute (since 2.0)
+                    // and the render attribute (only if skipUnrendered is true)
+                    if (param.isDisable() || (skipUnrendered && !param.isRendered()))
+                    {
+                        // ignore this UIParameter and continue
+                        continue;
+                    }
 
-                // check the name
-                String name = param.getName();
-                if (skipNullName && (name == null || RendererUtils.EMPTY_STRING.equals(name)))
-                {
-                    // warn for a null-name
-                    log.log(Level.WARNING, "The UIParameter " + ComponentUtils.getPathToComponent(param)
-                                    + " has a name of null or empty string and thus will
not be added to the URL.");
-                    // and skip it
-                    continue;
-                }
+                    // check the name
+                    String name = param.getName();
+                    if (skipNullName && (name == null || RendererUtils.EMPTY_STRING.equals(name)))
+                    {
+                        // warn for a null-name
+                        log.log(Level.WARNING, "The UIParameter " + ComponentUtils.getPathToComponent(param)
+                                        + " has a name of null or empty string and thus will
not be added to the URL.");
+                        // and skip it
+                        continue;
+                    }
 
-                // check the value
-                if (skipNullValue && param.getValue() == null)
-                {
-                    if (facesContext.isProjectStage(ProjectStage.Development))
+                    // check the value
+                    if (skipNullValue && param.getValue() == null)
                     {
-                        // inform the user about the null value when in Development stage
-                        log.log(Level.INFO, "The UIParameter " + ComponentUtils.getPathToComponent(param)
-                                        + " has a value of null and thus will not be added
to the URL.");
+                        if (facesContext.isProjectStage(ProjectStage.Development))
+                        {
+                            // inform the user about the null value when in Development stage
+                            log.log(Level.INFO, "The UIParameter " + ComponentUtils.getPathToComponent(param)
+                                            + " has a value of null and thus will not be
added to the URL.");
+                        }
+                        // skip a null-value
+                        continue;
                     }
-                    // skip a null-value
-                    continue;
-                }
 
-                // add the param
-                if (params == null)
-                {
-                    params = new ArrayList<UIParameter>();
+                    // add the param
+                    if (params == null)
+                    {
+                        params = new ArrayList<>();
+                    }
+                    params.add(param);
                 }
-                params.add(param);
             }
         }
+
         if (params == null)
         {
             params = Collections.emptyList();
         }
+
         return params;
     }
 


Mime
View raw message