Re: [Xswt-developer] Xswt-developer Digest, Vol 9, Issue 11
Brought to you by:
dvorme
|
From: David J. O. <dj...@co...> - 2007-04-24 17:39:54
|
Thanks Hallvard!=20
Dave=20
----- Original Message -----=20
From: Hallvard Tr=C3=A6tteberg <ha...@id...>=20
To: xsw...@li...=20
Sent: Tuesday, April 24, 2007 11:30:56 AM GMT-0800=20
Subject: Re: [Xswt-developer] Xswt-developer Digest, Vol 9, Issue 11=20
Hi,=20
I've just committed a quick fix for the getMethod("setData", ...) problem. =
I=20
just did a direct call to getMethod(...).invoke(...) wrapped in a try/catch=
all.=20
I also added a JUnit test in the test project, to check whether it works (i=
t does).=20
Hallvard=20
xsw...@li... wrote:=20
> Send Xswt-developer mailing list submissions to=20
> xsw...@li...=20
>=20
> To subscribe or unsubscribe via the World Wide Web, visit=20
> https://lists.sourceforge.net/lists/listinfo/xswt-developer=20
> or, via email, send a message with subject or body 'help' to=20
> xsw...@li...=20
>=20
> You can reach the person managing the list at=20
> xsw...@li...=20
>=20
> When replying, please edit your Subject line so it is more specific=20
> than "Re: Contents of Xswt-developer digest..."=20
>=20
>=20
> Today's Topics:=20
>=20
> 1. Re: Widget.setData (Millberg Lars)=20
> 2. Terrific gains possible. (Stephanie Mewett)=20
>=20
>=20
> ----------------------------------------------------------------------=20
>=20
> Message: 1=20
> Date: Mon, 23 Apr 2007 10:34:27 +0200=20
> From: "Millberg Lars" <lar...@sa...>=20
> Subject: Re: [Xswt-developer] Widget.setData=20
> To: <xsw...@li...>=20
> Message-ID:=20
> <6F2...@co...>=20
> Content-Type: text/plain; charset=3D"utf-8"=20
>=20
> I sent this last Friday afternoon, but it was rejected by the list since =
with history and HTML markup it got bigger than 40k (according to the daemo=
n - 32k according to my mailer, MS OutOfLuck).=20
> So, I'm resending with old fashioned plain text formatting...=20
>=20
> -----=20
>=20
> Found it!=20
> It?s in XSWT.processBuiltInAttr().=20
>=20
> Two issues with the method:=20
> 1: (indirectly relevant to the problem at hand)=20
>=20
> if (nodeName.endsWith("id"))=20
> return true;=20
>=20
> If I have ?x:id.uuid? as the actual attribute name it will never be consi=
dered. I suggest changing the above code to:=20
>=20
> if ("id".equals(nodeName))=20
> return true;=20
>=20
> This is also more inline with the rest of the tests in the loop.=20
>=20
> 2: The interesting case for ?setData? is this code:=20
>=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
>=20
> The problem is with types of the args; the actual objects in the array ar=
e strings. Follow the call to ReflectionSupport.invokei and we find that th=
is call=20
>=20
> Method methodCaller =3D receiver.getClass().getMethod(method,=20
> getParamTypes(args));=20
>=20
> ultimately looks for a method ?setData(String,String)?, which doesn?t exi=
st.=20
>=20
> I can?t right now think a an elegant solution to this, other than to add =
a new method to ReflectionSupport, yieldning something like this:=20
>=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
>=20
> Of course the old invokei should be changed to use the new method:=20
>=20
> public static Object invokei(Object receiver, String method,=20
> Object[] args) {=20
> return invokeiWithTypes(receiver, method, args, getParamTypes(args));=20
> }=20
>=20
> Finally, a corresponding change in processBuildInAttrs:=20
>=20
> ReflectionSupport.invokeiWithTypes(=20
> obj, "setData", new Object[] {key, value},=20
> new Class[]{String.class, Object.class});=20
>=20
> What say ye?=20
>=20
>=20
>=20
>=20
> ------------------------------=20
>=20
> Message: 2=20
> Date: Mon, 23 Apr 2007 22:15:52 +0800=20
> From: "Stephanie Mewett" <Mew...@ac...>=20
> Subject: [Xswt-developer] Terrific gains possible.=20
> To: xsw...@li...=20
> Message-ID: <FA6...@ac...>=20
> Content-Type: text/plain; charset=3DISO-8859-1; format=3Dflowed=20
>=20
> http://www.imagehosting.com/out.php/i512135_2.jpg=20
> Add to your portfolio!=20
>=20
> It is likely that most large companies have situations like this, where d=
ata has been entered once but must be entered again because of a computer i=
ncompatibility.=20
>=20
>=20
>=20
>=20
> ------------------------------=20
>=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
> ------------------------------=20
>=20
> _______________________________________________=20
> Xswt-developer mailing list=20
> Xsw...@li...=20
> https://lists.sourceforge.net/lists/listinfo/xswt-developer=20
>=20
>=20
> End of Xswt-developer Digest, Vol 9, Issue 11=20
> *********************************************=20
>=20
>=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
|