Inherited fields with @RemoteProperty are undefined

Description

Hello,

We are using DWR 2.0.5 with annotations.

We have an abstract class A annotated with @DataTransferObject
and a class B which extends A also annotated with @DataTransferObject.

The @RemoteProperty is set on the attributes of both classes.
(Our modelization tool forces us to put this annotation on properties instead of methods).

However, when we try to access the properties of the parent class from the javascript, the attributes from the parent class A
are undefined.
Looking at the AnnotationsConfigurator, we see that the fields are taken from:

fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
fields.addAll(Arrays.asList(clazz.getFields()));

not from the superclass.

So, we tried to hack this in order to take the fields of the super class:

and it works.

Is there another proper way to configure DWR annotations with inheritance without doing a hack like this?

Thank you,
Gilles

Activity

Show:
David Marginian
March 30, 2012, 5:21 AM

1) I am not sure doing this is correct, let me think about it.
2) Yes, actually I think you have it mixed up. getFields is not necessary but getDeclaredFields certainly is. getFields only returns public fields.

David Marginian
March 31, 2012, 10:18 PM
Edited

Gilles, you don't mention it in your description but a key part of this is that the field in the abstract (super class) has to be private in order to see this - if it is public everything works fine.

You should look at the Java Doc for the reflection APIs we are using and you will see why calling getDeclaredFields is necessary.

I don't think your request for the Enum change is valid.

I am considering this issue resolved.

J
July 31, 2013, 2:05 AM

Hello David,

You mentioned this bug will be patched in version 2.0.11 but from your documentation this version does not exist.
Did you fix this bug.

Thanks a lot

David Marginian
July 31, 2013, 4:02 AM

Joachim, I have been meaning to release it but haven't had time. Until then the latest 2.x build on Bamboo should get you the fix:
http://directwebremoting.org/bamboo/browse/DWR20-ALL-108/artifact

J
July 31, 2013, 4:42 AM

Ok thx, let me know when you'll had time to release this version.

Cheers

Assignee

David Marginian

Reporter

Gilles Robert

Labels

None

Documentation Required

No

Components

Fix versions

Priority

Normal
Configure