You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mm...@apache.org on 2006/01/23 09:16:32 UTC

svn commit: r371487 - in /myfaces/tomahawk/trunk: core/src/main/java/org/apache/myfaces/component/html/ext/ core/src/main/java/org/apache/myfaces/custom/buffer/ sandbox/core/src/main/java/org/apache/myfaces/custom/subform/

Author: mmarinschek
Date: Mon Jan 23 00:16:20 2006
New Revision: 371487

URL: http://svn.apache.org/viewcvs?rev=371487&view=rev
Log:
Started architecture for callbacks, added some testing for getClientId and findComponent, moved the stuff I implemented in UIComponent for partial validation out to the new SubForm

Modified:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/buffer/BufferRenderer.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubForm.java

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java?rev=371487&r1=371486&r2=371487&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java Mon Jan 23 00:16:20 2006
@@ -33,6 +33,8 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.component.UserRoleAware;
 import org.apache.myfaces.component.UserRoleUtils;
+import org.apache.myfaces.component.ExecuteOnCapable;
+import org.apache.myfaces.component.ExecuteOnCallback;
 import org.apache.myfaces.custom.crosstable.UIColumns;
 import org.apache.myfaces.renderkit.JSFAttr;
 
@@ -41,7 +43,7 @@
  * @author Manfred Geiler
  * @version $Revision$ $Date$
  */
-public class HtmlDataTable extends HtmlDataTableHack implements UserRoleAware
+public class HtmlDataTable extends HtmlDataTableHack implements UserRoleAware, ExecuteOnCapable
 {
     private static final Log log = LogFactory.getLog(HtmlDataTable.class);
 
@@ -100,6 +102,12 @@
         return parsedForcedClientId;
     }
 
+    public Object executeOn(FacesContext facesContext, String clientId, ExecuteOnCallback executeOnCallback)
+    {
+        return null;
+    }
+
+
     public void setRowIndex(int rowIndex)
     {
         if(rowIndex < -1)
@@ -339,7 +347,7 @@
         if (_preservedDataModel != null)
         {
             //Rather get the currently restored DataModel attribute
-            return ((_SerializableDataModel) _preservedDataModel).getFirst();
+            return _preservedDataModel.getFirst();
         }
         else
         {
@@ -352,7 +360,7 @@
         if (_preservedDataModel != null)
         {
             //Also change the currently restored DataModel attribute
-            ((_SerializableDataModel) _preservedDataModel).setFirst(first);
+            _preservedDataModel.setFirst(first);
         }
         super.setFirst(first);
     }
@@ -362,7 +370,7 @@
         if (_preservedDataModel != null)
         {
             //Rather get the currently restored DataModel attribute
-            return ((_SerializableDataModel) _preservedDataModel).getRows();
+            return _preservedDataModel.getRows();
         }
         else
         {
@@ -375,7 +383,7 @@
         if (_preservedDataModel != null)
         {
             //Also change the currently restored DataModel attribute
-            ((_SerializableDataModel) _preservedDataModel).setRows(rows);
+            _preservedDataModel.setRows(rows);
         }
         super.setRows(rows);
     }
@@ -932,4 +940,6 @@
     }
 
     //------------------ GENERATED CODE END ---------------------------------------
+
+
 }

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/buffer/BufferRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/buffer/BufferRenderer.java?rev=371487&r1=371486&r2=371487&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/buffer/BufferRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/buffer/BufferRenderer.java Mon Jan 23 00:16:20 2006
@@ -46,7 +46,7 @@
         RendererUtils.checkParamValidity(facesContext, uiComponent, Buffer.class);
 
         initialWriter = facesContext.getResponseWriter();
-        bufferWriter = HtmlBufferResponseWriterWrapper.getInstance( initialWriter );
+        bufferWriter = HtmlBufferResponseWriterWrapper.getInstance(initialWriter );
         facesContext.setResponseWriter( bufferWriter );
     }
 

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubForm.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubForm.java?rev=371487&r1=371486&r2=371487&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubForm.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubForm.java Mon Jan 23 00:16:20 2006
@@ -2,6 +2,10 @@
 
 import javax.faces.component.UIComponentBase;
 import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import java.util.List;
+import java.util.Iterator;
 
 /**
  * @author Gerald Muellan
@@ -16,6 +20,10 @@
     public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.SubForm";
     public static final String COMPONENT_FAMILY = "javax.faces.Form";
 
+    private static final String PARTIAL_ENABLED = "org.apache.myfaces.IsPartialPhaseExecutionEnabled";
+    private static final String ACTION_FOR_LIST = "org.apache.myfaces.ActionForList";
+
+
     public SubForm()
     {
         super.setRendererType(DEFAULT_RENDERER_TYPE);
@@ -24,6 +32,84 @@
     public String getFamily()
     {
         return COMPONENT_FAMILY;
+    }
+
+    public void processValidators(FacesContext context)
+    {
+        if (context == null) throw new NullPointerException("context");
+        if (!isRendered()) return;
+
+        boolean tearDownRequired = setupPartialInfo(context);
+
+        for (Iterator it = getFacetsAndChildren(); it.hasNext(); )
+        {
+            UIComponent childOrFacet = (UIComponent)it.next();
+            childOrFacet.processValidators(context);
+        }
+
+        if(tearDownRequired)
+        {
+            tearDownPartialInfo(context);
+        }
+    }
+
+    /**Sets up information if this component is included in
+     * the group of components which are associated with the current action.
+     *
+     * @param context
+     * @return true if there has been a change by this setup which has to be undone after the phase finishes.
+     */
+    private boolean setupPartialInfo(FacesContext context)
+    {
+        //the following section is not in the spec
+        //there is no place to put it into the actual implementation, though
+        //we want to execute validation (and model update) only
+        //if certain conditions are met
+        //especially, we want to switch validation/update on/off depending on
+        //the attribute "actionFor" of a MyFaces extended button or link
+        //if you use commandButtons which don't set these
+        //request parameters, this won't cause any adverse effects
+        //except the additional performance hit of getting the request-parameter
+
+        //is it necessary to remove the request-parameter again?
+        boolean tearDownRequired = false;
+
+        //get the list of (parent) client-ids for which a validation should be performed
+        List li = (List) context.getExternalContext().getRequestMap().get(
+                ACTION_FOR_LIST);
+
+        //check if the list is existing at all - if not, we want to validate in any case.
+        if(li==null || li.size()==0)
+        {
+            if(!context.getExternalContext().getRequestMap().containsKey(PARTIAL_ENABLED))
+            {
+                context.getExternalContext().getRequestMap().put(PARTIAL_ENABLED,Boolean.TRUE);
+                tearDownRequired = true;
+            }
+        }
+        //if there is a list, check if the current client id
+        //matches an entry of the list
+        else if(li.contains(getClientId(context)))
+        {
+            if(!context.getExternalContext().getRequestMap().containsKey(PARTIAL_ENABLED))
+            {
+                context.getExternalContext().getRequestMap().put(PARTIAL_ENABLED,Boolean.TRUE);
+                tearDownRequired = true;
+            }
+        }
+
+        return tearDownRequired;
+    }
+
+    /**
+     * Remove the information about this component being included in the partial
+     * phase execution.
+     *
+     * @param context
+     */
+    private void tearDownPartialInfo(FacesContext context)
+    {
+        context.getExternalContext().getRequestMap().remove(PARTIAL_ENABLED);
     }