Search code examples
xpages

How to prevent full refresh using onChange event SSJS


(You may be able to figure out an answer by ONLY reading the last question by itself, but I included everything for reference if necessary)

The onChange of one field is causing displayErrors to show validation results prior to when I need it to do that.

On an xpage, I have these two comboboxes: 1.) locationType 2.) locationEtc

Choices for locationEtc are dependent on what was selected in locationType field.

In the locationEtc field, the choices are using one computed value with this code:

try
{
var locType = getComponent("locationType").getValue();

var key = '';

switch(locType) {
case 'Commuity Service Center':
    key = 'loc_cso';
    break;
case 'RYDC':
    key = 'loc_rydc';
    break;
case 'YDC':
    key = 'loc_ydc';
    break;
case 'HQ':
    key = 'loc_hq';
    break;
default:
    key = 'facilities';
}
    var luChoices = @DbLookup('','keywords', key, 'choices');   
    luChoices.unshift("Select one|''");
    return luChoices;
}
catch(e)
{
print("Error:::::"+e);
    }

The choices were NOT changing for locationEtc whenever I pick a locationType, but then they do when I add code to clear the location field whenever locationType changes, using a simple action for onChange event of locationType field:

enter image description here

This is great, but when it all refreshes, my displayErrors control appears (yellow background area) showing required field validation results, and a lot of the fields are not filled in yet by design.

How can I make the displayErrors to show ONLY when tying to submit?

Thanks everyone who can help.

Matt


Solution

  • Set disableValidators="true" on the simple action that you created