You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by sm...@apache.org on 2007/05/21 23:48:38 UTC

svn commit: r540310 - in /portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed: common.js desktop/core.js

Author: smilek
Date: Mon May 21 14:48:37 2007
New Revision: 540310

URL: http://svn.apache.org/viewvc?view=rev&rev=540310
Log:
For desktop only, changed values returned by createActionURL and createRenderURL to be regular urls (instead of 'javascript:doRender()/doAction()' statement). Added desktop /render pipeline, which is equivalent to /portlet pipeline except for the addition of the DesktopEncoderRedirectValveImpl (used by the /render pipeline (desktop-render-pipeline) to allow render requests that are not initiated via desktop javascript code to result in a page level navigation to the /desktop pipeline with the correct portlet rendering indicated in the original url).

Modified:
    portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/common.js
    portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/desktop/core.js

Modified: portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/common.js
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/common.js?view=diff&rev=540310&r1=540309&r2=540310
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/common.js (original)
+++ portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/common.js Mon May 21 14:48:37 2007
@@ -274,6 +274,8 @@
     DESKTOP: null,    //   /jetspeed/desktop
     PORTAL: null,     //   /jetspeed/portal
     PORTLET: null,    //   /jetspeed/portlet
+    ACTION: null,     //   /jetspeed/action
+    RENDER: null,     //   /jetspeed/render
     initialized: false
 };
 
@@ -318,7 +320,9 @@
     jetspeed.url.path.DESKTOP = jetspeed.url.path.JETSPEED + "/desktop";
     jetspeed.url.path.PORTAL = jetspeed.url.path.JETSPEED + "/portal";
     jetspeed.url.path.PORTLET = jetspeed.url.path.JETSPEED + "/portlet";
-    
+    jetspeed.url.path.ACTION = jetspeed.url.path.JETSPEED + "/action";
+    jetspeed.url.path.RENDER = jetspeed.url.path.JETSPEED + "/render";
+
     jetspeed.url.path.initialized = true;
 };
 jetspeed.url.parse = function( url )

Modified: portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/desktop/core.js
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/desktop/core.js?view=diff&rev=540310&r1=540309&r2=540310
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/desktop/core.js (original)
+++ portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/desktop/core.js Mon May 21 14:48:37 2007
@@ -204,7 +204,7 @@
 //jetspeed.debugContentDumpIds = [ "page-.*" ];                   // dump page psml response
 //jetspeed.debugContentDumpIds = [ "js-cp-selector.2" ];          // dump portlet selector content
 //jetspeed.debugContentDumpIds = [ "moveabs-layout" ];            // dump move layout response
-
+//jetspeed.debugContentDumpIds = [ "js-cp-selector.*" ];          // dump portlet selector
 // ... load page /portlets
 jetspeed.page = null ;
 jetspeed.initializeDesktop = function()
@@ -497,61 +497,40 @@
             else
                 dojo.debug( "doAction [" + portletEntityId + "] url: " + bindArgs.url + " form: " + jetspeed.debugDumpForm( bindArgs.formNode ) );
         }
