You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2011/02/14 12:02:08 UTC

svn commit: r1070438 - in /myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago: internal/component/AbstractUIPage.java renderkit/PageRendererBase.java

Author: lofwyr
Date: Mon Feb 14 11:02:08 2011
New Revision: 1070438

URL: http://svn.apache.org/viewvc?rev=1070438&view=rev
Log:
TOBAGO-606: LayoutManager
 - size of the browser should be stored in the decode phase (so that it work, when validation fails)

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPage.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/PageRendererBase.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPage.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPage.java?rev=1070438&r1=1070437&r2=1070438&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPage.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPage.java Mon Feb 14 11:02:08 2011
@@ -21,7 +21,6 @@ import org.apache.commons.collections.Ke
 import org.apache.myfaces.tobago.compat.FacesUtils;
 import org.apache.myfaces.tobago.component.Attributes;
 import org.apache.myfaces.tobago.component.ComponentTypes;
-import org.apache.myfaces.tobago.util.CreateComponentUtils;
 import org.apache.myfaces.tobago.component.DeprecatedDimension;
 import org.apache.myfaces.tobago.component.Facets;
 import org.apache.myfaces.tobago.component.OnComponentPopulated;
@@ -36,6 +35,7 @@ import org.apache.myfaces.tobago.layout.
 import org.apache.myfaces.tobago.model.PageState;
 import org.apache.myfaces.tobago.model.PageStateImpl;
 import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.apache.myfaces.tobago.util.CreateComponentUtils;
 import org.apache.myfaces.tobago.util.DebugUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -49,7 +49,6 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import java.util.StringTokenizer;
 
 public abstract class AbstractUIPage extends AbstractUIForm
     implements OnComponentPopulated, LayoutContainer, DeprecatedDimension {
@@ -220,31 +219,6 @@ public abstract class AbstractUIPage ext
    */
   @Deprecated
   public void updatePageState(FacesContext facesContext) {
-    PageState state = getPageState(facesContext);
-    decodePageState(facesContext, state);
-  }
-
-  @SuppressWarnings("unchecked")
-  private void decodePageState(FacesContext facesContext, PageState pageState) {
-    String name;
-    String value = null;
-    try {
-      name = getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "form-clientDimension";
-      value = (String) facesContext.getExternalContext().getRequestParameterMap().get(name);
-      if (value != null) {
-        StringTokenizer tokenizer = new StringTokenizer(value, ";");
-        Measure width = Measure.parse(tokenizer.nextToken());
-        Measure height = Measure.parse(tokenizer.nextToken());
-        if (pageState != null) {
-          pageState.setClientWidth(width.getPixel());
-          pageState.setClientHeight(height.getPixel());
-        }
-        facesContext.getExternalContext().getRequestMap().put("tobago-page-clientDimension-width", width);
-        facesContext.getExternalContext().getRequestMap().put("tobago-page-clientDimension-height", height);
-      }
-    } catch (Exception e) {
-      LOG.error("Error in decoding state: value='" + value + "'", e);
-    }
   }
 
   /**

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/PageRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/PageRendererBase.java?rev=1070438&r1=1070437&r2=1070438&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/PageRendererBase.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/PageRendererBase.java Mon Feb 14 11:02:08 2011
@@ -18,6 +18,8 @@ package org.apache.myfaces.tobago.render
  */
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.myfaces.tobago.layout.Measure;
+import org.apache.myfaces.tobago.model.PageState;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.myfaces.tobago.internal.component.AbstractUIPage;
@@ -26,6 +28,7 @@ import org.apache.myfaces.tobago.util.Co
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
+import java.util.StringTokenizer;
 
 public class PageRendererBase extends LayoutComponentRendererBase {
 
@@ -35,29 +38,59 @@ public class PageRendererBase extends La
     if (component instanceof AbstractUIPage) {
       AbstractUIPage page = (AbstractUIPage) component;
 
-      String actionIdName = page.getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "form-action";
-      String newActionId = (String) facesContext.getExternalContext().getRequestParameterMap().get(actionIdName);
+      decodeActionPosition(facesContext, page);
+      decodePageState(facesContext, page);
+    }
+  }
+
+  private void decodeActionPosition(FacesContext facesContext, AbstractUIPage page) {
+    String actionIdName = page.getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "form-action";
+    String newActionId = (String) facesContext.getExternalContext().getRequestParameterMap().get(actionIdName);
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("action = " + newActionId);
+    }
+    page.setActionId(newActionId);
+
+    try {
+      String actionPositionName = page.getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "action-position";
+      String actionPositionString = (String)
+          facesContext.getExternalContext().getRequestParameterMap().get(actionPositionName);
       if (LOG.isDebugEnabled()) {
-        LOG.debug("action = " + newActionId);
+        LOG.debug("actionPosition='" + actionPositionString + "'");
       }
-      page.setActionId(newActionId);
+      if (StringUtils.isNotEmpty(actionPositionString)) {
+        Box actionPosition = new Box(actionPositionString);
+        page.setActionPosition(actionPosition);
+      } else {
+        page.setActionPosition(null);
+      }
+    } catch (Exception e) {
+      LOG.warn("Can't analyse parameter for action-position", e);
+    }
+  }
 
-      try {
-        String actionPositionName = page.getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "action-position";
-        String actionPositionString = (String)
-            facesContext.getExternalContext().getRequestParameterMap().get(actionPositionName);
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("actionPosition='" + actionPositionString + "'");
-        }
-        if (StringUtils.isNotEmpty(actionPositionString)) {
-          Box actionPosition = new Box(actionPositionString);
-          page.setActionPosition(actionPosition);
-        } else {
-          page.setActionPosition(null);
+  @SuppressWarnings("unchecked")
+  private void decodePageState(FacesContext facesContext, AbstractUIPage page) {
+    String name;
+    String value = null;
+    try {
+      name = page.getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "form-clientDimension";
+      value = (String) facesContext.getExternalContext().getRequestParameterMap().get(name);
+      if (value != null) {
+        StringTokenizer tokenizer = new StringTokenizer(value, ";");
+        Measure width = Measure.parse(tokenizer.nextToken());
+        Measure height = Measure.parse(tokenizer.nextToken());
+        // XXX remove me later
+        PageState pageState = page.getPageState(facesContext);
+        if (pageState != null) {
+          pageState.setClientWidth(width.getPixel());
+          pageState.setClientHeight(height.getPixel());
         }
-      } catch (Exception e) {
-        LOG.warn("Can't analyse parameter for action-position", e);
+        facesContext.getExternalContext().getRequestMap().put("tobago-page-clientDimension-width", width);
+        facesContext.getExternalContext().getRequestMap().put("tobago-page-clientDimension-height", height);
       }
+    } catch (Exception e) {
+      LOG.error("Error in decoding state: value='" + value + "'", e);
     }
   }
 }