You can't do it. The problem is that you cannot get hold of the
obfuscated field names from GWT. The way people provide this kind of
functionality is by building a generator that at compile time
generates a class with a bunch of getters and setters. This is how the
RPC serialization works and a bunch of dynamic binding libraries. The
code is really ugly in many cases.



On Apr 29, 10:33 am, Arinté <[email protected]> wrote:
> We have an XSD that has a numerous amount of properties that need to
> be set.  We have placed all those properties on the browser, so when
> the user submits those values I want to plug those properties into the
> jaxb object.  So instead of coding a bunch of setXXX, I wanted to do
> in such a way that if the xsd changed all I have to do is change the
> GUI and give that gwt gui object a name that maps directly to the xsd.
>
> So the xsd has UserName
> The gui will have a g:Textbox name="UserName"
>
> Then in the code I would call the reflective method.
>
> As I typed this I guess regardless there would be no way to do this on
> the client side. So now I am thinking that I could just send the
> widget to the server and the server could do all the reflection it
> needs.
>
> Pseudocode for the server side
> String someMethodCalledAsync(Widget t){
>    for ( Node n : t.getElement().getChildNodes() ){
>       if ( n )//do reflection to see if this object has a getName
> method.  if so we can use it and do an easy map to the jaxb object.
>    }
>
> }
>
> On Apr 29, 10:08 am, Sripathi Krishnan <[email protected]>
> wrote:
>
>
>
>
>
> > GWT doesn't support reflection or dynamic method invocation for performance
> > reasons. It has to know at compile time what method you want to invoke, so
> > that it can eliminate methods that it knows aren't being called.
>
> > If you describe your use-case, perhaps someone could help you with a
> > workaround.
>
> > --Sri
>
> > On 29 April 2010 19:20, Arinté <[email protected]> wrote:
>
> > > I want to be able to call a method on a object dynamically.  As in:
> > > Method m = obj.getClass().getMethod(...);
> > > m.invoke(...);
>
> > > How would I do this on the client-side in GWT.  I was trying to do
> > > this:
>
> > > reflectiveSet(trunk.getSettings().getCustName(), "value", "grumpy");
>
> > >    private native void reflectiveSet(Object obj, String property,
> > > String value)/*-{
> > >        alert('o' +obj);
> > >        alert('p' +property);
> > >        alert('v' +value);
> > >        obj[property] = value;
> > >    }-*/;
>
> > > but that doesn't work, I get this error:
>
> > > com.google.gwt.core.client.JavaScriptException: (null): null
> > >    at
>
> > > com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChann
> > >  elServer.java:
> > > 195)
>
> > > Would this work if I were to actually deploy the war file?
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Google Web Toolkit" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected]<google-web-toolkit%2Bunsubs
> > >  [email protected]>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-web-toolkit?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Google Web Toolkit" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to 
> > [email protected].
> > For more options, visit this group 
> > athttp://groups.google.com/group/google-web-toolkit?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group 
> athttp://groups.google.com/group/google-web-toolkit?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to