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.
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.
I want to validate the text box when clicking 'OK' button from the following dialog box.
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.
Comment