-        targetPortlet.retrieveContent( new jetspeed.om.PortletActionContentListener(), bindArgs );
+        targetPortlet.retrieveContent( new jetspeed.om.PortletActionContentListener( bindArgs ), bindArgs );
     }
 };
 
 jetspeed.portleturl =
 {
-    JAVASCRIPT_ACTION_PREFIX: "javascript:doAction",
-    JAVASCRIPT_RENDER_PREFIX: "javascript:doRender",
+    DESKTOP_ACTION_PREFIX_URL: null,
+    DESKTOP_RENDER_PREFIX_URL: null,
     JAVASCRIPT_ARG_QUOTE: "&" + "quot;",
     PORTLET_REQUEST_ACTION: "action",
     PORTLET_REQUEST_RENDER: "render",
     JETSPEED_DO_NOTHING_ACTION: "javascript:jetspeed.doNothingNav()",
 
-    parseJSPseudoUrlActionRender: function( /* String */ javascriptPseudoUrl )
+    parseContentUrlForDesktopActionRender: function( /* String */ contentUrl )
     {
+        if ( this.DESKTOP_ACTION_PREFIX_URL == null )
+            this.DESKTOP_ACTION_PREFIX_URL = jetspeed.url.basePortalUrl() + jetspeed.url.path.ACTION ;
+        if ( this.DESKTOP_RENDER_PREFIX_URL == null )
+            this.DESKTOP_RENDER_PREFIX_URL = jetspeed.url.basePortalUrl() + jetspeed.url.path.RENDER ;
         var op = null;
-        var justTheUrl = javascriptPseudoUrl;
+        var justTheUrl = contentUrl;
         var entityId = null;
-        var argsSuffix = null;
-        if ( javascriptPseudoUrl && javascriptPseudoUrl.length > this.JAVASCRIPT_ACTION_PREFIX.length && javascriptPseudoUrl.indexOf( this.JAVASCRIPT_ACTION_PREFIX ) == 0 )
+        if ( contentUrl && contentUrl.length > this.DESKTOP_ACTION_PREFIX_URL.length && contentUrl.indexOf( this.DESKTOP_ACTION_PREFIX_URL ) == 0 )
         {   // annotate away javascript invocation in form action
-            justTheUrl = null;
             op = jetspeed.portleturl.PORTLET_REQUEST_ACTION;
-            argsSuffix = javascriptPseudoUrl.substring( this.JAVASCRIPT_ACTION_PREFIX.length );
         }
-        else if ( javascriptPseudoUrl && javascriptPseudoUrl.length > this.JAVASCRIPT_RENDER_PREFIX.length && javascriptPseudoUrl.indexOf( this.JAVASCRIPT_RENDER_PREFIX ) == 0 )
+        else if ( contentUrl && contentUrl.length > this.DESKTOP_RENDER_PREFIX_URL.length && contentUrl.indexOf( this.DESKTOP_RENDER_PREFIX_URL ) == 0 )
         {
-            justTheUrl = null;
             op = jetspeed.portleturl.PORTLET_REQUEST_RENDER;
-            argsSuffix = javascriptPseudoUrl.substring( this.JAVASCRIPT_RENDER_PREFIX.length );
         }
-        if ( argsSuffix != null )
+        if ( op != null )
         {
-            var quoteDelim = "\"";
-            var argsEnd = argsSuffix.lastIndexOf( quoteDelim );
-            var altargsEnd = argsSuffix.lastIndexOf( this.JAVASCRIPT_ARG_QUOTE );
-            if ( altargsEnd > argsEnd )
-            {
-                quoteDelim = this.JAVASCRIPT_ARG_QUOTE;
-                argsEnd = altargsEnd;
-            }
-            if ( argsEnd >= 0 )
-            {
-                argsSuffix = dojo.string.trim( argsSuffix.substring( 0, argsEnd + quoteDelim.length ) );
-                var argsData = argsSuffix.split( quoteDelim );
-                if ( argsData && argsData.length >=4 )
-                {
-                    justTheUrl = argsData[1];
-                    entityId = argsData[3];
-                }
-            }
-        }
-        else
-        {
-            op = null;
+            entityId = jetspeed.url.getQueryParameter( contentUrl, "entity" );
+            //dojo.debug( "portlet-url op=" + op  + " entity=" + entityId + " url=" + contentUrl );  
         }
         
         if ( ! jetspeed.url.validateUrlStartsWithHttp( justTheUrl ) )
@@ -2844,7 +2823,7 @@
                     var cForm = formList[i];                    
                     var cFormAction = cForm.action;
 
-                    var parsedPseudoUrl = jetspeed.portleturl.parseJSPseudoUrlActionRender( cFormAction );
+                    var parsedPseudoUrl = jetspeed.portleturl.parseContentUrlForDesktopActionRender( cFormAction );
                     
                     var submitOperation = parsedPseudoUrl.operation;
 
@@ -2865,12 +2844,12 @@
                         var formBind = new jetspeed.om.ActionRenderFormBind( cForm, null, this.entityId, null );
                         //  ^^^ formBind serves as an event hook up - retained ref is not needed
                         
-                        if ( djConfig.isDebug )
+                        if ( debugOn )
                             dojo.debug( "postParseAnnotateHtml [" + this.entityId + "] form action attribute is empty - adding FormBind with expectation that form action will be set via script" ) ;
                     }
                     else
                     {
-                        if ( djConfig.isDebug )
+                        if ( debugOn )
                             dojo.debug( "postParseAnnotateHtml [" + this.entityId + "] form action attribute doesn't match annotation criteria, leaving as is: " + cFormAction ) ;
                     }
                 }
