Re: Trying to export non-static methods to javascript via JSNI

2014-02-15 Thread Jens

>
> I should point out the differences.  In the first non-working example I 
> use 'this' in my export.  In the second example I remove the 'this' and 
> declare my log() method as static.
>

You already answered your own question more or less. Your export method is 
static while your log method is not. That means you can not access your log 
method using "this" inside a static JSNI method.

So you either make export() non static and keep "this", or you keep 
export() static and provide an instance as parameter if you want to keep 
log() an instance method or you make all methods static and remove "this".


All instance methods:


public class Main implements EntryPoint {
 public void onModuleLoad() {
   this.export();
 }

 public void log(String msg) {
  ...
 }
 
 public native void export() /*-{
   $wnd.log = $entry(th...@package.main::log(Ljava/lang/String));

 }-*/;


Static export() but instance log() method:


public class Main implements EntryPoint {
 public void onModuleLoad() {
   Main.export(this);
 }

 public void log(String msg) {
  ...
 }
 
 public static native void export(Main main) /*-{
   $wnd.log = $entry(ma...@package.main::log(Ljava/lang/String));

 }-*/;


All static methods:



public class Main implements EntryPoint {
 public void onModuleLoad() {
   Main.export();
 }

 public static void log(String msg) {
  ...
 }
 
