Here is the scenario…

You have a text edit box, and when you leave that field (onBur) you fire a partial refresh to update some other values on the page.  Now since it is refreshed the focus of the cursor may not be where the user clicked on the form, worse – what if the user clicked a cancel button or another button?  The user will have to click it twice, once for the partial refresh and then once to fire the button.

With a little help from Paul Withers i think i have found a good solution to this issue.

First on the Xpage in the onClientLoad() event lets declare our 2 variables

var cancelRefresh = "";
var focusOnMe = "";

Next we go to the field with the onBlur() event that fires the partial update.

Click on the onBlur() event, then click on the client tab.  In the script area enter this code where yourfieldid is the id of the field you are editing.

if(dojo.byId("#{id:yourfieldid}").value ==""){return false};
if(cancelRefresh =="Yes"){
cancelRefresh ="";
return false;
}

Next we are going to go to the outline.  In the Outline you can expand the field and see event handlers.  Click on the event handlers, then the properties tab to the right.

Then scroll down until you see the onComplete property.  Click on it and enter this code.

if(focusOnMe != ""){
dojo.byId(focusOnMe).focus();
focusOnMe =""
}

This will focus on the field we just clicked on.

The next step is to go to a button, like a cancel button, or to a field.  Click on the onMouseDown event and enter this code on the Client tab.

For a button, tell it not to update

cancelRefresh ="Yes"

For a field, tell it where to focus, where yourfieldid is the id of the field

focusOnMe = "#{id:yourfieldid}"

That should get you immediate actions on your buttons and focus on the fields you click on after the refresh has occurred.