Accessing underlying data structure.

10 views
Skip to first unread message

Robert Rawlins

unread,
Jan 31, 2012, 9:49:52 AM1/31/12
to transf...@googlegroups.com
Hello Guys,

I have a property on an object which is type='numeric' - it stores the price of a product.

The problem I have at the moment is that the generated setter method has an argument of type 'numeric' too.

When dynamically populating the bean from a form ready to be validated I sometimes get an exception, as the argument passed into the setter might not be of numeric type. This prevents me from validating the object and giving the user a helpful message.

In the hibernate ORM I would use an 'any' or 'string' type for the setter, and be able to establish a separate datatype at a database level for the property, but unfortunately this isn't something supported by transfer.

I've been playing with the concept of decorating the setter method, so that it let's me set a value of any type into the object. However, I can't figure out how to actually access the underlying data structure to set the property, without at some point going through the generated setter, which limits the argument to numeric.

Can anyone offer any advice on this?

Thank you.

Robert

Clarkee21

unread,
Jan 31, 2012, 6:33:01 PM1/31/12
to transf...@googlegroups.com
Hey Robert,

Personally I'd say user input problems shouldn't be dealt with by Transfer at all. Those objects should be reflective of your database structure with validation, data cleanup etc. happening before the population.

We had the exact same pain in our previous application and we got around it by using a combination of ValidateThis scripts to check the form was giving us the correct data types back and some custom components that allowed us to strip out currency symbols etc. out.

Cheers,
James


Reply all
Reply to author
Forward
0 new messages