[gatein-commits] gatein SVN: r4392 - in portal/branches/navcontroller/web: eXoResources/src/main/webapp/javascript/eXo/webui and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Sep 27 04:02:59 EDT 2010


Author: trong.tran
Date: 2010-09-27 04:02:58 -0400 (Mon, 27 Sep 2010)
New Revision: 4392

Modified:
   portal/branches/navcontroller/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalHttpRequest.js
   portal/branches/navcontroller/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIForm.js
   portal/branches/navcontroller/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIRightClickPopupMenu.js
   portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UIRightClickPopupMenu.gtmpl
Log:
Use POST instead of GET method to submit a request in UIRightClickPopupMenu component

Modified: portal/branches/navcontroller/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalHttpRequest.js
===================================================================
--- portal/branches/navcontroller/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalHttpRequest.js	2010-09-27 07:25:55 UTC (rev 4391)
+++ portal/branches/navcontroller/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalHttpRequest.js	2010-09-27 08:02:58 UTC (rev 4392)
@@ -574,16 +574,12 @@
   doRequest("Get", url, null, callback) ;
 } ;
 
-/*
-* This method is called when a HTTP POST should be done but in an AJAX
-* case some maniputalions are needed
-* Once the content of the form is placed into a string object, the call
-* is delegated to the doRequest() method 
-*/
-function ajaxPost(formElement, callback) {
+/**
+ * Do a POST request in AJAX with given <code>url</code> and <code>queryString</code>.
+ * The call is delegated to the doRequest() method with a callback function
+ */
+function ajaxPost(url, queryString, callback) {
   if (!callback) callback = null ;
-  var queryString = eXo.webui.UIForm.serializeForm(formElement) ;
-  var url = formElement.action + "&ajaxRequest=true" ;
   doRequest("POST", url, queryString, callback) ;
 } ;
 
@@ -613,6 +609,7 @@
 	  eXo.session.itvInit() ;
   }
 }	;
+
 /**
  * Abort an ajax request
  * @return
@@ -625,6 +622,7 @@
   eXo.portal.CurrentRequest.aborted = true ;
   eXo.portal.CurrentRequest = null ;
 } ;
+
 /**
  * Create a ajax request
  * @param {String} url - Url
@@ -643,6 +641,7 @@
   }
 	if(!async) return request.responseText ;
 }
+
 /**
  * Redirect browser to url
  * @param url

Modified: portal/branches/navcontroller/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIForm.js
===================================================================
--- portal/branches/navcontroller/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIForm.js	2010-09-27 07:25:55 UTC (rev 4391)
+++ portal/branches/navcontroller/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIForm.js	2010-09-27 08:02:58 UTC (rev 4392)
@@ -22,7 +22,21 @@
  */
 function UIForm() {
 };
+
 /**
+ * This method is called when a HTTP POST should be done but in an AJAX
+ * case some maniputalions are needed
+ * Once the content of the form is placed into a string object, the call
+ * is delegated to the doRequest() method 
+ */
+UIForm.prototype.ajaxPost = function(formElement, callback) {
+  if (!callback) callback = null ;
+  var queryString = eXo.webui.UIForm.serializeForm(formElement) ;
+  var url = formElement.action + "&ajaxRequest=true" ;
+  doRequest("POST", url, queryString, callback) ;
+} ;
+
+/**
  * Get form element with pattern condition
  * @param {String} pattern
  * The pattern can  be Id#Id, example: Account#UIAccountForm
@@ -36,7 +50,7 @@
 
 /**
  * A function that submits the form identified by formId, with the specified action
- * If useAjax is true, calls the ajaxPost function from PortalHttpRequest, with the given callback function
+ * If useAjax is true, calls the ajaxPost function, with the given callback function
  * Note: ie bug  you cannot have more than one button tag
  */
 UIForm.prototype.submitForm = function(formId, action, useAjax, callback) {
@@ -60,13 +74,13 @@
  } catch(e) {}
 
   form.elements['formOp'].value = action ;
-  if(useAjax) ajaxPost(form, callback) ;
+  if(useAjax) this.ajaxPost(form, callback) ;
   else  form.submit();
 } ;
 
 /**
  * Submits a form by Ajax, with the given action and the given parameters
- * Calls ajaxPost of PortalHttpRequest
+ * Calls ajaxPost
  * Note: ie bug  you cannot have more than one button tag
  */
 UIForm.prototype.submitEvent = function(formId, action, params) {
@@ -84,7 +98,7 @@
   form.elements['formOp'].value = action ; 
   if(!form.originalAction) form.originalAction = form.action ; 
 	form.action =  form.originalAction +  encodeURI(params) ;
-  ajaxPost(form) ;
+  this.ajaxPost(form) ;
 } ;
 
 UIForm.prototype.selectBoxOnChange = function(formId, elemt) {

Modified: portal/branches/navcontroller/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIRightClickPopupMenu.js
===================================================================
--- portal/branches/navcontroller/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIRightClickPopupMenu.js	2010-09-27 07:25:55 UTC (rev 4391)
+++ portal/branches/navcontroller/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIRightClickPopupMenu.js	2010-09-27 08:02:58 UTC (rev 4392)
@@ -72,9 +72,15 @@
 		eXo.core.MouseEventManager.docMouseDownEvt(evt) ;
 		return false;
 	}
-	elemt.setAttribute('href', href.replace('_objectid_', encodeURI(contextMenu.objId.replace(/'/g, "\\'")))) ;
+	elemt.setAttribute('href', href += '&objectId=' + encodeURI(contextMenu.objId.replace(/'/g, "\\'"))) ;
 	return true;
 }
+
+UIRightClickPopupMenu.prototype.ajaxPost = function(url, objId) {
+  var queryString = "ajaxRequest=true&objectId=" + objId;
+  ajaxPost(url, queryString);
+}
+
 /**
  * Mouse click on element, If click is right-click, the context menu will be shown
  * @param {Object} event

Modified: portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UIRightClickPopupMenu.gtmpl
===================================================================
--- portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UIRightClickPopupMenu.gtmpl	2010-09-27 07:25:55 UTC (rev 4391)
+++ portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UIRightClickPopupMenu.gtmpl	2010-09-27 08:02:58 UTC (rev 4392)
@@ -18,12 +18,12 @@
 					<%for(action in uicomponent.getActions()) {%>
 					
 					 	<div class="MenuItem"> 	
-							<a exo:attr="$action" href="<%=uicomponent.event(action,"_objectid_");%>" onclick="return eXo.webui.UIRightClickPopupMenu.prepareObjectId(event, this);" class="ItemIcon ${action}16x16Icon" >
+							<a exo:attr="$action" href="javascript: eXo.webui.UIRightClickPopupMenu.ajaxPost('<%=uicomponent.url(action);%>', '_objectid_')" onclick="return eXo.webui.UIRightClickPopupMenu.prepareObjectId(event, this);" class="ItemIcon ${action}16x16Icon" >
 								<%=_ctx.appRes(uicomponent.getId() + ".event." + action) %>
 							</a>
 					 	</div>						
 					<%}%>
-				<div class="RightClickCustomItem"><span></span></div>
+				  <div class="RightClickCustomItem"><span></span></div>
 				</div>
 		
 			</div>



More information about the gatein-commits mailing list