myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r1750678 - in /myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit: AbstractRendererBaseWrapper.java RendererBase.java
Date Wed, 29 Jun 2016 17:15:27 GMT
Author: lofwyr
Date: Wed Jun 29 17:15:27 2016
New Revision: 1750678

URL: http://svn.apache.org/viewvc?rev=1750678&view=rev
Log:
TOBAGO-1567: Clean up: consolidate getFormattedValue() and other methods.

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/AbstractRendererBaseWrapper.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/RendererBase.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/AbstractRendererBaseWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/AbstractRendererBaseWrapper.java?rev=1750678&r1=1750677&r2=1750678&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/AbstractRendererBaseWrapper.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/AbstractRendererBaseWrapper.java
Wed Jun 29 17:15:27 2016
@@ -22,7 +22,6 @@ package org.apache.myfaces.tobago.render
 import org.apache.myfaces.tobago.internal.context.ResourceManagerFactory;
 
 import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.ConverterException;
 import java.io.IOException;
@@ -44,11 +43,6 @@ public abstract class AbstractRendererBa
   public final void decode(final FacesContext facesContext, final UIComponent component)
{
     getRenderer(facesContext).decode(facesContext, component);
   }
-  
-  @Override
-  protected final Object getCurrentValueAsObject(final UIInput input) {
-    return getRenderer(FacesContext.getCurrentInstance()).getCurrentValueAsObject(input);
-  }
 
   @Override
   protected final String getCurrentValue(final FacesContext facesContext, final UIComponent
component) {
@@ -56,11 +50,6 @@ public abstract class AbstractRendererBa
   }
 
   @Override
-  protected final Object getValue(final UIComponent component) {
-    return getRenderer(FacesContext.getCurrentInstance()).getValue(component);
-  }
-
-  @Override
   public final Object getConvertedValue(
       final FacesContext facesContext, final UIComponent component, final Object submittedValue)
       throws ConverterException {

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/RendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/RendererBase.java?rev=1750678&r1=1750677&r2=1750678&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/RendererBase.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/RendererBase.java
Wed Jun 29 17:15:27 2016
@@ -19,15 +19,10 @@
 
 package org.apache.myfaces.tobago.renderkit;
 
-import org.apache.myfaces.tobago.context.ResourceManager;
-import org.apache.myfaces.tobago.internal.context.ResourceManagerFactory;
 import org.apache.myfaces.tobago.util.ComponentUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import javax.faces.component.EditableValueHolder;
 import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
 import javax.faces.component.ValueHolder;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
@@ -36,38 +31,23 @@ import javax.faces.render.Renderer;
 
 public class RendererBase extends Renderer {
 
-  private static final Logger LOG = LoggerFactory.getLogger(RendererBase.class);
-
-  private ResourceManager resourceManager;
-
-  protected Object getCurrentValueAsObject(final UIInput input) {
-    final Object submittedValue = input.getSubmittedValue();
-    if (submittedValue != null) {
-      return submittedValue;
-    }
-    return getValue(input);
-  }
-
   protected String getCurrentValue(final FacesContext facesContext, final UIComponent component)
{
 
-    if (component instanceof EditableValueHolder) {
-      final EditableValueHolder editableValueHolder = (EditableValueHolder) component;
-      final Object submittedValue = editableValueHolder.getSubmittedValue();
-      if (submittedValue != null || !editableValueHolder.isValid()) {
-        return (String) submittedValue;
-      }
-    }
-    String currentValue = null;
-    final Object currentObj = getValue(component);
-    if (currentObj != null) {
-      currentValue = ComponentUtils.getFormattedValue(facesContext, component, currentObj);
-    }
-    return currentValue;
-  }
-
-  protected Object getValue(final UIComponent component) {
     if (component instanceof ValueHolder) {
-      return ((ValueHolder) component).getValue();
+      final ValueHolder valueHolder = (ValueHolder) component;
+      if (valueHolder instanceof EditableValueHolder) {
+        final EditableValueHolder editableValueHolder = (EditableValueHolder) component;
+        final Object submittedValue = editableValueHolder.getSubmittedValue();
+        if (submittedValue != null || !editableValueHolder.isValid()) {
+          return (String) submittedValue;
+        }
+      }
+      String currentValue = null;
+      final Object result = ((ValueHolder) component).getValue();
+      if (result != null) {
+        currentValue = ComponentUtils.getFormattedValue(facesContext, component, result);
+      }
+      return currentValue;
     } else {
       return null;
     }
@@ -90,11 +70,4 @@ public class RendererBase extends Render
   public void onComponentCreated(
       final FacesContext facesContext, final UIComponent component, final UIComponent parent)
{
   }
-  
-  protected synchronized ResourceManager getResourceManager() {
-    if (resourceManager == null) {
-      resourceManager = ResourceManagerFactory.getResourceManager(FacesContext.getCurrentInstance());
-    }
-    return resourceManager;
-  }
 }



Mime
View raw message