You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2012/07/20 17:17:22 UTC

svn commit: r1363830 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/ tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/ t...

Author: bommel
Date: Fri Jul 20 15:17:22 2012
New Revision: 1363830

URL: http://svn.apache.org/viewvc?rev=1363830&view=rev
Log:
(TOBAGO-1178)
Support for current actionId in FacesContextUtils

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPopup.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/FacesContextUtils.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/PagingUtils.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/PageRendererBase.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ApplyRequestValuesCallback.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/FormRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPopup.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPopup.java?rev=1363830&r1=1363829&r2=1363830&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPopup.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPopup.java Fri Jul 20 15:17:22 2012
@@ -27,6 +27,7 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.component.Position;
 import org.apache.myfaces.tobago.component.RendererTypes;
 import org.apache.myfaces.tobago.internal.layout.LayoutUtils;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
 import org.apache.myfaces.tobago.layout.LayoutComponent;
 import org.apache.myfaces.tobago.layout.LayoutContainer;
 import org.apache.myfaces.tobago.layout.LayoutManager;
@@ -111,16 +112,15 @@ public abstract class AbstractUIPopup ex
   }
 
   private boolean isSubmitted() {
-    String action = ComponentUtils.findPage(getFacesContext(), this).getActionId();
+    String action = FacesContextUtils.getActionId(getFacesContext());
     return action != null && action.startsWith(getClientId(getFacesContext()) + SEPARATOR_CHAR);
   }
 
   private boolean isRedisplay() {
     if (isSubmitted()) {
-      AbstractUIPage page = ComponentUtils.findPage(getFacesContext(), this);
-      String action = page.getActionId();
+      String action = FacesContextUtils.getActionId(getFacesContext());
       if (action != null) {
-        UIComponent command = page.findComponent(SEPARATOR_CHAR + action);
+        UIComponent command = getFacesContext().getViewRoot().findComponent(SEPARATOR_CHAR + action);
         if (command != null && command instanceof UICommand) {
           return !(command.getAttributes().get(Attributes.POPUP_CLOSE) != null);
         }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/FacesContextUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/FacesContextUtils.java?rev=1363830&r1=1363829&r2=1363830&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/FacesContextUtils.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/FacesContextUtils.java Fri Jul 20 15:17:22 2012
@@ -43,7 +43,7 @@ public final class FacesContextUtils {
   private static final String TOBAGO_ONSUBMIT_SCRIPTS = "org.apache.myfaces.tobago.onsubmitScripts";
   private static final String TOBAGO_POPUPS = "org.apache.myfaces.tobago.popups";
   private static final String TOBAGO_MENU_ACCELERATORS = "org.apache.myfaces.tobago.menuAccelerators";
-
+  private static final String TOBAGO_ACTION_ID = "org.apache.myfaces.tobago.actionId";
           
   public static boolean isAjax(FacesContext context) {
     return FacesUtils.getFacesContextAttributes(context).containsKey(TOBAGO_AJAX);
@@ -53,6 +53,15 @@ public final class FacesContextUtils {
     FacesUtils.getFacesContextAttributes(context).put(TOBAGO_AJAX, ajax);
   }
 
+  public static void setActionId(FacesContext context, String actionId) {
+    FacesUtils.getFacesContextAttributes(context).put(TOBAGO_ACTION_ID, actionId);
+  }
+
+  public static String getActionId(FacesContext context) {
+    return (String) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_ACTION_ID);
+  }
+
+
   public static String getAjaxComponentId(FacesContext context) {
     return (String) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_AJAX_COMPONENT_ID);
   }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/PagingUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/PagingUtils.java?rev=1363830&r1=1363829&r2=1363830&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/PagingUtils.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/PagingUtils.java Fri Jul 20 15:17:22 2012
@@ -33,7 +33,7 @@ public class PagingUtils {
   private static final Logger LOG = LoggerFactory.getLogger(PagingUtils.class);
 
   public static void decode(FacesContext facesContext, UIComponent component) {
-    String actionId = ComponentUtils.findPage(facesContext, component).getActionId();
+    String actionId = FacesContextUtils.getActionId(facesContext);
     String clientId = component.getClientId(facesContext);
     if (LOG.isDebugEnabled()) {
       LOG.debug("actionId = '" + actionId + "'");

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=1363830&r1=1363829&r2=1363830&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 Fri Jul 20 15:17:22 2012
@@ -18,6 +18,7 @@ package org.apache.myfaces.tobago.render
  */
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
 import org.apache.myfaces.tobago.layout.Measure;
 import org.apache.myfaces.tobago.model.PageState;
 import org.slf4j.Logger;
@@ -50,7 +51,7 @@ public class PageRendererBase extends La
       LOG.debug("action = " + newActionId);
     }
     page.setActionId(newActionId);
-
+    FacesContextUtils.setActionId(facesContext, newActionId);
     try {
       String actionPositionName = page.getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "action-position";
       String actionPositionString = (String)

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ApplyRequestValuesCallback.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ApplyRequestValuesCallback.java?rev=1363830&r1=1363829&r2=1363830&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ApplyRequestValuesCallback.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ApplyRequestValuesCallback.java Fri Jul 20 15:17:22 2012
@@ -39,7 +39,7 @@ public class ApplyRequestValuesCallback 
       final String ajaxId = FacesContextUtils.getAjaxComponentId(context);
       UIComponent reload = component.getFacet(Facets.RELOAD);
       if (ajaxId != null && ajaxId.equals(component.getClientId(context)) && reload != null && reload.isRendered()
-          && ajaxId.equals(ComponentUtils.findPage(context, component).getActionId())) {
+          && ajaxId.equals(FacesContextUtils.getActionId(context))) {
         Boolean immediate = (Boolean) reload.getAttributes().get(Attributes.IMMEDIATE);
         if (immediate != null && immediate) {
           Boolean update = (Boolean) reload.getAttributes().get(Attributes.UPDATE);

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/FormRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/FormRenderer.java?rev=1363830&r1=1363829&r2=1363830&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/FormRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/FormRenderer.java Fri Jul 20 15:17:22 2012
@@ -22,7 +22,7 @@ package org.apache.myfaces.tobago.render
  * $Id$
  */
 
-import org.apache.myfaces.tobago.internal.component.AbstractUIPage;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
 import org.apache.myfaces.tobago.renderkit.RendererBase;
 import org.apache.myfaces.tobago.util.ComponentUtils;
 
@@ -34,8 +34,7 @@ public class FormRenderer extends Render
 
   public void decode(FacesContext facesContext, UIComponent component) {
     UIForm form = (UIForm) component;
-    AbstractUIPage page = ComponentUtils.findPage(facesContext, form);
-    String actionId = page.getActionId();
+    String actionId = FacesContextUtils.getActionId(facesContext);
     String clientId = form.getClientId(facesContext);
     if (actionId != null && actionId.startsWith(clientId)) {
       form.setSubmitted(true);

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java?rev=1363830&r1=1363829&r2=1363830&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java Fri Jul 20 15:17:22 2012
@@ -22,7 +22,7 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.component.UIIn;
 import org.apache.myfaces.tobago.context.ResourceManagerUtils;
 import org.apache.myfaces.tobago.internal.component.AbstractUIInput;
-import org.apache.myfaces.tobago.internal.component.AbstractUIPage;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
 import org.apache.myfaces.tobago.model.AutoSuggestExtensionItem;
 import org.apache.myfaces.tobago.model.AutoSuggestItem;
 import org.apache.myfaces.tobago.model.AutoSuggestItems;
@@ -56,8 +56,7 @@ public class InRenderer extends InputRen
   public void decode(FacesContext facesContext, UIComponent component) {
     super.decode(facesContext, component);
     String clientId = component.getClientId(facesContext);
-    AbstractUIPage page = ComponentUtils.findPage(component);
-    if (clientId.equals(page.getActionId())) {
+    if (clientId.equals(FacesContextUtils.getActionId(facesContext))) {
       // this is a inputSuggest request -> render response
       facesContext.renderResponse();
     }
@@ -71,8 +70,7 @@ public class InRenderer extends InputRen
     }
 
     String clientId = component.getClientId(facesContext);
-    AbstractUIPage page = ComponentUtils.findPage(component);
-    if (clientId.equals(page.getActionId())) {
+    if (clientId.equals(FacesContextUtils.getActionId(facesContext))) {
       // this is a inputSuggest
       encodeAjax(facesContext, component);
     } else {

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java?rev=1363830&r1=1363829&r2=1363830&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java Fri Jul 20 15:17:22 2012
@@ -18,6 +18,7 @@ package org.apache.myfaces.tobago.render
  */
 
 import org.apache.myfaces.tobago.context.ResourceManagerUtils;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
 import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -35,7 +36,7 @@ public abstract class CommandRendererBas
     if (ComponentUtils.isOutputOnly(component)) {
       return;
     }
-    String actionId = ComponentUtils.findPage(facesContext, component).getActionId();
+    String actionId = FacesContextUtils.getActionId(facesContext);
     String clientId = component.getClientId(facesContext);
     if (LOG.isDebugEnabled()) {
       LOG.debug("actionId = '" + actionId + "'");