myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r1720417 [3/3] - in /myfaces/tobago/branches/tobago-3.0.x: tobago-core/src/main/java/org/apache/myfaces/tobago/component/ tobago-core/src/main/java/org/apache/myfaces/tobago/convert/ tobago-core/src/main/java/org/apache/myfaces/tobago/facel...
Date Wed, 16 Dec 2015 19:23:37 GMT
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeRenderer.java?rev=1720417&r1=1720416&r2=1720417&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeRenderer.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeRenderer.java
Wed Dec 16 19:23:36 2015
@@ -50,8 +50,8 @@ public class TreeRenderer extends Render
 
   @Override
   public void decode(final FacesContext facesContext, final UIComponent component) {
-    RenderUtils.decodeScrollPosition(facesContext, component);
     final AbstractUITree tree = (AbstractUITree) component;
+    RenderUtils.decodeScrollPosition(facesContext, tree, tree.getState());
     RenderUtils.decodedStateOfTreeData(facesContext, tree);
   }
 
@@ -142,7 +142,7 @@ public class TreeRenderer extends Render
     writer.writeAttribute(HtmlAttributes.VALUE, expandedValue.toString(), false);
     writer.endElement(HtmlElements.INPUT);
 
-    RenderUtils.writeScrollPosition(facesContext, writer, tree);
+    RenderUtils.writeScrollPosition(facesContext, writer, tree, tree.getState());
 
     writer.endElement(HtmlElements.DIV);
   }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/VerbatimRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/VerbatimRenderer.java?rev=1720417&r1=1720416&r2=1720417&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/VerbatimRenderer.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/VerbatimRenderer.java
Wed Dec 16 19:23:36 2015
@@ -41,7 +41,7 @@ public class VerbatimRenderer extends Re
       return;
     }
 
