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 2007/05/04 07:20:01 UTC

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

Author: mmarinschek
Date: Thu May  3 22:20:00 2007
New Revision: 535097

URL: http://svn.apache.org/viewvc?view=rev&rev=535097
Log:
fix for TOMAHAWK-758: Enable traditional submit for exceptions. Thanks to Ernst Fastl.

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

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?view=diff&rev=535097&r1=535096&r2=535097
==============================================================================
--- 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 May  3 22:20:00 2007
@@ -47,13 +47,15 @@
     this.addButtonOnClickHandlers();
 }
 
-//Method for JSF Components to register Regular Expressions for partial update triggering
+//Method to register individual HTML to be displayed instead of the component during loading
 
 org.apache.myfaces.PPRCtrl.prototype.addInlineLoadingMessage= function(message, refreshZoneId)
 {
         window.myFacesInlineLoadingMessage[refreshZoneId] = message;
 };
 
+//Method for JSF Components to register Regular Expressions for partial update triggering
+
 org.apache.myfaces.PPRCtrl.prototype.addPartialTriggerPattern= function(pattern, refreshZoneId)
 {
         window.myFacesPartialTriggerPatterns[refreshZoneId] = pattern;
@@ -116,6 +118,14 @@
     if(type == "load" && !this.blockPeriodicalUpdateDuringPost)
     {
 	    var componentUpdates = data.getElementsByTagName("component");
+	    
+	    //In case no componentUpdates are returned the response is considered 
+	    //invalid - do a normal submit to get the corresponding error page
+	    if(componentUpdates == null || componentUpdates.length == 0) {
+	    	this.formNode.myFacesPPRCtrl.callbackErrorHandler();
+	    	return;	
+	    }
+	    
 	    var componentUpdate = null;
 	    var domElement = null;
 		for (var i = 0; i < componentUpdates.length; i++)
@@ -157,10 +167,45 @@
     }
     else if(this.showDebugMessages)
     {
-        alert("an Error occured during the ajax-request " + data.message);
+    // In case of an error during the AJAX Request do a normal form submit
+    // to enable showing a proper error page
+    this.formNode.myFacesPPRCtrl.callbackErrorHandler();
     }
 }
 
+org.apache.myfaces.PPRCtrl.prototype.callbackErrorHandler = function() {
+	if(typeof this.lastSubmittedElement == "undefined") {
+		alert("An unexpected error occured during an ajax-request - page has been fully submitted!");
+		this.form.submit_orig();
+	}
+	
+	var formName = this.form.id;
+
+    if(typeof formName == "undefined")
+    {
+        formName = this.form.name;
+    }
+	
+	var triggerElement = this.lastSubmittedElement;
+	
+	if (triggerElement.tagName.toLowerCase() == "input" &&
+                (triggerElement.type.toLowerCase() == "submit" ||
+                 triggerElement.type.toLowerCase() == "image")
+                )
+            {
+            	var hiddenInputName = triggerElement.name;
+            	//Rename the button that we can insert a hidden input
+            	//that simulates a click of the submit-button
+            	triggerElement.name = "changed" + triggerElement.name;
+            	oamSetHiddenInput(formName,hiddenInputName,triggerElement.value);
+            }
+            else
+            {
+        		oamSetHiddenInput(formName,formName +':'+'_idcl',triggerElement.id);
+        	} 
+	this.form.submit_orig();
+}
+
 //This Method checks if an AJAX Call is to be done instead of submitting the form
 //as usual. If so it uses dojo.bind to submit the mainform via AJAX
 
@@ -181,6 +226,8 @@
     	if(typeof triggerElement != "undefined")
     	{
     		triggerId=triggerElement.id;
+    		
+    		this.lastSubmittedElement=triggerElement;
 
             if (triggerElement.tagName.toLowerCase() == "input" &&
                 (triggerElement.type.toLowerCase() == "submit" ||

Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/ppr/PPRExampleBean.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/ppr/PPRExampleBean.java?view=diff&rev=535097&r1=535096&r2=535097
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/ppr/PPRExampleBean.java (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/ppr/PPRExampleBean.java Thu May  3 22:20:00 2007
@@ -21,6 +21,7 @@
 
 import org.apache.myfaces.examples.inputSuggestAjax.Address;
 
+import javax.faces.FacesException;
 import javax.faces.event.ValueChangeEvent;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -68,6 +69,10 @@
 
         if(_textField == null || _textField.equals(""))
             return null;
+	
+	public String testExceptionAction() {
+		throw new FacesException("Test PPR Exception Handling");
+	}
 
         for (Iterator iterator = _names.iterator(); iterator.hasNext();)
         {