Bruce Stemplewski
Bruce Stemplewski

Reputation: 1343

An error occured while updating some of the page xhr cancelled with Submit button

Apparenty there seems to be some sort of problem in xpages with submit buttons and IE. So I had to set the submit button as follows.

<xp:button value="Submit" id="button2" type="submit">
        <xp:eventHandler event="onclick" submit="true" refreshMode="partial" refreshId="panelErrMsg" immediate="false" save="true">

When I do I get "an error occured while updating some of the page xhr cancelled" then pressing enter or clicking the button. As long as the button is not type submit it works fine but of course I need to click the button and I would like to have the option of pressing enter.

The submit button is the only button on the form.

Update: Here is a full example demonstrating the issue:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">Unique Number:&#160;

    <xp:text escape="true" id="computedField1" value="#{javascript:@Unique();}"></xp:text>
    <xp:br></xp:br>
<xp:button id="button1" value="Update" type="submit">
    <xp:eventHandler event="onclick" submit="true"
        refreshMode="partial" refreshId="computedField1">
    </xp:eventHandler>
</xp:button>

Upvotes: 0

Views: 2513

Answers (2)

Sven Hasselbach
Sven Hasselbach

Reputation: 10485

An error occurs because of the combination of a sumbit button and a partial refresh.

The partial refresh is processed asynchronously, which means that the partial refresh (a xhr call) is sent to the server and then let the browser continue "his work". Instead of waiting for the response the form is now submitted, and the xhr call is canceled. The cancellation of the xhr call pops up the alert.

There are two workarounds:

  1. Instead of performing an asynchronous xhr call, do a synchronous call.
  2. Override the Error method of the partial refresh

    <xp:eventHandler event="onclick" submit="true"
     refreshMode="partial" refreshId="computedField1" onError="return" > 
    </xp:eventHandler>
    

UPDATE 21.06.2013

Here is the code for doing a sync xhr call:

// --- hijack dojo XHR calls
if( !dojo._xhr )
    dojo._xhr = dojo.xhr; 

var loadOld;

function hijacked( response, ioArgs ){
   dojo.xhr = dojo._xhr;
   delete dojo._xhr;
   loadOld( response, ioArgs ); // call the original function    
}

dojo.xhr = function( mode, args, bool ){
    args["sync"] = true;
    loadOld = args["load"];
    args["load"] = hijacked;

    dojo._xhr( mode, args, bool );
}

The code overwrites the exsiting Dojo functions for xhr Calls to set the required parameter sync to true. If the partial refresh is finished the original functionality is restored.

Upvotes: 3

stwissel
stwissel

Reputation: 20384

When you set it to refreshMode="full" then you will get the full error message. The "an error occurred" message is displayed when the submit results in a Error condition, that would show in a full submission. Change it and see the error message.

Upvotes: 1

Related Questions