You can do it in real java, but as reflection is not supported in GWT it would
not work in GWT. 

In real java you would say:-

Test test = new Test();
Test.getClass().getField("value").set(test,"some value");

Note that if value is a private or protected field then you need to use
getDeclaredField not getField.

David

On Wednesday 08 July 2009, george9 wrote:
> When you have a typed class, say
>
> class Test {
>     String value;
> }
>
> is it somehow possible to set field 'value' without a static reference
> in the code?
> I'm looking for an equivalent to JavaScript's:
>
> var Test = { };
> Test["value"] = "some value";
>
> JSNI can access a java field via the "[instance-exp...@class-
> name::field-name" notation, but that looks like a compile time thing.
>
> 
\

--~--~---------~--~----~------------~-------~--~----~
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