PDA

View Full Version : [FNR] Basic validator messages dissapear when using Validator



staffan
21 Aug 2008, 6:45 AM
I've written an implementation on Validator to use with a Numberfield. The NumberField also has basic validators such as max length = 5. After adding the custom validator I only get the error message from the custom validator, regardless of what's wrong. E.g: I enter a 10 digit string -> I'll get the error message from the Validator and not from the MaxLength. When removing the validator from my code the messages from the basic Validators start working again.

According to the API the Custom Validator shall only be used if the basic validators all passes. It seems there is a mixup somewhere with the error messages.

Se code below:




supplierId.setAllowBlank(false);
supplierId.setAllowDecimals(false);
supplierId.setAllowNegative(false);
supplierId.setPropertyEditor(new NumberPropertyEditor("0"));
supplierId.setMinLength(5);
supplierId.setMaxLength(5);
supplierId.setValue(sui.getSupplierIdentifier());


supplierId.setValidator(new SupplierIdentifierValidator(controller));

darrellmeyer
21 Aug 2008, 9:01 PM
Fix is in SVN.

rgoncalves
22 Aug 2008, 3:32 AM
Hi,
I'm having a problem with error messages in a NumberField too. The problem is described in thread http://extjs.com/forum/showthread.php?p=213182#post213182.

Known bug?
Thaks.

staffan
27 Aug 2008, 11:00 PM
Hi!

After updating to GXT 1.1 my NumberField, mentioned above, start bahaving even more strange:

* It is not longer possible to edit the field using the Backspace button. The only way to enter a new number is to use the Delete button or highlight the number and enter a new.

* My custom validator is never run (Checked using debug in hosted mode). I'm calling validate() on my NumberField instance, it returns true but the Validator is never executed. I've tried enter invalid numbers according to my validator, the NumberField still returns true on validate()

darrellmeyer
28 Aug 2008, 1:19 PM
Please see this post (http://extjs.com/forum/showthread.php?t=40289) for guidelines to posting bugs.

Using the following code I have no issues with validation and the backspace key with 1.1 alpha 3 and 1.0.3 (FF, IE, Safari):


public void onModuleLoad() {
final NumberField my_id = new NumberField();
my_id.setFieldLabel("my Id");
my_id.setAllowBlank(false);
my_id.setMinLength(2);
my_id.setMaxLength(4);
my_id.setAutoValidate(true);
RootPanel.get().add(my_id);
}


If any of you are still having issues, please post again with the requested information.

staffan
28 Aug 2008, 11:22 PM
I upgraded to 1.1 alpha3, which solved the backspace problem. Unfortunately I discovered these new problems:

* Unable to navigate in Numberfield using Arrow keys
* Unable to jump to next Field using Tab

* I still cannot get my own Implementation of Validator to run. The code in my validator is never executed, but field returns valid.

My NumberField:



supplierId = new NumberField();


supplierId.setFieldLabel("ICA Supplier Id");

supplierId.setAllowBlank(false);
supplierId.setAllowDecimals(false);
supplierId.setAllowNegative(false);
supplierId.setPropertyEditor(new NumberPropertyEditor("0"));
supplierId.setMinLength(5);
supplierId.setMaxLength(5);
supplierId.setValue(sui.getSupplierIdentifier());
supplierId.setValidator(new SupplierIdentifierValidator(controller));
supplierId.addListener(Events.OnClick, controller);
supplierId.setAutoValidate(true);





My Validator




public String validate(Field field, String value) {





NumberField nf = (NumberField)field;

for(Component item: controller.getSoiView().getLogPartiHandelTab().getSuiMain().getItems()) {
if(item instanceof SUIDetailsFormPanel) {
SUIDetailsFormPanel suiPanel = (SUIDetailsFormPanel)item;
//Not compare with it self -- not compare with sui that is already set -- only compare with other suis
if(!suiPanel.getSupplierId().equals(nf) && !suiPanel.getItemId().equals(suiPanel.getSupplierId().getValue().toString()) && suiPanel.getSupplierId().getValue().intValue() == nf.getValue().intValue()) {
return "Invalid Supplier Identifier, allready in use";
}
}
}
return null;


}

darrellmeyer
29 Aug 2008, 7:17 AM
I have fixed the arrow key issue and the validator is now called in NumberField. Fixes are in SVN.