Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[riena-dev] Re-validation on add/remove

Hi Christian / riena-dev,

here's something to discuss in the call.

I'm trying to implement re-validation on add/removeValidation rule as
discussed previously on the list. However I see a couple of issues with
our current design:


1. Re-validation on add -- Does it make sense to throw an exception in
case #1? A workaround could be not to validate if there is no bound
data-model (i.e. do not validate if #bindToModel has not been called). 

// #1 no data yet; add throws runtime exception
ridget.addValidationRule(new MinLength(3),
ValidationTime.ON_UPDATE_TO_MODEL));

// #2
ridget.setText("abc");
// add throws runtime exception
ridget.addValidationRule(new
ValidCharacters(ValidCharacters.VALID_NUMBERS));

// #3
ridget.addValidationRule(new
ValidCharacters(ValidCharacters.VALID_NUMBERS));
// #setText throws runtime exception
ridget.setText("abc");


2. Re-validation on remove: Does it make sense to copy to the control
data to the ridget?

bean.setProperty("123");
ridget.bindToModel(bean, TestBean.PROPERTY);
IValidator numbersOnly = new
ValidCharacters(ValidCharacters.VALID_NUMBERS);
ridget.addValidationRule(numbersOnly);
// user types "abc"; ridget is invalid
// control value is "abc"; ridget value is "123"; bean value is "123"
ridget.removeValidationRule(numbersOnly);
// revalidation occurs; ridget is valid

At this point; should the value of "abc" be copied to the ridget / bean
?


In general I am worried that we are trying to automate too much here.
>From the application developers POV, it seems that these things make it
more diffcult to understand what is going on inside the ridget and how
to avoid getting runtime exceptions.

Personally, I think maybe a compromise would be ok, where you can add /
remove rules as you want; without any exceptions and there is a #boolean
revalidate(boolean withException) method, that you can call if you need
revalidation. Revalidate will either return true / false or true /
throws exception.

Regards,
Elias.

---
Elias Volanakis
Technical Lead
Innoopract, Inc.
351 NW 12th Avenue
Portland, Oregon 97209
Tel: +1-503-552-1457
Fax: +1-503-715-4915
Mobile: +1-503-929-5537
evolanakis@xxxxxxxxxxxxxx
http://rapblog.innoopract.com



Back to the top