@@ -2883,7 +2862,7 @@
                     var aNode = aList[i];
                     var aHref = aNode.href;
                     
-                    var parsedPseudoUrl = jetspeed.portleturl.parseJSPseudoUrlActionRender( aHref );
+                    var parsedPseudoUrl = jetspeed.portleturl.parseContentUrlForDesktopActionRender( aHref );
                     var replacementHref = jetspeed.portleturl.generateJSPseudoUrlActionRender( parsedPseudoUrl );
 
                     if ( ! replacementHref )
@@ -3076,35 +3055,38 @@
 
     getPortletUrl: function( bindArgs )
     {
-        var queryString = "";
+        var modUrl = null;
+        if ( bindArgs && bindArgs.url )
+        {
+            modUrl = bindArgs.url;
+        }
+        else if ( bindArgs && bindArgs.formNode )
+        {
+            var formAction = bindArgs.formNode.getAttribute( "action" );
+            if ( formAction )
+                modUrl = formAction;
+        }
+        if ( modUrl == null )
+            modUrl = jetspeed.url.basePortalUrl() + jetspeed.url.path.PORTLET + jetspeed.page.getPath();
+
         if ( ! bindArgs.dontAddQueryArgs )
         {
-            queryString += "?entity=" + this.entityId + "&portlet=" + this.name + "&encoder=desktop";
+            modUrl = jetspeed.url.parse( modUrl );
+            modUrl = jetspeed.url.addQueryParameter( modUrl, "entity", this.entityId, true );
+            modUrl = jetspeed.url.addQueryParameter( modUrl, "portlet", this.name, true );
+            modUrl = jetspeed.url.addQueryParameter( modUrl, "encoder", "desktop", true );
             if ( bindArgs.jsPageUrl != null )
             {
                 var jsPageUrlQuery = bindArgs.jsPageUrl.query;
                 if ( jsPageUrlQuery != null && jsPageUrlQuery.length > 0 )
                 {
-                    queryString += "&" + jsPageUrlQuery;
+                    modUrl = modUrl.toString() + "&" + jsPageUrlQuery;
                 }
             }
         }
         
-        var modUrl = null;
-        if ( bindArgs && bindArgs.url )
-        {
-            modUrl = bindArgs.url + queryString;
-        }
-        else if ( bindArgs && bindArgs.formNode )
-        {
-            var formAction = bindArgs.formNode.getAttribute( "action" );
-            if ( formAction )
-                modUrl = formAction + queryString;
-        }
-        if ( modUrl == null )
-            modUrl = jetspeed.url.basePortalUrl() + jetspeed.url.path.PORTLET + jetspeed.page.getPath() + queryString;
         if ( bindArgs )
-            bindArgs.url = modUrl;
+            bindArgs.url = modUrl.toString();
         return modUrl;
     },
 
@@ -3203,7 +3185,7 @@
     retrieveContent: function( contentListener, bindArgs, suppressGetActions )
     {
         if ( contentListener == null )
-            contentListener = new jetspeed.om.PortletContentListener( suppressGetActions );
+            contentListener = new jetspeed.om.PortletContentListener( suppressGetActions, bindArgs );
 
         if ( ! bindArgs )
             bindArgs = {};
@@ -3318,6 +3300,7 @@
 
     this.entityId = portletEntityId;
     this.submitOperation = submitOperation;
+    this.formSubmitInProgress = false;
 };
 dojo.inherits( jetspeed.om.ActionRenderFormBind, dojo.io.FormBind );
 dojo.lang.extend( jetspeed.om.ActionRenderFormBind,
@@ -3369,7 +3352,9 @@
     onSubmit: function( cForm )
     {
         var proceed = true;
-        if ( jetspeed.debug.confirmOnSubmit )
+        if ( this.isFormSubmitInProgress() )
+            proceed = false;
+        else if ( jetspeed.debug.confirmOnSubmit )
         {
             if ( ! confirm( "Click OK to submit." ) )
             {
@@ -3383,9 +3368,13 @@
     {
         if ( e )
 		    e.preventDefault();
-		if( this.onSubmit( this.form ) )
+        if ( this.isFormSubmitInProgress() )
+        {
+            // do nothing
+        }
+		else if( this.onSubmit( this.form ) )
         {
-            var parsedPseudoUrl = jetspeed.portleturl.parseJSPseudoUrlActionRender( this.form.action );
+            var parsedPseudoUrl = jetspeed.portleturl.parseContentUrlForDesktopActionRender( this.form.action );
 
             var mixInBindArgs = {};
             if ( parsedPseudoUrl.operation == jetspeed.portleturl.PORTLET_REQUEST_ACTION || parsedPseudoUrl.operation == jetspeed.portleturl.PORTLET_REQUEST_RENDER )
@@ -3399,23 +3388,33 @@
 
             if ( this.submitOperation == jetspeed.portleturl.PORTLET_REQUEST_RENDER || this.submitOperation == jetspeed.portleturl.PORTLET_REQUEST_ACTION )
             {
+                this.isFormSubmitInProgress( true );
                 mixInBindArgs.formFilter = dojo.lang.hitch( this, "formFilter" );
+                mixInBindArgs.submitFormBindObject = this;
                 if ( this.submitOperation == jetspeed.portleturl.PORTLET_REQUEST_RENDER )
                 {
-                    doRender( dojo.lang.mixin(this.bindArgs, mixInBindArgs ), this.entityId );
+                    jetspeed.doRender( dojo.lang.mixin(this.bindArgs, mixInBindArgs ), this.entityId );
                 }
                 else
                 {
-                    doAction( dojo.lang.mixin(this.bindArgs, mixInBindArgs ), this.entityId );
+                    jetspeed.doAction( dojo.lang.mixin(this.bindArgs, mixInBindArgs ), this.entityId );
                 }
             }
             else
             {
-                var errMsg = "ActionRenderFormBind.submit cannot process form submit with action:" + this.form.action;
-                alert( errMsg );
+                //var errMsg = "ActionRenderFormBind.submit cannot process form submit with action:" + this.form.action;
+                //alert( errMsg );
             }
 		}
-	}
+	},
+    isFormSubmitInProgress: function( setVal )
+    {
+        if ( setVal != undefined )
+        {
+            this.formSubmitInProgress = setVal;
+        }
+        return this.formSubmitInProgress;
+    }
 });
 
 // ... jetspeed.om.FolderDef
@@ -3502,9 +3501,14 @@
 };
 
 // ... jetspeed.om.PortletContentListener
-jetspeed.om.PortletContentListener = function( suppressGetActions )
+jetspeed.om.PortletContentListener = function( suppressGetActions, bindArgs )
 {
     this.suppressGetActions = suppressGetActions;
+    this.submittedFormBindObject = null;
+    if ( bindArgs != null && bindArgs.submitFormBindObject != null )
+    {
+        this.submittedFormBindObject = bindArgs.submitFormBindObject;
+    }
 };
 jetspeed.om.PortletContentListener.prototype =
 {
@@ -3520,32 +3524,45 @@
         portlet.setPortletContent( portletContent, requestUrl, portletTitle );
         if ( this.suppressGetActions == null || this.suppressGetActions == false )
             jetspeed.getActionsForPortlet( portlet.getId() );
+        if ( this.submittedFormBindObject != null )
+        {
+            this.submittedFormBindObject.isFormSubmitInProgress( false );
+        }
     },
     notifyFailure: function( /* String */ type, /* Object */ error, /* String */ requestUrl, /* Portlet */ portlet )
     {
+        if ( this.submittedFormBindObject != null )
+        {
+            this.submittedFormBindObject.isFormSubmitInProgress( false );
+        }
         dojo.raise( "PortletContentListener notifyFailure url: " + requestUrl + " type: " + type + jetspeed.url.formatBindError( error ) );
     }
 };
 
 // ... jetspeed.om.PortletActionContentListener
