google-code-export / gwt-ext

Automatically exported from code.google.com/p/gwt-ext
0 stars 0 forks source link

Form button's addClickListener not working in hosted mode #71

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run attached application in hosted mode
2. Click button, no change triggered on label
3. Compile to javascript, in browser triggering works

What version of the product are you using? On what operating system?
Mac OS X/gwtext 0.9.1/GWT 1.4.10

I'm not sure whether the above is supposed to work. I suppose there are 
limitations to any 
Javascript support in hosted mode.

Original issue reported on code.google.com by Ives.Lan...@gmail.com on 20 Aug 2007 at 8:50

Attachments:

GoogleCodeExporter commented 9 years ago
This is a known issue and is most likely an issue with the OS X hosted browser. 

Please read this thread :
http://groups.google.com/group/gwt-ext/browse_thread/thread/126e16b8b2c7deeb

As mentioned in the thread, I have made a local change to the Button click 
listener
in SVN to accomodate this. Please try it out and see if it works.

Original comment by sanjiv.j...@gmail.com on 20 Aug 2007 at 8:59

GoogleCodeExporter commented 9 years ago
I did a checkout, build and retry. The change doesn't solve the issue.

Let me know if there's anything else I may try.

Original comment by Ives.Lan...@gmail.com on 20 Aug 2007 at 10:32

GoogleCodeExporter commented 9 years ago
Do you see any error in the hosted mode console?

You can try troubleshooting by :

1) including ext-all-debug.js instead of ext-all.js

2) search for the following code in the Button class

    onClick : function(e){          
add->   alert('type is ' + e.type);
add->   alert('button val is ' + e.button);
add->   alert('is disabled ' + this.disabled);
        if(e){
            e.preventDefault();
        }
        if(e.button != 0){
            return;
        }
        if(!this.disabled){
            if(this.enableToggle){
                this.toggle();
            }
            if(this.menu && !this.menu.isVisible()){
                this.menu.show(this.el, this.menuAlign);
            }
            this.fireEvent("click", this, e);
            if(this.handler){
                this.el.removeClass("x-btn-over");
                this.handler.call(this.scope || this, this, e);
            }
        }
    }

and modify the code below as indicated