 public static native void export() /*-{
   $wnd.log = $entry(@package.Main::log(Ljava/lang/String));

 }-*/;

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Getting "$doc.createStyleSheet is not a function" when injecting CSS on Firefox for GWT 2.6.0

2014-02-15 Thread pgieser
Our application seems to behave correctly under GWT 2.5.1, and bundles CSS 
as follows:

public interface CssResourceBundle extends ClientBundle {

CssResourceBundle INSTANCE = GWT.create(CssResourceBundle.class);

@CssResource.NotStrict
@Source("com/xxx/javascript/some.css")
CssResource css();
}


with an entry point:

public class AnEntryPoint implements EntryPoint {

static {
CssResourceBundle.INSTANCE.css().ensureInjected();
}

@Override
public void onModuleLoad() {
  // xxx
}
}


However, after upgrading to GWT 2.6.0, we're seeing an exception (that 
prevents the CSS from being injected) on Firefox (but not for example on 
Chrome or Safari):


Mon Feb 10 22:39:53 GMT-500 2014 
com.google.gwt.logging.client.LogConfiguration
SEVERE: (TypeError)
__gwt$exception: 
fileName: xxx lineNumber: 301
columnNumber: 21: $doc.createStyleSheet is not a 
functioncom.google.gwt.core.client.JavaScriptException: (TypeError)
__gwt$exception: 
fileName: xxx
lineNumber: 301
columnNumber: 21: $doc.createStyleSheet is not a function



Any suggestions for what may be going on here?

Thanks,
Pete

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Form factor support using GIN

2014-02-15 Thread Kadaici Tamilan
Yes It worked. Thanks.

On Friday, February 14, 2014 8:51:38 PM UTC, Jens wrote:
>
> Do your Desktop/Tablet/MobileGinjectors extend from MyGinjector?
>
> -- J.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Getting "$doc.createStyleSheet is not a function" when injecting CSS on Firefox for GWT 2.6.0

2014-02-15 Thread Thomas Broyer
Looks a lot 
like 
https://groups.google.com/d/topic/google-web-toolkit-contributors/RkC3OKdlsQ8/discussion
Are you using soft-permutations? (i.e. collapse properties)

On Saturday, February 15, 2014 5:54:13 AM UTC+1, pgi...@gmail.com wrote:
>
> Our application seems to behave correctly under GWT 2.5.1, and bundles CSS 
> as follows:
>
> public interface CssResourceBundle extends ClientBundle {
>
> CssResourceBundle INSTANCE = GWT.create(CssResourceBundle.class);
>
> @CssResource.NotStrict
> @Source("com/xxx/javascript/some.css")
> CssResource css();
> }
>
>
> with an entry point:
>
> public class AnEntryPoint implements EntryPoint {
>
> static {
> CssResourceBundle.INSTANCE.css().ensureInjected();
> }
>
> @Override
> public void onModuleLoad() {
>   // xxx
> }
> }
>
>
> However, after upgrading to GWT 2.6.0, we're seeing an exception (that 
> prevents the CSS from being injected) on Firefox (but not for example on 
> Chrome or Safari):
>
>
> Mon Feb 10 22:39:53 GMT-500 2014 
> com.google.gwt.logging.client.LogConfiguration
> SEVERE: (TypeError)
> __gwt$exception: 
> fileName: xxx lineNumber: 301
> columnNumber: 21: $doc.createStyleSheet is not a 
> functioncom.google.gwt.core.client.JavaScriptException: (TypeError)
> __gwt$exception: 
> fileName: xxx
> lineNumber: 301
> columnNumber: 21: $doc.createStyleSheet is not a function
>
>
>
> Any suggestions for what may be going on here?
>
> Thanks,
> Pete
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Trying to export non-static methods to javascript via JSNI

2014-02-15 Thread Thomas Broyer
You need to "bind" the method to the instance, e.g.

$wnd.log = $entry(function(msg) { 
instan...@pack.age.main::log(Ljava/lang/String;)(msg); });

Note that 'instance' cannot be 'this' here, because 'this' is a keyword, 
not a variable. You could for instance pass your 'this' as argument to the 
export() method so you have a variable pointing to your instance, or you 
could just store your instance in a variable outside the closure:

var that = this;
$wnd.log = $entry(function(msg) { 
th...@pack.age.main::log(Ljava/lang/String;)(msg); });

On Saturday, February 15, 2014 7:51:13 AM UTC+1, rjcarr wrote:
>
> The subject sums it up pretty well, so let's get right to code:
>
> public class Main implements EntryPoint {
>  public void onModuleLoad() {
>export();
>  }
>
>  public void log(String msg) {
>   ...
>  }
>  
>  public static native void export() /*-{
>$wnd.log = $entry(th...@package.main::log(Ljava/lang/String));
>
>  }-*/;
>
> This doesn't work for me and I get giant stack traces in my javascript 
> logs.  I got this idea from the JSNI docs so not sure where I'm going 
> wrong.  However, if I change things to this:
>
> public class Main implements EntryPoint {
>  public void onModuleLoad() {
>export();
>  }
>
>  public static void log(String msg) {
>   ...
>  }
>  
>  public static native void export() /*-{
>$wnd.log = $entry(@package.Main::log(Ljava/lang/String));
>
>  }-*/;
>
> Then it works fine.  What am I doing wrong?  Thanks!
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Help] GWT + GAE + Android - Where to start?

2014-02-15 Thread Andrew Mackenzie
Hi Bruno,
well you've made a lot of progress, so congratulations.

I think we need to overcome a basic misconception before going further

On the server side, you should only have ONE project, a combined GAE and
GWT project, not two.
No need to copy classes and files between projects, etc.
Just think about appengine being the application server that runs your GWT
(Javascript) web app.as if it was TomCat or some other app server.

The only difference over a "GAE only" project is that the GWT compiler will
generate JavaScript for you (from your Java code in your /client subfolders
for each GWT Module), and if you use GWT-RPCs, then you will have server
side code and should include the GWT jars (gwt-user.jar) to receive those
RPC requests and respond to them.

To "load" your GWT generated javascript you just need to add a normal

Re: SuperDevMode and -noserver (Tomcat) debugging

2014-02-15 Thread Thomas Broyer


On Friday, February 14, 2014 5:08:50 AM UTC+1, Thad Humphries wrote:
>
> I thought I had this working, and I do, but only in one project. Now I'm 
> trying to recreate the magic, and it's not working.
>
> I've an older project that I started running SuperDevMode from a console 
> and DevMode from Eclipse. Since I wanted some features of Tomcat, I 
> switched to running the app as a Remote Java Application. Debugging works. 
> Moreover, when I make a change in a server-only class--like a servlet--the 
> change is there on the very next run.
>
> I want to recreate what I've done and document it for the next guy. 
> Accordingly I
>
> 1) Generate a new project, Foo, using the gwt-maven-plugin archetype.
>
> 2) Add pluginManagement for org.eclipse.m2e to my pom.xml so Eclipse won't 
> squawk about i18n and import the project (see 
> http://stackoverflow.com/questions/16068127/maven-gwt-2-5-1-setup-issue)
>

You'd better just remove the i18n line from the generated 
project. That's one of the things that are plain wrong with the archetype 
(and the gwt-maven-plugin), IMO.
 

> 3) Add 
>
>   
>   
>

