Can the custom handler become more generic for any timestamp fields? I would
like to avoid adding/removing "hardcoded field name" in my handler, such as
User28 and User29. My objective is to make my handler class more reusable.
Do you have something similar implemented below?
public Object getValue(Object _obj) throws IllegalStateException
{
Object timestampToBeHandled = getFieldDescriptor().getHandledField();
// getHandledField will return the object User27 if it is called
within the user27 field and vice versa.
}
-----Original Message-----
From: Keith Visco [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 04, 2002 5:30 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] CastorXML Timestamp issue
You received the ZoneMastBiz object because that is the parent object in
which the field needs to be set, or retrieved from.
If you are using the CVS version and you want information about *which*
field it is, try extending AbstractFieldHandler. You can then determine
information about the field by using the getFieldDescriptor() method:
public Object getValue(Object _obj) throws IllegalStateException
{
if (getFieldDescriptor().getName().equals("User27")) {
...
}
}
--Keith
Tin wrote:
>
> Hi,
> I have tried your suggestion, but my custom field handler will get the
> object that contains the field. There is no way to tell which field I want
> to handle.
> ex,
> my mapping file
> -------------------
> <class name="ZoneMastBiz">
> <field name="User27" type="java.sql.Timestamp"
> handler="TimestampFieldHandler">
> <bind-xml name="User27" node="element"/>
> </field>
> -------------------
>
> In my field handler, I got the object ZoneMastBiz, which I think it should
> be "User27". So, I can "handler" it myself. Any suggestion?
>
> my handler implement
> ----------------------
> public class TimestampFieldHandler extends XMLFieldHandler
> {
> ...
>
> public Object getValue(Object _obj) throws IllegalStateException
> {
> /* I got ZoneMastBiz here. How could I know it is called within the
> field "User27" ? */
> }
> ...
> }
> -----Original Message-----
> From: Arnaud Blandin [mailto:[EMAIL PROTECTED]]
> Sent: Friday, October 04, 2002 5:49 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [castor-dev] CastorXML Timestamp issue
>
> Hi Stan,
>
> We can't integrate the patch the way it is since it doesn't fit with the
> current code base and semantics of Castor. The best way to provide
> marshalling and unmarshalling of such a class is to use the pluggable
> FieldHandler API in Castor.
> What you have to do is write a specific FieldHandler that will help the
> marshalling framework to marshal/unmarshal a java.sql.TimeStamp. You can
> take a look at org.exolab.castor.xml.handlers.DateFieldHandler as an
> example.
> Once your handler is ready you can specify it using the 'handler'
> attribute of the <field> element in a mapping file.
> Feel free also to send us the handler so that we can integrate it in the
> next release.
>
> Thanks,
>
> Arnaud
>
> -----Original Message-----
> From: Tyree, Stan [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, October 03, 2002 9:03 PM
> To: [EMAIL PROTECTED]
> Subject: [castor-dev] CastorXML Timestamp issue
>
> Quan,
>
> I saw this post and didn't see your fix in the latest version of
> castor. Do you know if anyone has plans of addressing the
> problem/solution you had?
>
> http://www.mail-archive.com/[email protected]/msg01422.html
>
> Thanks,
>
> Stan T.
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev