Hi all
I have such strange problem with data incomming from a client's form with
Java7.
I have created a generic entity, which is a superclass for all other
entities in applications. This class contains getter and setter for ID.
Getter is generic, setter - due Tapestry5 coercions - expects Object and
converts it to proper type inside the method setId(Object).

The generic entity is here:
https://code.google.com/p/fishear/source/browse/fishear-data/src/main/java/net/fishear/data/generic/entities/GenericEntity.java

In applications themselves, the less generic implementation is used, which
implements ID as Long:
https://code.google.com/p/fishear/source/browse/fishear-data/src/main/java/net/fishear/data/generic/entities/AbstractEntity.java
(the fishear project is very early, please excuse many missing things in
classes).

Note the method setId(Object) is not generic due Tapestry5 - in forms, in
case ID is null and the ID field (from the entity) is part of the form - T5
tries to convert empty String (comming from form) to setter type - Long in
this case, which result to en exception.

The solution (let setter for ID non-generic) worked up to JAVA version 6 (T5
passed the String to the entity "as it was"). But in Java7 - T5 tries
convert string to Long anyway. Why?.

The best solution for me would be to convert empty string (incomming from
client's form) to null object, also leave null value as null (do not throw
exception) - it would allow me to make setId() method generic too (I think
this is great ide generaly).
Or to have possibility to change "system" coercer with the custom one for
any type pair already registered.
But the solution used currently (and functional with Java6) will be
sufficient if it is functional in Java7.

I tried add custom coercion, but I can't change "system" coercion (String ->
Long) - I can only add new one, which does not function (due the same type
already exists?)

Any ideas?

Thanks

Radek

Reply via email to