It seems  that intake 2.3 forms with unrequired int fields can't be 
successfully submitted unless one fills in the field. A blank error message 
appears if no value is provided.

The problem lies in the IntegerValidator.assertValidity method. A condition
if ((required || minLength > 0) || (testValue != null && testValue.length() > 
0))
{
 ...
}
should be added before an attempt to Integer.parseInt is carried out. Since 
this condition is not implemented, a "" int value will lead to a 
ValidationException with a most often null "invalidNumberMessage".

Once this correction is written, another problem appears : 
group.setProperties(myObject) raises an exception. The problem is that a 
dynamic invocation of myObject.setMyInt(null) is tried in the 
Field.setProperty(Object obj) method.

Probably, this problem also appears with any primitive type (int, float, 
double, short, long). For a non primitive type, a null value means no value. 
How can this be achieved with primitive types ?

To correct the problem, a private String type field can be added in the Field  
class, initialized from XmlField.getType() in the Field constructor and a 
if ((!type.equals("int")) || (valArray[0] != null))
{
        setter.invoke(obj, valArray);
}
condition can be added.

With these corrections, everything seems to work properly. Objects with 
unrequired int fields can be retrieved with intake. They can be saved by 
Torque ... but unfortunately, Torque inserts a 0 value (at least on MySQL) 
instead of a NULL  value for unrequired unfilled int fields ! I guess this is 
a problem for referential integrity.

Any idea on how this Torque problem could be fixed ?
-- 
Lo�c QUERAN

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to