-    if (ComponentUtils.getBooleanAttribute(component, Attributes.ESCAPE)) {
+    if (ComponentUtils.getBooleanAttribute(component, Attributes.escape)) {
       writer.writeText(value, null);
     } else {
       writer.write(value);

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java?rev=1720417&r1=1720416&r2=1720417&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java
Wed Dec 16 19:23:36 2015
@@ -163,7 +163,7 @@ public final class HtmlRendererUtils {
 
   public static String getTitleFromTipAndMessages(final FacesContext facesContext, final
UIComponent component) {
     final String messages = ComponentUtils.getFacesMessageAsString(facesContext, component);
-    return HtmlRendererUtils.addTip(messages, component.getAttributes().get(Attributes.TIP));
+    return HtmlRendererUtils.addTip(messages, ComponentUtils.getAttribute(component, Attributes.tip));
   }
 
   public static String addTip(String title, final Object tip) {
@@ -283,8 +283,8 @@ public final class HtmlRendererUtils {
   public static void renderCommandFacet(
       final UIComponent component, final String id, final FacesContext facesContext, final
TobagoResponseWriter writer)
       throws IOException {
-    if (ComponentUtils.getBooleanAttribute(component, Attributes.READONLY)
-        || ComponentUtils.getBooleanAttribute(component, Attributes.DISABLED)) {
+    if (ComponentUtils.getBooleanAttribute(component, Attributes.readonly)
+        || ComponentUtils.getBooleanAttribute(component, Attributes.disabled)) {
       return;
     }
     CommandMap commandMap = null;

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java?rev=1720417&r1=1720416&r2=1720417&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java
Wed Dec 16 19:23:36 2015
@@ -19,12 +19,12 @@
 
 package org.apache.myfaces.tobago.renderkit.util;
 
-import org.apache.myfaces.tobago.component.Attributes;
 import org.apache.myfaces.tobago.context.ResourceManagerUtils;
 import org.apache.myfaces.tobago.internal.component.AbstractUICommand;
 import org.apache.myfaces.tobago.internal.component.AbstractUIData;
 import org.apache.myfaces.tobago.internal.util.StringUtils;
 import org.apache.myfaces.tobago.model.ExpandedState;
+import org.apache.myfaces.tobago.model.ScrollPositionState;
 import org.apache.myfaces.tobago.model.SelectedState;
 import org.apache.myfaces.tobago.model.TreePath;
 import org.apache.myfaces.tobago.renderkit.html.DataAttributes;
@@ -234,16 +234,14 @@ public class RenderUtils {
 
       // expanded
       if (expandedIndices != null) {
-        if (expandedIndices != null) {
-          final ExpandedState expandedState = data.getExpandedState();
-          final boolean oldExpanded = expandedState.isExpanded(path);
-          final boolean newExpanded = expandedIndices.contains(rowIndex);
-          if (newExpanded != oldExpanded) {
-            if (newExpanded) {
-              expandedState.expand(path);
-            } else {
-              expandedState.collapse(path);
-            }
+        final ExpandedState expandedState = data.getExpandedState();
+        final boolean oldExpanded = expandedState.isExpanded(path);
+        final boolean newExpanded = expandedIndices.contains(rowIndex);
+        if (newExpanded != oldExpanded) {
+          if (newExpanded) {
+            expandedState.expand(path);
+          } else {
+            expandedState.collapse(path);
           }
         }
       }
@@ -269,58 +267,26 @@ public class RenderUtils {
   }
 
   public static void writeScrollPosition(
-      final FacesContext facesContext, final TobagoResponseWriter writer, final UIComponent
component)
-      throws IOException {
-    Integer[] scrollPosition = (Integer[]) component.getAttributes().get(Attributes.SCROLL_POSITION);
-    if (scrollPosition == null) {
-      final String key = component.getClientId(facesContext) + SCROLL_POSTFIX;
-      scrollPosition = parseScrollPosition(facesContext.getExternalContext().getRequestParameterMap().get(key));
-    }
-    writeScrollPosition(facesContext, writer, component, scrollPosition);
-  }
-
-  public static void writeScrollPosition(
       final FacesContext facesContext, final TobagoResponseWriter writer, final UIComponent
component,
-      final Integer[] scrollPosition)
+      final ScrollPositionState state)
       throws IOException {
     final String clientId = component.getClientId(facesContext);
     writer.startElement(HtmlElements.INPUT);
     writer.writeIdAttribute(clientId + SCROLL_POSTFIX);
     writer.writeNameAttribute(clientId + SCROLL_POSTFIX);
     writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN);
-    final String scrollPositionString = scrollPosition != null ? scrollPosition[0] + ";"
+ scrollPosition[1] : "";
-    writer.writeAttribute(HtmlAttributes.VALUE, scrollPositionString, false);
+    writer.writeAttribute(HtmlAttributes.VALUE, state.getScrollPosition().encode(), false);
     writer.writeAttribute(DataAttributes.SCROLL_POSITION, Boolean.TRUE.toString(), true);
     writer.endElement(HtmlElements.INPUT);
   }
 
-  public static void decodeScrollPosition(final FacesContext facesContext, final UIComponent
component) {
+  public static void decodeScrollPosition(
+      final FacesContext facesContext, final UIComponent component, final ScrollPositionState
state) {
     final String key = component.getClientId(facesContext) + SCROLL_POSTFIX;
     final String value = facesContext.getExternalContext().getRequestParameterMap().get(key);
     if (value != null) {
-      final Integer[] scrollPosition = parseScrollPosition(value);
-      if (scrollPosition != null) {
-        //noinspection unchecked
-        component.getAttributes().put(Attributes.SCROLL_POSITION, scrollPosition);
-      }
-    }
-  }
-
-  public static Integer[] parseScrollPosition(final String value) {
-    Integer[] position = null;
-    if (!StringUtils.isBlank(value)) {
-      final int sep = value.indexOf(";");
-      if (sep == -1) {
-        LOG.warn("Can't parse: '{}'", value);
-        return null;
-      }
-      final int left = Integer.parseInt(value.substring(0, sep));
-      final int top = Integer.parseInt(value.substring(sep + 1));
-      position = new Integer[2];
-      position[0] = left;
-      position[1] = top;
+      state.getScrollPosition().update(value);
     }
-    return position;
   }
 
   public static String generateUrl(final FacesContext facesContext, final AbstractUICommand
component) {

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/SelectItemUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/SelectItemUtils.java?rev=1720417&r1=1720416&r2=1720417&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/SelectItemUtils.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/SelectItemUtils.java
Wed Dec 16 19:23:36 2015
@@ -22,6 +22,7 @@ package org.apache.myfaces.tobago.render
 import org.apache.myfaces.tobago.component.Attributes;
 import org.apache.myfaces.tobago.component.Visual;
 import org.apache.myfaces.tobago.context.Markup;
+import org.apache.myfaces.tobago.util.ComponentUtils;
 
 import javax.el.ValueExpression;
 import javax.faces.component.UIComponent;
@@ -211,7 +212,7 @@ public class SelectItemUtils {
           // write the current item into the request map under the key listed in var, if
available
           boolean wroteRequestMapVarValue = false;
           Object oldRequestMapVarValue = null;
-          final String var = (String) attributeMap.get(Attributes.VAR);
+          final String var = ComponentUtils.getStringAttribute(currentUISelectItems, Attributes.var);
           if (var != null && !"".equals(var)) {
             // save the current value of the key listed in var from the request map
             oldRequestMapVarValue = facesContext.getExternalContext().getRequestMap().put(var,
item);
@@ -219,7 +220,7 @@ public class SelectItemUtils {
           }
 
           // check the itemValue attribute
-          Object itemValue = attributeMap.get(Attributes.ITEM_VALUE);
+          Object itemValue = ComponentUtils.getAttribute(currentUISelectItems, Attributes.itemValue);
           if (itemValue == null) {
             // the itemValue attribute was not provided
             // --> use the current item as the itemValue
@@ -228,18 +229,19 @@ public class SelectItemUtils {
 
           // Spec: When iterating over the select items, toString()
           // must be called on the string rendered attribute values
-          Object itemLabel = attributeMap.get(Attributes.ITEM_LABEL);
+          Object itemLabel = ComponentUtils.getAttribute(currentUISelectItems, Attributes.itemLabel);
           if (itemLabel == null) {
             itemLabel = itemValue.toString();
           } else {
             itemLabel = itemLabel.toString();
           }
-          Object itemDescription = attributeMap.get(Attributes.ITEM_DESCRIPTION);
+          Object itemDescription = ComponentUtils.getAttribute(currentUISelectItems, Attributes.itemDescription);
           if (itemDescription != null) {
             itemDescription = itemDescription.toString();
           }
-          final Boolean itemDisabled = getBooleanAttribute(currentUISelectItems, Attributes.ITEM_DISABLED,
false);
-          final String itemImage = (String) attributeMap.get(Attributes.ITEM_IMAGE);
+          final Boolean itemDisabled
+              = ComponentUtils.getBooleanAttribute(currentUISelectItems, Attributes.itemDisabled,
false);
+          final String itemImage = ComponentUtils.getStringAttribute(currentUISelectItems,
Attributes.itemImage);
           final Markup markup;
           if (currentUISelectItems instanceof Visual) {
             markup = ((Visual) currentUISelectItems).getCurrentMarkup();
@@ -271,21 +273,6 @@ public class SelectItemUtils {
     public void remove() {
       throw new UnsupportedOperationException();
     }
-
-    private boolean getBooleanAttribute(
-        final UIComponent component, final String attrName, final boolean defaultValue) {
-      final Object value = component.getAttributes().get(attrName);
-      if (value == null) {
-        return defaultValue;
-      } else if (value instanceof Boolean) {
-        return (Boolean) value;
-      } else {
-        // If the value is a String, parse the boolean.
-        // This makes the following code work: <tag attribute="true" />,
-        // otherwise you would have to write <tag attribute="#{true}" />.
-        return Boolean.valueOf(value.toString());
-      }
-    }
   }
 
 }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/JsonUtilsUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/JsonUtilsUnitTest.java?rev=1720417&r1=1720416&r2=1720417&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/JsonUtilsUnitTest.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/JsonUtilsUnitTest.java
Wed Dec 16 19:23:36 2015
@@ -25,6 +25,7 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.internal.component.AbstractUICommand;
 import org.apache.myfaces.tobago.internal.config.AbstractTobagoTestBase;
 import org.apache.myfaces.tobago.internal.context.DateTimeI18n;
+import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.util.CreateComponentUtils;
 import org.junit.Assert;
 import org.junit.Test;
@@ -79,7 +80,7 @@ public class JsonUtilsUnitTest extends A
     final CommandMap map = new CommandMap();
     final AbstractUICommand command = (AbstractUICommand)
         CreateComponentUtils.createComponent(facesContext, ComponentTypes.BUTTON, RendererTypes.BUTTON,
"command");
-    command.getAttributes().put(Attributes.POPUP_CLOSE, "immediate");
+    ComponentUtils.setAttribute(command, Attributes.popupClose, "immediate");
     command.setRenderedPartially(new String[]{"popup"});
 
     map.setClick(new Command(



Mime
View raw message