Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    No validation error message using setRequired( true ) and LengthRangeValidator.

    I am using SmartClient Version: v10.1p_2016-01-07/PowerEdition Deployment (built 2016-01-07) and FireFox ESR 24.3.0.

    I want to validate the text box when clicking 'OK' button from the following dialog box.

    Click image for larger version

Name:	Capture.PNG
Views:	60
Size:	3.7 KB
ID:	234796

    The instance of text box is 'valueInput ' and I set setRequired( true ) for it like the following.

    public class ValueInputDialog extends Window {
    ...
    final TextItem valueInput = new TextItem( VALUE_INPUT, valueInputLabel );
    valueInput.setRequired( true );
    ...
    }

    I also set the min and max range of the value like the following.

    public class TrimmedStringLengthValidator extends LengthRangeValidator {

    private int min, max;

    public TrimmedStringLengthValidator() {
    this.init( 1, 255, "error" );
    }
    private void init(int min, int max, String errorMessage) {
    this.setMin( min );
    this.min = min;

    this.setMax( max );
    this.max = max;

    StringBuffer completeErrorMessage = new StringBuffer( errorMessage );
    completeErrorMessage.append( this.common.length() + ": " );
    completeErrorMessage.append( min );
    completeErrorMessage.append( "-" );
    completeErrorMessage.append( max );
    this.setErrorMessage( completeErrorMessage.toString() );
    }
    }

    BTW, when I leave the text box empty and click 'OK' no validation error shows up.

    Please help.

    #2
    There's nothing obviously wrong with this part of the code, but we haven't been shown the rest - without seeing it, the problem could be as basic as creating the Validators but never actually calling setValidators(), never actually calling validate() from your OK button, or something along those lines.

    Comment

    Working...
    X