Note that in 2.6.0 you no longer need that second line, it's enabled by 
default.
 

> to the module file.
>
> 4) Run `mvn clean generate-sources gwt:run` from a console.
>

No need to include "generate-sources" here, gwt:run should fork an "mvn 
process-classes" when run.
 

> 5) Launch the app in the browser then quit DevMode.
>
> 6) Copy target/Foo-1.0-SNAPSHOT to $CATALINA_HOME/webapps/Foo
>

Wouldn't it be easier to run "mvn package" or "mvn package 
-Dgwt.compiler.skip" ? (you need the GWT compile on the very first time 
though)
But actually, much better would be to just point Tomcat at your 
target/Foo-1.0-SNAPSHOT, or start Tomcat using the tomcat7-maven-plugin 
(unless you have some special Tomcat config that you cannot replicate with 
the tomcat7-maven-plugin).
 

> 7) Run `mvn clean generate-sources gwt:run-codeserver` from a console.
>

There you should use "process-classes" instead of "generate-sources". Note 
that gwt:run-codeserver seems to be fixed in 'master', maybe I'll release 
2.6.0-1 this week-end, but in the mean time you can build the plugin 
yourself to try it out.
 

> 8) In Eclipse, create a Debug Remote Java Application on Foo and run it.
>
> 9) Open http://localhost:8080/Foo in my browser (Chrome).
>
> 10) Turn Dev Mode On. Compile. Project runs.
>
> If I put a breakpoint in my servlet (GreetingServiceImpl), it breaks in 
> the Eclipse debugger.
>
> 11) Disconnect from Tomcat (in Eclipse). Modify GreetingServiceImpl.java. 
> Restart the remote debug in Eclipse.
>

You shouldn't need to restart remote debugging.
 

> 12) In the browser, turn Dev Mode Off, turn Dev Mode On, and Compile
>

Note that you don't need to "Dev Mode Off", you can just click again on 
"Dev Mode On" at will.
 

> When I call the RPC function, the change made in Step #11 does NOT take 
> effect, though I can see those changes while stepping 
> through GreetingServiceImpl in the Eclipse debugger.
>

Are you sure you're *seeing* these changes? Sure Eclipse shows you your 
local source file, but are you sure it's in sync with the code that 
actually runs? (I doubt it)
 

> What could I be missing?
>

You didn't re-deploy your modified class to your Tomcat instance, so it's 
still running the one you put there at step #6.
 

> As I said, in my older project (which has gone through some evolution from 
> 2.5.1 to 2.6.0, from DevMode to SuperDevMode and -noserver, from Java 1.5 
> to 1.6 to 1.7, etc.) server-side changes show on the next run. What might 
> be missing from a archetype generated project and/or from my Eclipse 
> configuration that would cause server-side change to NOT take effect in Foo 
> when they do elsewhere?
>

