Re: [Xswt-developer] Widget.setData
Brought to you by:
dvorme
|
From: David J. O. <dj...@co...> - 2007-04-23 19:28:47
|
What say I? Looks great!=20
Looks like we probably broke this when we factored all the ReflectionSuppor=
t out into its own class.=20
If your patch is < 100 lines, you can submit it directly. Else, please have=
your employer sign a committer form as found on the XSWT web site (it's th=
e same as Eclipse's committer agreement) and fax or mail it tome and I can =
accept the patch.=20
Sorry for all the red tape, but SCO has forced all meaningful open-source p=
rojects to be very careful to dot the i's and cross the t's, legally speaki=
ng.=20
Regards,=20
Dave Orme=20
----- Original Message -----=20
From: Millberg Lars <lar...@sa...>=20
To: xsw...@li...=20
Sent: Monday, April 23, 2007 3:34:27 AM GMT-0800=20
Subject: Re: [Xswt-developer] Widget.setData=20
I sent this last Friday afternoon, but it was rejected by the list since wi=
th history and HTML markup it got bigger than 40k (according to the daemon =
- 32k according to my mailer, MS OutOfLuck).=20
So, I'm resending with old fashioned plain text formatting...=20
-----=20
Found it!=20
It=E2=80=99s in XSWT.processBuiltInAttr().=20
Two issues with the method:=20
1: (indirectly relevant to the problem at hand)=20
if (nodeName.endsWith("id"))=20
return true;=20
If I have =E2=80=9Cx:id.uuid=E2=80=9D as the actual attribute name it will =
never be considered. I suggest changing the above code to:=20
if ("id".equals(nodeName))=20
return true;=20
This is also more inline with the rest of the tests in the loop.=20
2: The interesting case for =E2=80=9CsetData=E2=80=9D is this code:=20
// x:id.<key> - setData on Widget objects=20
if (nodeName.startsWith("id.")) {=20
String key =3D nodeName.substring("id.".length());=20
ReflectionSupport.invokei(obj, "setData", new Object[] {key, value});=20
return true;=20
}=20
The problem is with types of the args; the actual objects in the array are =
strings. Follow the call to ReflectionSupport.invokei and we find that this=
call=20
Method methodCaller =3D receiver.getClass().getMethod(method,=20
getParamTypes(args));=20
ultimately looks for a method =E2=80=9CsetData(String,String)=E2=80=9D, whi=
ch doesn=E2=80=99t exist.=20
I can=E2=80=99t right now think a an elegant solution to this, other than t=
o add a new method to ReflectionSupport, yieldning something like this:=20
public static Object invokeiWithTypes(Object receiver, String method,=20
Object[] args, Class[] argTypes) {=20
Object result =3D null;=20
try {=20
Method methodCaller =3D receiver.getClass().getMethod(method, argTypes);=20
result =3D methodCaller.invoke(receiver, args);=20
} catch (Exception e) {=20
}=20
return result;=20
}=20
Of course the old invokei should be changed to use the new method:=20
public static Object invokei(Object receiver, String method,=20
Object[] args) {=20
return invokeiWithTypes(receiver, method, args, getParamTypes(args));=20
}=20
Finally, a corresponding change in processBuildInAttrs:=20
ReflectionSupport.invokeiWithTypes(=20
obj, "setData", new Object[] {key, value},=20
new Class[]{String.class, Object.class});=20
What say ye?=20
-------------------------------------------------------------------------=
=20
This SF.net email is sponsored by DB2 Express=20
Download DB2 Express C - the FREE version of DB2 express and take=20
control of your XML. No limits. Just data. Click to get it now.=20
http://sourceforge.net/powerbar/db2/=20
_______________________________________________=20
Xswt-developer mailing list=20
Xsw...@li...=20
https://lists.sourceforge.net/lists/listinfo/xswt-developer=20
|