myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [myfaces] branch master updated: refactored
Date Sun, 16 Dec 2018 14:40:06 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


The following commit(s) were added to refs/heads/master by this push:
     new 0669641  refactored
0669641 is described below

commit 0669641b2d25af5484a347ce6a80bb8de45cb589
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Sun Dec 16 15:40:12 2018 +0100

    refactored
---
 .../apache/myfaces/renderkit/RendererUtils.java    | 22 +++------
 .../renderkit/html/HtmlCommandScriptRenderer.java  | 56 +++-------------------
 2 files changed, 14 insertions(+), 64 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/renderkit/RendererUtils.java b/impl/src/main/java/org/apache/myfaces/renderkit/RendererUtils.java
index 5fd0d93..7e535f8 100755
--- a/impl/src/main/java/org/apache/myfaces/renderkit/RendererUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/renderkit/RendererUtils.java
@@ -136,8 +136,7 @@ public final class RendererUtils
         return null;
     }
 
-    public static String getStringValue(FacesContext facesContext,
-            UIComponent component)
+    public static String getStringValue(FacesContext facesContext, UIComponent component)
     {
         if (!(component instanceof ValueHolder))
         {
@@ -185,8 +184,7 @@ public final class RendererUtils
 
             try
             {
-                converter = facesContext.getApplication().createConverter(
-                        value.getClass());
+                converter = facesContext.getApplication().createConverter(value.getClass());
                 if (log.isLoggable(Level.FINE))
                 {
                     log.fine("the created converter is " + converter);
@@ -198,7 +196,6 @@ public final class RendererUtils
                         + value.getClass().getName()
                         + " found (component id=" + component.getId()
                         + ").", e);
-                // converter stays null
             }
         }
 
@@ -228,8 +225,8 @@ public final class RendererUtils
         return converter.getAsString(facesContext, component, value);
     }
 