You could run Tomcat from within Eclipse (using WTP or similar) so that 
Eclipse automatically (or in a single click) redeploys your server-side 
code.
Or you could start Tomcat using the tomcat7-maven-plugin, it then scans the 
target/Foo-1.0-SNAPSHOT and automatically redeploys the app when there's a 
change (each time you save a file in Eclipse, so beware of memory leaks!)
Or you could point your external Tomcat to your target/Foo-1.0-SNAPSHOT 
(could be just a symlink), and redeploy your app "the Tomcat way" (which I 
have no idea what it is).
Or you could deploy your app to your Tomcat using the tomcat7-maven-plugin 
(just use -Dgwt.compiler.skip to skip GWT compilation)

I've had success with "mvn tomcat7:run", "mvn jetty:run" and pointing an 
external Jetty to my target/Foo-1.0-SNAPSHOT.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visi

Re: Trying to export non-static methods to javascript via JSNI

2014-02-15 Thread Jens

>
> $wnd.log = $entry(function(msg) { 
> instan...@pack.age.main::log(Ljava/lang/String;)(msg); });
>

 Oh right. Somehow I totally ignored the method parameter that needs to be 
passed around.


-- J.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: RequestFactoryEditorDriver Can P be a list of proxy ?

2014-02-15 Thread Thomas Broyer
Note that you should only use that for display, or implement a 
"stage/commit" feature in your cells (as 
in 
http://gwt.googleusercontent.com/samples/Showcase/Showcase.html#!CwCellSampler) 
or you're breaking the edit/flush flow of the Editor framework (your cells 
directly updating the edited objects rather than waiting for the flush()).
Not that it'll cause any issue (you'd have to try it), just "theoretical 
purity".

On Friday, February 14, 2014 9:11:56 PM UTC+1, Rogelio Flores wrote:
>
> On the other hand, if you are editing a list of proxies and using a 
> DataGrid, you want to take a look at
> HasDataEditor, which allows you to edit a list of proxies by doing simply 
> this:
>
> HasDataEditor myListEditor = HasDataEditor.of(myDataGrid)
>
>
> On Friday, February 14, 2014 6:07:46 AM UTC-5, Thomas Broyer wrote:
>>
>> You don't need the editor framework to feed a DataGrid.
>>
>> For other use-cases, workarounds include using an EditorDriver per value 
>> in the list, or having the list as a property in a wrapper object.
>>
>> On Friday, February 14, 2014 9:13:13 AM UTC+1, pierre laurent wrote:
>>>
>>> Hi There,
>>>
>>> Interface RequestFactoryEditorDriver>> Editor
>>> >
>>>  Type Parameters:P - the type of Proxy being editedE - the type of 
>>> Editor that will edit the Record
>>>
>>>
>>> Can P be a list of proxy ?
>>>
>>> I do have a list of proxy ( see below ) i want to fill within a 
>>> datagrid, 
>>> if not possible, is there any workaround ?
>>>
>>>   interface HistoFichesDriver extends
>>>  RequestFactoryEditorDriver, HistofichesEditor> {
>>> }
>>>
>>>
>>> Regards,
>>>
>>> Pierre
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Excluding permutation compilation combinations?

2014-02-15 Thread Thomas Broyer
Is this what you're looking 
for: https://code.google.com/p/google-web-toolkit/wiki/ConditionalProperties 
?

On Friday, February 14, 2014 5:19:09 PM UTC+1, Ed wrote:
>
> How can I exclude certain permutation compilation combinations?
> Example: I have the following combination showing in my soyc report that I 
> like to exclude:
> 'ipad' , 'user.agent' : 'ie9'
>
> Note: I know how to hard code the required compiler permutations output 
> (include action), that I use during development, but for production I like 
> to config it the other way around: exclude some combinations.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Using SuperDevMode with code splitting

2014-02-15 Thread Thomas Broyer


