Steve,

I am not sure this has been 'reported' already. I have seen issues being
reported with the GeneralizedFieldHandler now and then, but afaict not
related to this problem.

Guys, can you please create a Jira issue and attach the most minimal
test case ?

Thanks
Werner

Steve Kingsland wrote:
> Yes, I discovered the same exact thing you did, over the weekend. As far as
> I can tell, this "bug" means that the "field-handler" element doesn't allow
> you to reuse the handler across more than one field.
> 
> In my case, I have 50 fields, and each field will use 1 of 4 different types
> of custom handlers: StringHandler, IntegerHandler, DecimalHandler, and
> DateHandler. I had hoped to declare each handler once (using a param to tell
> it which type of field class to handle), and use them in my field mappings.
> But since each handler only gets instantiated *once* (not once *per field*),
> it means the handler will only work for the last field it was assigned to!
> 
> Does anyone know if this has been reported as a bug? The "test case" is the
> mapping Paulo provided below, which is simplified even more here:
> 
> <field-handler name="*myHandlerName*" class="myHandler"/>
> 
> 
> 
> <field name="*myField1*" type="string" handler="*myHandlerName*">
> 
> <bind-xml name="my-field-1" node="attribute"/>
> 
> </field>
> 
> <field name="*myField2*" type="string" handler="*myHandlerName*">
> 
> <bind-xml name="my-field-2" node="attribute"/>
> 
> </field>
> 
> If you use this to unmarshall an XML document, "myHandler" only gets called
> for "myField2", not "myField1".
> 
> Steve
> 
> On Wed, Oct 15, 2008 at 2:24 PM, Paulo Silveira <[EMAIL PROTECTED]>wrote:
> 
>> Hi,
>>
>>
>> I extended *GeneralizedFieldHandler* to create my own handler.
>>
>>
>> I'm trying to pass a parameter to it (since *GeneralizedFieldHandler* 
>> implements
>> *ConfigurableFieldHandler*) and use it for many fields that are binding
>> for different methods.
>>
>>
>>
>> My mapping file:
>>
>>
>>
>> <!-- Handler mapping -->
>>
>> <field-handler name="*myHandlerName*" class="myHandler">
>>
>> <param name="myFlag" value="true"/>
>>
>> </field-handler>
>>
>>
>>
>> <!-- fields mapping -->
>>
>> <field name="*myField1*" required="true" type="string" handler="*
>> myHandlerName*">
>>
>> <bind-xml name="my-field-1" node="attribute"/>
>>
>> </field>
>>
>> <field name="*myField2*" required="true" type="string" handler="*
>> myHandlerName*">
>>
>> <bind-xml name=" my-field-2" node="attribute"/>
>>
>> </field>
>>
>>
>>
>> The issue is that castor is calling *getMyField2* all the time (it never
>> calls *getMyField1 *for the first field).
>>
>>
>>
>> After some debug in castor source code I saw that the myHandler instance is
>> the same all the time (it looks fine to me, since I have only one handler in
>> this mapping), but it has a reference to *FieldHandlerImpl* object
>> (attribute *_handler*) and this object has an attribute *_getMethod,* this
>> attribute is set for each field that I have in my mapping file, but the
>> handler instance is the same and in the moment of use it, *_getMethod*will 
>> have the method that I have in my last mapped field that
>> uses myHandlerName (in this example: *myField2*).
>>
>> Does anyone have similar issue?
>>
>> Thanks,
>> Paulo
>>
> 

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to