Apr 5, 2012, 4:27 AM
56 Posts

executeOnServer() fails with new document

  • Category: Debugging
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 1
Hi,
 
I am using the executeOnServer function with a dialog, to ask the user if he want's to save a document when closing it.
 
Everything is working fine, but when I am creating a new document, this function doesn't work, no serverside eventhandler is executed.
 
Here is my code:
 
function executeOnServer() {
                // must supply event handler id or we're outta here....
                if (!arguments[0])
                    return false;
            
                // the ID of the event handler we want to execute
                var functionName = arguments[0];
            
                // OPTIONAL - The Client Side ID that you want to partial refresh after executing the event handler
                var refreshId = (arguments[1]) ? arguments[1] : "@none";
                var form = (arguments[1]) ? this.findForm(arguments[1]) : dojo.query('form')[0];
                   
                // catch all in case dojo element has moved object outside of form...
                if (!form)
                    form = dojo.query('form')[0];
            
                // OPTIONAL - Options object contianing onStart, onComplete and onError functions for the call to the
                // handler and subsequent partial refresh
                var options = (arguments[2]) ? arguments[2] : {};
            
                // OPTIONAL - Value to submit in $$xspsubmitvalue. can be retrieved using context.getSubmittedValue()
                var submitValue = (arguments[3]) ? arguments[3] : '';
            
                // Set the ID in $$xspsubmitid of the event handler to execute
                dojo.query('[name="$$xspsubmitid"]')[0].value = functionName;
                dojo.query('[name="$$xspsubmitvalue"]')[0].value = submitValue;
                XSP._partialRefresh("post", form, refreshId, options);        
            }
 
I am calling it here:
 
function( returnValue ) {
                                                        if (returnValue=="Yes") {
                                                            executeOnServer('#{id:eventhandler1a}')
                                                        } else if (returnValue=="No") {
                                                            executeOnServer('#{id:eventhandler1b}')
                                                        } else {
                                                            executeOnServer('#{id:eventhandler1c}')
                                                        }
                                                    }
 
 Like I've said, in a existing document, everything works fine, but when creating a new document, the program does not execute the serverside eventhandlers. I have checked it with print statements, and also the page isn't refreshed ( which is propably the reason why the eventhandlers aren't executed)
 
I've checked that the same information on the eventhandler is passed on, no matter whether I call it with a new or existing document.
The function executeOnServer is executed and all information are passed on correctly. Only the refresh doesn't seem to work.
 
Do you have any idea why it is failing with new documents?
 
Thanks in advance
 
Matthias Nicklisch
 
mnicklisch.wordpress.com
 
Apr 12, 2012, 5:43 AM
272 Posts
Re: executeOnServer() fails with new document
Hi,
 
the problem is caused by the following line:
 
   var form = (arguments[1]) ? this.findForm(arguments[1]) : dojo.query('form')[0];
 
where a not existing method is called. By changing this to
 
   var form = (arguments[1]) ? XSP.findForm(arguments[1]) : dojo.query('form')[0];
 
the function works as designed.
 
Sven