Ext.util.Observable.prototype = {

    fireEvent : function(){
        var ce = this.events[arguments[0].toLowerCase()];
add-->  if(arguments[0].toLowerCase() == 'click') alert(' ce is ' + ce);
        if(typeof ce == "object"){
add-->      if(arguments[0].toLowerCase() == 'click') {
               var args = Array.prototype.slice.call(arguments, 1);
               alert(' arguments length ' + args.length);  //should be 2
               alert(' first arg ' + args[0]); 
               alert(' second arg ' + args[1]); 
            }
            return ce.fire.apply(ce, Array.prototype.slice.call(arguments, 1));
        }else{
            return true;
        }
    }

Let me know the results of each alert statement.

Original comment by sanjiv.j...@gmail.com on 20 Aug 2007 at 11:46

GoogleCodeExporter commented 9 years ago
I don't see any error in the console.

Output of the alert statements:

type is click
button val is 0
is disabled false
ce is [object Object]
arguments length 2
first arg [object Object]
second arg [object Object]

Original comment by Ives.Lan...@gmail.com on 21 Aug 2007 at 6:56

GoogleCodeExporter commented 9 years ago
Actually, I do get output (I was not looking in my Eclipse console window+ 
console output only appeared 
after I close the hosted mode application). Following output appeared, using 
GWT 1.4.59

(event handler):Value undefined (result of expression 
__static["@com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/cli
ent/JavaScriptObject;)"]) is 
not object.
(event handler):Value undefined (result of expression 
__static["@com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/cli
ent/JavaScriptObject;)"]) is 
not object.
(event handler):Value undefined (result of expression 
__static["@com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/cli
ent/JavaScriptObject;)"]) is 
not object.
(event handler):Value undefined (result of expression 
__static["@com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/cli
ent/JavaScriptObject;)"]) is 
not object.

Original comment by Ives.Lan...@gmail.com on 21 Aug 2007 at 9:37

GoogleCodeExporter commented 9 years ago
Reset my environment back to GWT 1.4.10. Same console output there:

(event handler):Value undefined (result of expression 
__static["@com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/cli
ent/JavaScriptObject;)"]) is 
not object.
(event handler):Value undefined (result of expression 
__static["@com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/cli
ent/JavaScriptObject;)"]) is 
not object.
(event handler):Value undefined (result of expression 
__static["@com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/cli
ent/JavaScriptObject;)"]) is 
not object.
(event handler):Value undefined (result of expression 
__static["@com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/cli
ent/JavaScriptObject;)"]) is 
not object.
(event handler):Value undefined (result of expression 
__static["@com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/cli
ent/JavaScriptObject;)"]) is 
not object.

Original comment by Ives.Lan...@gmail.com on 21 Aug 2007 at 9:42

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Thats odd. The output from the alerts seem okay. Try setting a breakpoint on 
the line
below in the EventObject class and when the button is clicked, analyze the even
object in your debugger. (Expand the the object properties in your debugger and 
let
me know what they look like. For example the 'variant' and 'type'

    public static EventObject instance(JavaScriptObject event) {
-->        return new EventObject(event);
    }

Original comment by sanjiv.j...@gmail.com on 21 Aug 2007 at 11:37

GoogleCodeExporter commented 9 years ago
I made another minor change to the Button class. Can you please update from SVN 
and
try again.

Original comment by sanjiv.j...@gmail.com on 21 Aug 2007 at 11:47

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Ran update, build library, no luck :-(
Breakpoint : doesn't get triggered (unless I do something wrong)

Put a breakpoint on the EventObject class itself(triggered when class is 
loaded). 
It gets hit, during execution of the static initializer section an 
EmptyStackException is thrown from the inner 
workings of GWT. Not sure whether this is because of the debugging itself or 
the root cause (threadlocal). 

In any case this is deep into mac specific gwt code. The exception is thrown 
when below method invokes 
peek() on an apparently empty stack object. Results are the same for gwt 1.4.10 
and 1.4.59

package com.google.gwt.dev.shell.mac;
public class LowLevelSaf { 

  public static int getExecState() {
    Stack stack = (Stack) stateStack.get();
    if (stack == null) {
      throw new RuntimeException("No thread local execState stack!");
    }
    Integer top = (Integer) stack.peek();
    return top.intValue();
  }

Original comment by Ives.Lan...@gmail.com on 22 Aug 2007 at 7:35

GoogleCodeExporter commented 9 years ago
Appears like a deep issue which is going to be extremely hard for me to 
troubleshoot
without access to an OS X box. You're in a better position to get to the root 
of this
and seems like you've narrowed it down somewhat. I would suggest you try to 
write
some basic javascript code in a JSNI method where you register an onclick 
handler to
a button using vanilla JS / DOM code and see if you can reproduce the issue. 
And if
you do, you can submit an issue with GWT.

Original comment by sanjiv.j...@gmail.com on 22 Aug 2007 at 8:12

GoogleCodeExporter commented 9 years ago
The deep issue will probably be too deep for me ;-) 

However, I noted during my debug session that the issue seemed to be triggered 
by the creation of a class 
instance during the initialization of the class itself. 

I "hacked" a bit on the EventObject code, so that the class is initialized 
before any of the constants are 
populated. Below hack makes ExtGwt buttons work on GWT hosted mode:
Note: below code is a hack, and may lead to side effects, because the constants 
are only initialized AFTER 
the first EventObject has been created. I only did a minimal test: my test case 
now works.

In package com.gwtext.client.core:

public class EventObject extends JsObject {

    public static int BACKSPACE, CONTROL, DELETE, DOWN, END, ENTER, ESC, F5, HOME, LEFT, PAGEDOWN,
            PAGEUP, RETURN, RIGHT, SHIFT, SPACE, TAB, UP;

    public static boolean initialized = false;

    static {
 //       initConstants();
    }

    public EventObject(JavaScriptObject jsObj) {
        super(jsObj);

        if(!initialized) {
            initialized = true;
            initConstants();
        }

    }

Original comment by Ives.Lan...@gmail.com on 23 Aug 2007 at 7:57

GoogleCodeExporter commented 9 years ago
Interesting. Can you try adding this line to the init() method of
com.gwtext.client.core,JsObject and remove you changes to the constructor.

@com.gwtext.client.core.EventObject::initConstants()();

Leave the initMethods() call in EventObject commented out. 

Let me know if it works. Could be some timing condition that is hit in OS X 
hosted
mode when static initializers are used.

Original comment by sanjiv.j...@gmail.com on 23 Aug 2007 at 8:06

GoogleCodeExporter commented 9 years ago
Works too, although I experienced "something": I recompiled/restartedseveral 
times, and had two occurrences 
where the test screen first gives an error (no details provided, only a message 
box + no screen content). Error 
was gone after hitting refresh or restart. I can't consistently reproduce it 
(and there are absolutely no details 
given for the error). 

Anyway, I reverted the code to my hack, and experienced exactly the same 
behaviour. It's nothing I can't live 
with.

Original comment by Ives.Lan...@gmail.com on 23 Aug 2007 at 8:39

GoogleCodeExporter commented 9 years ago
Moving the initConstants() to JsObject as mentioned in my previous mail is a 
safe
change that seems to keep OS X hosted somewhat happy. I'll check in this change.

Original comment by sanjiv.j...@gmail.com on 23 Aug 2007 at 8:44

GoogleCodeExporter commented 9 years ago
Checked in the workaround as described above. 

Original comment by sanjiv.j...@gmail.com on 25 Aug 2007 at 4:50

GoogleCodeExporter commented 9 years ago
Great! Did a small test, works fine.

Original comment by Ives.Lan...@gmail.com on 26 Aug 2007 at 8:43

GoogleCodeExporter commented 9 years ago

Original comment by sanjiv.j...@gmail.com on 29 Aug 2007 at 9:43