On Friday, February 14, 2014 8:50:22 PM UTC+1, Luis Fernando Planella 
Gonzalez wrote:
>
> Well, after patching CompilerOptionsImpl in gwt-codeserver.jar to return 
> true in isRunAsyncEnabled(), the code server started splitting the code, 
> but source maps were only generated for the initial fragment.
> I don't know the internals, but shouldn't be terribly hard to have the 
> source maps for each split point, right? Or isn't it at all supported by 
> the compiler?
> Compiling using "-saveSource -saveSourceOutput " together with 
>  and 
>  
> correctly saves all sources in the output dir and sets the source map 
> comments on each script...
> Also, the CompilerOptionsImpl has this:
>   @Override
>   public boolean shouldSaveSource() {
> return false; // handling this a different way
>   }
>
> This "different way" is explicitly not handling the runAsync case.
> Is there a strong reason for this?
>

SuperDevMode loads the source code right form its classpath (the same way 
as when it compiles it) when sending it to the browser (see SourceHandler 
and ModuleState).
That said, copying the sources would 
solve https://code.google.com/p/google-web-toolkit/issues/detail?id=7615 
(but saveSource has only been added recently, and I suspect SuperDevMode 
just hasn't caught up yet)
 

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Trying to export non-static methods to javascript via JSNI

2014-02-15 Thread Robert J. Carr
Thanks for the quick responses.  That makes sense that since the jsni
method is declared static that you can't use this, but I'm not following
Thomas's explanation.  Maybe I could just get an explanation from the docs
example here:

http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJSNI.html#methods-fields

Under the example: Accessing Java fields from JavaScript

Where it has:

public class JSNIExample {

  String myInstanceField;
  static int myStaticField;

  void instanceFoo(String s) {
// use s
  }

  static void staticFoo(String s) {
// use s
  }

  public native void bar(JSNIExample x, String s) /*-{
// Call instance method instanceFoo() on this

th...@com.google.gwt.examples.JSNIExample::instanceFoo(Ljava/lang/String;)(s);

// Call instance method instanceFoo() on x

x...@com.google.gwt.examples.JSNIExample::instanceFoo(Ljava/lang/String;)(s);

// Call static method staticFoo()
@com.google.gwt.examples.JSNIExample::staticFoo(Ljava/lang/String;)(s);

What's the difference here between using the 'this' and the passed in 'x'?
 What does 'this' represent in this example?

As for Thomas's explanation, are you saying that by calling $entry it
creates a new inner function (or closure) where 'this' is no longer what it
was?  So if I didn't use $entry then 'this' would be what I expect it is?

Thanks again for the help!

Robert


On Sat, Feb 15, 2014 at 4:26 AM, Jens  wrote:
>>
>> $wnd.log = $entry(function(msg) { 
>> instan...@pack.age.main::log(Ljava/lang/String;)(msg);
});
>
>
>  Oh right. Somehow I totally ignored the method parameter that needs to
be passed around.
>
>
> -- J.
>
> --
> You received this message because you are subscribed to a topic in the
Google Groups "Google Web Toolkit" group.
> To unsubscribe from this topic, visit
https://groups.google.com/d/topic/google-web-toolkit/rJAnzDPb_2Y/unsubscribe
.
> To unsubscribe from this group and all its topics, send an email to
google-web-toolkit+unsubscr...@googlegroups.com.
> To post to this group, send email to google-web-toolkit@googlegroups.com.
> Visit this group at http://groups.google.com/group/google-web-toolkit.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Trying to export non-static methods to javascript via JSNI

2014-02-15 Thread Thomas Broyer


On Saturday, February 15, 2014 6:00:47 PM UTC+1, rjcarr wrote:
>
> Thanks for the quick responses.  That makes sense that since the jsni 
> method is declared static that you can't use this, but I'm not following 
> Thomas's explanation.  Maybe I could just get an explanation from the docs 
> example here:
>
>
> http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJSNI.html#methods-fields
>
> Under the example: Accessing Java fields from JavaScript
>
> Where it has:
>
> public class JSNIExample {
>
>   String myInstanceField;
>   static int myStaticField;
>
>   void instanceFoo(String s) {
> // use s
>   }
>
>   static void staticFoo(String s) {
> // use s
>   }
>
>   public native void bar(JSNIExample x, String s) /*-{
> // Call instance method instanceFoo() on this
> 
> th...@com.google.gwt.examples.JSNIExample::instanceFoo(Ljava/lang/String;)(s);
>
> // Call instance method instanceFoo() on x
> 
> x...@com.google.gwt.examples.JSNIExample::instanceFoo(Ljava/lang/String;)(s);
>
> // Call static method staticFoo()
> @com.google.gwt.examples.JSNIExample::staticFoo(Ljava/lang/String;)(s);
>
> What's the difference here between using the 'this' and the passed in 'x'? 
>  What does 'this' represent in this example?
>

The 'this' is the same here as it would be in Java, difference between 
'this' and 'x' is the same too.
 

>
> As for Thomas's explanation, are you saying that by calling $entry it 
> creates a new inner function (or closure) where 'this' is no longer what it 
> was?  So if I didn't use $entry then 'this' would be what I expect it is?
>

It has nothing to do with $entry() but the fact that you export a method of 
an object, and the way things (and specifically 'this') work in JavaScript.

Let's use pure JS:

function JSExample() { };
JSExample.prototype.instanceFoo = function(s) {
  // use s
};
JSExample.staticFoo = function(s) {
  // use s
};
JSExample.prototype.bar = function(x, s) {
  this.instanceFoo(s);
  x.instanceFoo(s);
  JSExample.staticFoo(s);
};

We can create a JSExample instance and call bar:

var y = new JSExample();
y.bar(new JSExample(), "msg");

Now export the method from 'y' without binding it to the JSExample instance 
and try to call it:

var foo = y.bar; // could be window.foo instead of var foo; y.bar is the 
same as JSExample.prototype.bar
foo(new JSExample(), "msg"); // fails because 'window' (the current 'this') 
does not have an 'instanceFoo' property
foo.call(y, new JSExample(), "msg"); // works because we explicitly set the 
'this' to 'y'

Now export the method, binding it to 'y' (using a closure) and call it:

var foo = function(x, s) { y.bar(x, s); };
foo(new JSExample(), "msg"); // works, because we call 'bar' on 'y'

Introduce $entry:

var foo = $entry(function(x, s) { y.bar(x, s); });
foo(new JSExample(), "msg"); // works the same

With ECMAScript 5, you could now use y.bar.bind(y) instead of using a 
closure, and with "use strict" the "default 'this'" would be 'null', not 
'window'.

When I say GWT doesn't free you from knowing JS, I really mean it!

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: gwt 2.6 SuperDevMode and injected css problem

2014-02-15 Thread Vassilis Virvilis
I tried to reproduce it with GWT default project and I failed so I don't 
have a simplistic minimal project to contribute. However I enabled 
client side logging with gwt-log and it fails with


__gwt$exception: 
fileName: xxx lineNumber: 401
columnNumber: 21: $doc.createStyleSheet is not a function 
com.google.gwt.core.client.JavaScriptException: (TypeError)

__gwt$exception: 

There is another thread currently going on and a link from there
https://groups.google.com/forum/#!topic/google-web-toolkit/hJP0z9ethaY
https://groups.google.com/d/topic/google-web-toolkit-contributors/RkC3OKdlsQ8/discussion

which match my experience.

  thanks

On 02/11/14 02:16, Colin Alworth wrote:
With Super Dev Mode off, the browser simply loads the compiled code 
from the regular web server, so this suggests that either Super Dev 
Mode is being used as your regular server (and so only one copy of the 
app is available at a time, for the last browser it compiled for), or 
your normal compiled app is being compiled with those browsers turned 
off. The fact that SDM is able to generate code for those browsers 
suggests that the code itself is fine, and that either your project 
simply needs to be recompiled, or properties are set up in your 
.gwt.xml to exclude those browsers. Without seeing code or the running 
app, it is hard to be more specific.



On Sat, Feb 8, 2014 at 11:50 PM, Vassilis Virvilis > wrote:


Hi Colin,

The problem is when DevMod is off. As I said when when DevMod is
on (with compile) everything works in all browsers. However when I
am not developing I would expect that site would be working with
the version of software currently deployed for all browsers and
not only chrome.

Right now I am getting blank pages in firefox and IE.

   Vassilis


On 02/08/14 03:07, Colin Alworth wrote:

Can you confirm that you are hitting the Compile button in
each browser and that the SDM console is indicating that it is
recompiling for each other user agent? It sounds as though you
might be compiling when you start up one browser, then just
turning dev mode on without recompiling in other browsers.

On Friday, February 7, 2014 4:25:18 PM UTC-6, Vassilis
Virvilis wrote:

Helo everybody,

I have enabled super dev mode and it works ok in chrome
but fails in
firefox and internet explorer.

More specifically

I added
 
 
 

in my gwt.xml

My application requires some css to be injected with

 Resources.INSTANCE.css().ensureInjected();

which I do as the first thing in onModuleLoad()

When dev mode is on (the bookmartlet) everything is
working in all
browsers
When dev mode if off only chrome is working. In firefox
and IE css
resources are not injected.

Any ideas?

  Vassilis

--
You received this message because you are subscribed to the Google 
Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to google-web-toolkit+unsubscr...@googlegroups.com.

To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


--
You received this message because you are subscribed to the Google Groups "Google 
Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Trying to export non-static methods to javascript via JSNI

2014-02-15 Thread Robert J. Carr
Thanks for the explanation and examples.  I actually know javascript quite
well, including the ramifications of using this inside of closures, but as
I said, I didn't know that $entry was setting up a closure.

You've given me enough information that I believe I can figure out my
problems now.  Thanks for helping me out!


On Sat, Feb 15, 2014 at 9:26 AM, Thomas Broyer  wrote:

>
>
> On Saturday, February 15, 2014 6:00:47 PM UTC+1, rjcarr wrote:
>>
>> Thanks for the quick responses.  That makes sense that since the jsni
>> method is declared static that you can't use this, but I'm not following
>> Thomas's explanation.  Maybe I could just get an explanation from the docs
>> example here:
>>
>> http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJSNI.html#
>> methods-fields
>>
>> Under the example: Accessing Java fields from JavaScript
>>
>> Where it has:
>>
>> public class JSNIExample {
>>
>>   String myInstanceField;
>>   static int myStaticField;
>>
>>   void instanceFoo(String s) {
>> // use s
>>   }
>>
>>   static void staticFoo(String s) {
>> // use s
>>   }
>>
>>   public native void bar(JSNIExample x, String s) /*-{
>> // Call instance method instanceFoo() on this
>> 
>> th...@com.google.gwt.examples.JSNIExample::instanceFoo(Ljava/lang/String;)(s);
>>
>> // Call instance method instanceFoo() on x
>> 
>> x...@com.google.gwt.examples.JSNIExample::instanceFoo(Ljava/lang/String;)(s);
>>
>> // Call static method staticFoo()
>> @com.google.gwt.examples.JSNIExample::staticFoo(Ljava/lang/String;)(s);
>>
>> What's the difference here between using the 'this' and the passed in
>> 'x'?  What does 'this' represent in this example?
>>
>
> The 'this' is the same here as it would be in Java, difference between
> 'this' and 'x' is the same too.
>
>
>>
>> As for Thomas's explanation, are you saying that by calling $entry it
>> creates a new inner function (or closure) where 'this' is no longer what it
>> was?  So if I didn't use $entry then 'this' would be what I expect it is?
>>
>
> It has nothing to do with $entry() but the fact that you export a method
> of an object, and the way things (and specifically 'this') work in
> JavaScript.
>
> Let's use pure JS:
>
> function JSExample() { };
> JSExample.prototype.instanceFoo = function(s) {
>   // use s
> };
> JSExample.staticFoo = function(s) {
>   // use s
> };
> JSExample.prototype.bar = function(x, s) {
>   this.instanceFoo(s);
>   x.instanceFoo(s);
>   JSExample.staticFoo(s);
> };
>
> We can create a JSExample instance and call bar:
>
> var y = new JSExample();
> y.bar(new JSExample(), "msg");
>
> Now export the method from 'y' without binding it to the JSExample
> instance and try to call it:
>
> var foo = y.bar; // could be window.foo instead of var foo; y.bar is the
> same as JSExample.prototype.bar
> foo(new JSExample(), "msg"); // fails because 'window' (the current
> 'this') does not have an 'instanceFoo' property
> foo.call(y, new JSExample(), "msg"); // works because we explicitly set
> the 'this' to 'y'
>
> Now export the method, binding it to 'y' (using a closure) and call it:
>
> var foo = function(x, s) { y.bar(x, s); };
> foo(new JSExample(), "msg"); // works, because we call 'bar' on 'y'
>
> Introduce $entry:
>
> var foo = $entry(function(x, s) { y.bar(x, s); });
> foo(new JSExample(), "msg"); // works the same
>
> With ECMAScript 5, you could now use y.bar.bind(y) instead of using a
> closure, and with "use strict" the "default 'this'" would be 'null', not
> 'window'.
>
> When I say GWT doesn't free you from knowing JS, I really mean it!
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Google Web Toolkit" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/google-web-toolkit/rJAnzDPb_2Y/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> google-web-toolkit+unsubscr...@googlegroups.com.
> To post to this group, send email to google-web-toolkit@googlegroups.com.
> Visit this group at http://groups.google.com/group/google-web-toolkit.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Trying to export non-static methods to javascript via JSNI

2014-02-15 Thread Thomas Broyer


On Saturday, February 15, 2014 10:54:13 PM UTC+1, rjcarr wrote:
>
> Thanks for the explanation and examples.  I actually know javascript quite 
> well, including the ramifications of using this inside of closures, but as 
> I said, I didn't know that $entry was setting up a closure.
>

It's not. It's taking a function as argument and returns a function. If you 
pass your 'y.bar' (to keep my pure-JS example) as argument, it'll 
ultimately be called just like my "var foo", and depending on the 'this' at 
the time of the call, it'll fail.
So you *have* to create a closure to bind 'bar' to 'y' (and pass that 
function to $entry), or you could use $entry(y.bar.bind(y)) which would be 
equivalent (but IE9+).

$entry basically is:

function $entry(f) {
  return function() {
try {
  run_entry_commands(); // see Scheduler#scheduleEntry
  try {
f.apply(this, arguments);
  } finally {
run_finally_commands(); // see Scheduler#scheduleFinally
  }
} catch (e) {
  reportUncaughtException(e); // see GWT#reportUncaughtException
}
  };
}

which, for the purpose of the example/demo, could be simplified as:

function $entry(f) {
  return function() { f.call(this, arguments); }
}

or even

function $entry(f) { return f; }

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


UIBinder: using own classes

2014-02-15 Thread Magnus
Hi,

I have subclassed MenuItem:

class MyMenuItem extends MenuItem


And I would like to use it in an UIBinder specification:

 
  
  ...


Where do I specify, which attributes are allowed in the UIBinder 
specification and how they are passed to the MyMenuItem class?

I cannot believe that it is sufficient to have a constructor with the same 
fields like this:

MyMenuItem (String text,String customField)


(In a constructor, the order of the parameters matters, in an XML element 
it does not.)

Can I only pass strings, or can I also pass other things, e. g. enums?

Thanks
Magnus



-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.