Just to add a bit more in case that wasn't clear:
If you have a class 'Class1' that you cannot modify with a static field:
public final Class1 {
public static int counter = 55;
}
You can make a new class, ie. 'Class1Exposer'
public class Class1Exposer {
public static int getClass1Counter() {
return Class1.counter;
}
public static native void exportStaticMethod() /*-{
$wnd.counter =
$entry(@mypackage.Class1Exposer::getClass1Counter());
}-*/;
}
On Friday, January 11, 2013 4:05:53 PM UTC+2, RyanZA wrote:
>
> Hi
>
> No need to go so extreme -
> https://developers.google.com/web-toolkit/doc/latest/DevGuideCodingBasicsJSNI#methods-fields
>
> You can access static java methods from javascript as described in that
> link.
>
> On Friday, January 11, 2013 2:59:46 PM UTC+2, Michael Vogt wrote:
>>
>> Hello.
>>
>> I would like to have to possibility to access a Java class variable from
>> JavaScript, without changing the Java class itself. The idea is, to display
>> the values of the variables continuously while the application is running.
>> The usecase for me right now would be, that I want to check the
>> calculations of a drag while I do the drag. Sure I can add GWT.log() calls,
>> but accessing these values without code changes would be so much nicer.
>>
>> I already tried to find a way, but failed so far. Any tips how to get
>> there? Maybe by providing a specific Generator that adds some JSNI code
>> automatically?
>>
>>
>> Thanks,
>> Michael
>>
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/kSX-3nHr74gJ.
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.