You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2007/09/20 14:19:58 UTC

svn commit: r577713 - in /myfaces/tomahawk/trunk/sandbox/core/src/main: java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java resources/org/apache/myfaces/custom/ppr/resource/ppr.js

Author: imario
Date: Thu Sep 20 05:19:58 2007
New Revision: 577713

URL: http://svn.apache.org/viewvc?rev=577713&view=rev
Log:
make ppr compatible to tomahawks subform

Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ppr/resource/ppr.js

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java?rev=577713&r1=577712&r2=577713&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java Thu Sep 20 05:19:58 2007
@@ -18,22 +18,11 @@
  */
 package org.apache.myfaces.custom.ppr;
 
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.custom.dojo.DojoConfig;
 import org.apache.myfaces.custom.dojo.DojoUtils;
+import org.apache.myfaces.custom.subform.SubForm;
 import org.apache.myfaces.renderkit.html.ext.HtmlGroupRenderer;
 import org.apache.myfaces.renderkit.html.util.AddResource;
 import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
@@ -42,6 +31,17 @@
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.util.FormInfo;
 
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 /**
  * @author Ernst Fastl
  */
@@ -56,7 +56,9 @@
 
     private static final String ADD_PARTIAL_TRIGGER_PATTERN_FUNCTION = "addPartialTriggerPattern";
 
-    private static final String ADD_INLINE_LOADING_MESSAGE_FUNCTION = "addInlineLoadingMessage";
+	private static final String SET_SUBFORM_ID_FUNCTION = "setSubFormId";
+
+	private static final String ADD_INLINE_LOADING_MESSAGE_FUNCTION = "addInlineLoadingMessage";
 
     private static final String PPR_JS_FILE = "ppr.js";
 
@@ -72,7 +74,7 @@
          * components are marked with the TRANSIENT_MARKER_ATTRIBUTE so the
          * {@link PPRPhaseListener} can reset them to transient in the next
          * non-PPR Request
-         * 
+         *
          * @param facesContext
          *                the current {@link FacesContext}
          * @param uiComponent
@@ -109,7 +111,7 @@
     /**
          * todo: in 1.2, better use a combo of
          * invokeComponent/RendererUtils.renderChildren() instead
-         * 
+         *
          * @param context
          * @param component
          * @throws IOException
@@ -126,7 +128,7 @@
          * Encodes the end of the span-element and afterwards the inline
          * JavaScript for the client side initialization of the
          * {@link PPRPanelGroup}.
-         * 
+         *
          * @param facesContext
          *                the current {@link FacesContext}
          * @param uiComponent
@@ -167,7 +169,7 @@
          * <li>Starting periodical updates</li>
          * <li>Registering inline Loading messages</li>
          * </ul>
-         * 
+         *
          * @param facesContext
          *                the current {@link FacesContext}
          * @param pprGroup
@@ -203,10 +205,10 @@
 	    String encoding = "UTF-8" ; // Hardcoded default
 	    if(facesContext.getResponseWriter().getCharacterEncoding() != null)
 		encoding = facesContext.getResponseWriter().getCharacterEncoding();
-	    
+
 	    DojoConfig currentConfig = DojoUtils.getDjConfigInstance(facesContext);
 	    currentConfig.setBindEncoding(encoding);
-	    
+
 	    String javascriptLocation = (String) pprGroup.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
 	    AddResource addResource = AddResourceFactory.getInstance(facesContext);
 	    DojoUtils.addMainInclude(facesContext, pprGroup, javascriptLocation, currentConfig);
@@ -303,7 +305,7 @@
 	String partialTriggers = pprGroup.getPartialTriggers();
 
 	String partialTriggerPattern = pprGroup.getPartialTriggerPattern();
-	
+
 	//handle partial trigger patterns
 	if (partialTriggerPattern != null && partialTriggerPattern.trim().length() > 0)
 	{
@@ -311,6 +313,12 @@
 		    + "','" + clientId + "');");
 	}
 
+	SubForm subFormParent = findParentSubForm(pprGroup);
+	if (subFormParent != null)
+	{
+		script.append(pprCtrlReference + "." + SET_SUBFORM_ID_FUNCTION + "('" + subFormParent.getId() + "');");
+	}
+
 	String inlineLoadingMessage = pprGroup.getInlineLoadingMessage();
 
 	//handle inline loading messages
@@ -351,12 +359,27 @@
 
 	// closing the dojo.addOnLoad call
 	script.append("});");
-	
+
 	//Really render the script
 	renderInlineScript(facesContext, pprGroup, script.toString());
     }
 
-    private String encodeArray(List eventHooks)
+	private SubForm findParentSubForm(UIComponent base)
+	{
+		if (base == null)
+		{
+			return null;
+		}
+
+		if (base instanceof SubForm)
+		{
+			return (SubForm) base;
+		}
+
+		return findParentSubForm(base.getParent());
+	}
+
+	private String encodeArray(List eventHooks)
     {
 	if (eventHooks == null || eventHooks.size() == 0)
 	{
@@ -384,7 +407,7 @@
     /**
          * Helper to write an inline javascript at the exact resource location
          * of the call.
-         * 
+         *
          * @param facesContext
          *                The current faces-context.
          * @param component

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ppr/resource/ppr.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ppr/resource/ppr.js?rev=577713&r1=577712&r2=577713&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ppr/resource/ppr.js (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ppr/resource/ppr.js Thu Sep 20 05:19:58 2007
@@ -29,7 +29,9 @@
     this.showDebugMessages = showDebugMessages;
     this.stateUpdate = stateUpdate;
 
-    if(!window.oamPartialTriggersToZoneIds)
+	this.subFormId = null;
+
+	if(!window.oamPartialTriggersToZoneIds)
 	{
     	window.oamPartialTriggersToZoneIds = new Array();
     }
@@ -51,6 +53,12 @@
 	this.reConnectEventHandlers();
 }
 
+// set the subform id this ppr belongs to
+org.apache.myfaces.PPRCtrl.prototype.setSubFormId= function(subFormId)
+{
+	this.subFormId = subFormId;
+};
+
 //Method to register individual HTML to be displayed instead of the component during loading
 
 org.apache.myfaces.PPRCtrl.prototype.addInlineLoadingMessage= function(message, refreshZoneId)
@@ -322,7 +330,11 @@
         requestUri = formAction.nodeValue;
     }
 
-    content["org.apache.myfaces.PPRCtrl.ajaxRequest"]="true";
+	if (this.subFormId != null)
+	{
+		content["org.apache.myfaces.custom.subform.submittedId"]=this.subFormId;
+	}
+	content["org.apache.myfaces.PPRCtrl.ajaxRequest"]="true";
 
     dojo.io.bind({
         url		: requestUri,
@@ -333,7 +345,7 @@
         mimetype: "text/xml",
         transport: "XMLHTTPTransport",
         formNode: this.form
-    });
+	});
 
     if(refreshTimeout && !this.blockPeriodicalUpdateDuringPost)
     {