-jetspeed.om.PortletActionContentListener = function()
+jetspeed.om.PortletActionContentListener = function( bindArgs )
 {
+    this.submittedFormBindObject = null;
+    if ( bindArgs != null && bindArgs.submitFormBindObject != null )
+    {
+        this.submittedFormBindObject = bindArgs.submitFormBindObject;
+    }
 };
 jetspeed.om.PortletActionContentListener.prototype =
 {
     notifySuccess: function( /* String */ portletContent, /* String */ requestUrl, /* Portlet */ portlet, http )
     {
         var renderUrl = null;
-        var parsedPseudoUrl = jetspeed.portleturl.parseJSPseudoUrlActionRender( portletContent );
+        var parsedPseudoUrl = jetspeed.portleturl.parseContentUrlForDesktopActionRender( portletContent );
         if ( parsedPseudoUrl.operation == jetspeed.portleturl.PORTLET_REQUEST_ACTION || parsedPseudoUrl.operation == jetspeed.portleturl.PORTLET_REQUEST_RENDER )
         {
-            if ( djConfig.isDebug )
+            if ( jetspeed.debug.doRenderDoAction )
                 dojo.debug( "PortletActionContentListener extracted from javascript-pseudo-url: " + portletContent + "  url: " + parsedPseudoUrl.url + " operation: " + parsedPseudoUrl.operation + " entity-id: " + parsedPseudoUrl.portletEntityId ) ;
             renderUrl = parsedPseudoUrl.url;
         }
         else
         {
-            if ( djConfig.isDebug )
+            if ( jetspeed.debug.doRenderDoAction )
                 dojo.debug( "PortletActionContentListener: " + portletContent )
             renderUrl = portletContent;
             if ( renderUrl )
@@ -3554,9 +3571,14 @@
                 if ( portletUrlPos == -1 )
                 {
                     if ( jetspeed.url.validateUrlStartsWithHttp( renderUrl ) )
+                    {
+                        //dojo.debug( "PortletActionContentListener window.location.href navigation=" + renderUrl );
                         window.location.href = renderUrl;
+                    }
                     else
+                    {
                         dojo.raise( "PortletActionContentListener cannot interpret action response: " + portletContent );
+                    }
                     renderUrl = null;
                 }
                 else if ( portletUrlPos > 0 )
@@ -3566,14 +3588,24 @@
                 }
             }
         }
-        if ( renderUrl )
+        if ( renderUrl != null )
         {
+            if ( jetspeed.debug.doRenderDoAction )
+                dojo.debug( "PortletActionContentListener calling doRenderAll=" + renderUrl );
             jetspeed.doRenderAll( renderUrl );    // render all portlets
             //  portlet.retrieveContent(null, { url: renderUrl } );    // render just the one portlet
         }
+        if ( this.submittedFormBindObject != null )
+        {
+            this.submittedFormBindObject.isFormSubmitInProgress( false );
+        }
     },
     notifyFailure: function( /* String */ type, /* Object */ error, /* String */ requestUrl, /* Portlet */ portlet )
     {
+        if ( this.submittedFormBindObject != null )
+        {
+            this.submittedFormBindObject.isFormSubmitInProgress( false );
+        }
         dojo.raise( "PortletActionContentListener notifyFailure type: " + type + jetspeed.url.formatBindError( error ) );
     }
 };



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org