install4j

Install4j key validation is only executed once


In our installer there's an input field where user is supposed to enter a multicast range in CIDR format. We want to add input validation to indicate if the entered value is correct, and if it's correct, we want to show the corresponding range (beginning address, end address & count). To achieve this we tried adding an input validation expression, but this is only executed when the input field loses focus, and it also do not allow losing focus if the validation returns false. This seems to create confusion to our users as it looks like the installer got stuck...

Hence we wanted to re-validate the input each time the value is changed, and tried "key validation expression" and "key listener script". But they do not seem to be working as expected. They only get executed once for the first key press and not anymore. I do not see any errors printed in the logs. What's the suggested way to troubleshoot this?

We tried adding a key listener script (returns void, just updates a hint text) and also a key validation expression (returns true/false, also updates the hint text). They both get executed only for the first keypress.


Solution

  • Try using the "Validation expression" on the screen to validate the content of the variable instead. You would then query context.getVariable("variableName") in that script to check the entered value and use

    Util.showErrorMessage("...");
    return false;
    

    to signal a validation error.

    As for the "Key validation expression" or the "Key listener script" property key listener script being only executed once, I cannot reproduce this.