Re: [Xswt-developer] Xswt-developer Digest, Vol 9, Issue 11
Brought to you by:
dvorme
|
From: <ha...@id...> - 2007-04-24 16:58:13
|
Hi,
I've just committed a quick fix for the getMethod("setData", ...) problem. I
just did a direct call to getMethod(...).invoke(...) wrapped in a try/catch all.
I also added a JUnit test in the test project, to check whether it works (it does).
Hallvard
xsw...@li... wrote:
> Send Xswt-developer mailing list submissions to
> xsw...@li...
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.sourceforge.net/lists/listinfo/xswt-developer
> or, via email, send a message with subject or body 'help' to
> xsw...@li...
>
> You can reach the person managing the list at
> xsw...@li...
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Xswt-developer digest..."
>
>
> Today's Topics:
>
> 1. Re: Widget.setData (Millberg Lars)
> 2. Terrific gains possible. (Stephanie Mewett)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 23 Apr 2007 10:34:27 +0200
> From: "Millberg Lars" <lar...@sa...>
> Subject: Re: [Xswt-developer] Widget.setData
> To: <xsw...@li...>
> Message-ID:
> <6F2...@co...>
> Content-Type: text/plain; charset="utf-8"
>
> 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 daemon - 32k according to my mailer, MS OutOfLuck).
> So, I'm resending with old fashioned plain text formatting...
>
> -----
>
> Found it!
> It?s in XSWT.processBuiltInAttr().
>
> Two issues with the method:
> 1: (indirectly relevant to the problem at hand)
>
> if (nodeName.endsWith("id"))
> return true;
>
> If I have ?x:id.uuid? as the actual attribute name it will never be considered. I suggest changing the above code to:
>
> if ("id".equals(nodeName))
> return true;
>
> This is also more inline with the rest of the tests in the loop.
>
> 2: The interesting case for ?setData? is this code:
>
> // x:id.<key> - setData on Widget objects
> if (nodeName.startsWith("id.")) {
> String key = nodeName.substring("id.".length());
> ReflectionSupport.invokei(obj, "setData", new Object[] {key, value});
> return true;
> }
>
> 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
>
> Method methodCaller = receiver.getClass().getMethod(method,
> getParamTypes(args));
>
> ultimately looks for a method ?setData(String,String)?, which doesn?t exist.
>
> 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:
>
> public static Object invokeiWithTypes(Object receiver, String method,
> Object[] args, Class[] argTypes) {
> Object result = null;
> try {
> Method methodCaller = receiver.getClass().getMethod(method, argTypes);
> result = methodCaller.invoke(receiver, args);
> } catch (Exception e) {
> }
> return result;
> }
>
> Of course the old invokei should be changed to use the new method:
>
> public static Object invokei(Object receiver, String method,
> Object[] args) {
> return invokeiWithTypes(receiver, method, args, getParamTypes(args));
> }
>
> Finally, a corresponding change in processBuildInAttrs:
>
> ReflectionSupport.invokeiWithTypes(
> obj, "setData", new Object[] {key, value},
> new Class[]{String.class, Object.class});
>
> What say ye?
>
>
>
>
> ------------------------------
>
> Message: 2
> Date: Mon, 23 Apr 2007 22:15:52 +0800
> From: "Stephanie Mewett" <Mew...@ac...>
> Subject: [Xswt-developer] Terrific gains possible.
> To: xsw...@li...
> Message-ID: <FA6...@ac...>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> http://www.imagehosting.com/out.php/i512135_2.jpg
> Add to your portfolio!
>
> It is likely that most large companies have situations like this, where data has been entered once but must be entered again because of a computer incompatibility.
>
>
>
>
> ------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
>
> ------------------------------
>
> _______________________________________________
> Xswt-developer mailing list
> Xsw...@li...
> https://lists.sourceforge.net/lists/listinfo/xswt-developer
>
>
> End of Xswt-developer Digest, Vol 9, Issue 11
> *********************************************
>
>
|