-    public static String getStringFromSubmittedValueOrLocalValueReturnNull(
-            FacesContext facesContext, UIComponent component)
+    public static String getStringFromSubmittedValueOrLocalValueReturnNull(FacesContext facesContext,
+            UIComponent component)
     {
         try
         {
@@ -275,7 +272,6 @@ public final class RendererUtils
             Converter converter = ((ValueHolder) component).getConverter();
             if (converter == null && value != null)
             {
-
                 try
                 {
                     converter = facesContext.getApplication().createConverter(
@@ -692,13 +688,10 @@ public final class RendererUtils
         {
             //primitive array
             int len = Array.getLength(values);
-            HashSet set = new HashSet(
-                    org.apache.myfaces.util.HashMapUtils
-                            .calcCapacity(len));
+            HashSet set = new HashSet(HashMapUtils.calcCapacity(len));
             for (int i = 0; i < len; i++)
             {
-                set.add(getConvertedStringValue(context, component, converter,
-                        Array.get(values, i)));
+                set.add(getConvertedStringValue(context, component, converter, Array.get(values,
i)));
             }
             return set;
         }
@@ -713,8 +706,7 @@ public final class RendererUtils
             HashSet set = new HashSet(HashMapUtils.calcCapacity(col.size()));
             for (Iterator i = col.iterator(); i.hasNext();)
             {
-                set.add(getConvertedStringValue(context, component, converter,
-                        i.next()));
+                set.add(getConvertedStringValue(context, component, converter, i.next()));
             }
 
             return set;
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 2c802df..e264a74 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
@@ -30,7 +30,6 @@ import java.util.Set;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIForm;
 import javax.faces.component.UIParameter;
-import javax.faces.component.behavior.AjaxBehavior;
 import javax.faces.component.behavior.ClientBehaviorContext;
 import javax.faces.component.behavior.ClientBehaviorHolder;
 import javax.faces.component.html.HtmlCommandScript;
@@ -62,7 +61,6 @@ public class HtmlCommandScriptRenderer extends HtmlRenderer
     private static final String AJAX_KEY_ONEVENT = "onevent";
     private static final String AJAX_KEY_EXECUTE = "execute";
     private static final String AJAX_KEY_RENDER = "render";
-    private static final String AJAX_KEY_DELAY = "delay";
     private static final String AJAX_KEY_RESETVALUES = "resetValues";
 
     private static final String AJAX_VAL_THIS = "this";
@@ -105,15 +103,6 @@ public class HtmlCommandScriptRenderer extends HtmlRenderer
         script.append("var "+name+" = function(o){var o=(typeof o==='object')&&o?o:{};");
         script.prettyLine();
         
-        // TODO ajaxBehavior not required actually....
-        AjaxBehavior ajaxBehavior = new AjaxBehavior();
-        Boolean resetValues = commandScript.getResetValues();
-        if (resetValues != null)
-        {
-            ajaxBehavior.setResetValues(resetValues);
-        }
-        ajaxBehavior.setOnerror(commandScript.getOnerror());
-        ajaxBehavior.setOnevent(commandScript.getOnevent());
         
         Collection<ClientBehaviorContext.Parameter> eventParameters = null;    
         //eventParameters.add(new ClientBehaviorContext.Parameter("params", "o"));
@@ -121,7 +110,7 @@ public class HtmlCommandScriptRenderer extends HtmlRenderer
                                     context, component, "action",
                                     commandScript.getClientId(context), eventParameters);
         
-        script.append(makeAjax(context, ccc, ajaxBehavior, commandScript).toString());
+        script.append(makeAjax(context, ccc, commandScript).toString());
         script.decreaseIndent();
         script.append("}");
         
@@ -208,7 +197,7 @@ public class HtmlCommandScriptRenderer extends HtmlRenderer
      * @param commandScript the component
      * @return a fully working javascript with calls into jsf.js
      */
-    private StringBuilder makeAjax(FacesContext facesContext, ClientBehaviorContext context,
AjaxBehavior behavior,
+    private StringBuilder makeAjax(FacesContext facesContext, ClientBehaviorContext context,
             HtmlCommandScript commandScript)
     {
         StringBuilder retVal = SharedStringBuilder.get(context.getFacesContext(), AJAX_SB,
60);
@@ -222,7 +211,7 @@ public class HtmlCommandScriptRenderer extends HtmlRenderer
         String render = resolveExpressionsAsParameter(paramBuffer, AJAX_KEY_RENDER, commandScript.getRender(),
                 searchExpressionContext);
 
-        String onError = behavior.getOnerror();
+        String onError = commandScript.getOnerror();
         if (LangUtils.isNotBlank(onError))
         {
             paramBuffer.setLength(0);
@@ -236,7 +225,7 @@ public class HtmlCommandScriptRenderer extends HtmlRenderer
             onError = null;
         }
 
-        String onEvent = behavior.getOnevent();
+        String onEvent = commandScript.getOnevent();
         if (LangUtils.isNotBlank(onEvent))
         {
             paramBuffer.setLength(0);
@@ -250,42 +239,15 @@ public class HtmlCommandScriptRenderer extends HtmlRenderer
             onEvent = null;
         }
 
-        String delay = behavior.getDelay();
-        if (LangUtils.isNotBlank(delay))
-        {
-            paramBuffer.setLength(0);
-            paramBuffer.append(AJAX_KEY_DELAY);
-            paramBuffer.append(':');
-            if ("none".equals(delay))
-            {
-                paramBuffer.append('\'');
-                paramBuffer.append(delay);
-                paramBuffer.append('\'');
-            }
-            else
-            {
-                paramBuffer.append(delay);
-            }
-            delay = paramBuffer.toString();
-        }
-        else
-        {
-            delay = null;
-        }
-
-        String resetValues = Boolean.toString(behavior.isResetValues());
-        if (resetValues.equals("true"))
+        String resetValues = null;
+        if (Boolean.TRUE.equals(commandScript.getResetValues()))
         {
             paramBuffer.setLength(0);
             paramBuffer.append(AJAX_KEY_RESETVALUES);
             paramBuffer.append(':');
-            paramBuffer.append(resetValues);
+            paramBuffer.append("true");
             resetValues = paramBuffer.toString();
         }
-        else
-        {
-            resetValues = null;
-        }
 
         String sourceId = null;
         if (context.getSourceId() == null)
@@ -352,10 +314,6 @@ public class HtmlCommandScriptRenderer extends HtmlRenderer
         {
             parameterList.add(onEvent);
         }
-        if (delay != null)
-        {
-            parameterList.add(delay);
-        }
         if (resetValues != null)
         {
             parameterList.add(resetValues);


Mime
View raw message