Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Custom JavaScript code gets loaded but not executed
Custom JavaScript code gets loaded but not executed [message #80062] Mon, 31 March 2008 07:29 Go to next message
Eclipse UserFriend
Originally posted by: markus.joosten.plumbe.de

Hello folks,

i have created a custom widget with my own JavaScript code based on the
GMap demo. I have stripped everything GMap-specific and now when i run
my app, i can see in the source code that my JS has been loaded. Using
the LCA, I create the corresponding widget via the JSWriter.
My JS Code basically contains a qx class with just one property.
My constructor just contains an alert statement.
I also copied the _doActivate() and _doResize() methods from the GMaps
example and removed the GMap-specific stuff.

Any Ideas?
Any help would be greatly appreciated :)

Greets,
Markus
Re: Custom JavaScript code gets loaded but not executed [message #80110 is a reply to message #80062] Mon, 31 March 2008 08:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fappel.innoopract.com

Hi,

could you please add your LCA and the javascript implementation, so that
we can see what's going on. It's a little bit difficult without
sufficient information to analyse your problem.

Ciao
Frank

-----Ursprüngliche Nachricht-----
Von: Markus Joosten [mailto:markus.joosten@plumbe.de]
Bereitgestellt: Montag, 31. März 2008 09:29
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: Custom JavaScript code gets loaded but not executed
Betreff: Custom JavaScript code gets loaded but not executed


Hello folks,

i have created a custom widget with my own JavaScript code based on the
GMap demo. I have stripped everything GMap-specific and now when i run
my app, i can see in the source code that my JS has been loaded. Using
the LCA, I create the corresponding widget via the JSWriter.
My JS Code basically contains a qx class with just one property.
My constructor just contains an alert statement.
I also copied the _doActivate() and _doResize() methods from the GMaps
example and removed the GMap-specific stuff.

Any Ideas?
Any help would be greatly appreciated :)

Greets,
Markus
Re: Custom JavaScript code gets loaded but not executed [message #80155 is a reply to message #80110] Mon, 31 March 2008 08:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: markus.joosten.plumbe.de

My JS Code is just this:

qx.Class.define( "org.eclipse.rap.demo.ebay.EBay", {
extend: qx.ui.layout.CanvasLayout,

construct: function( id ) {
alert("constructor");
this.base( arguments );
this.setHtmlAttribute( "id", id );
this._id = id;
},

properties : {
seller_id : {
init : "",
apply : "load"
}
},

destruct : function() {

},

members : {

_doActivate : function() {
alert("doActivate!");
var shell = null;
var parent = this.getParent();
while( shell == null && parent != null ) {
if( parent.classname == "org.eclipse.swt.widgets.Shell" ) {
shell = parent;
}
parent = parent.getParent();
}
if( shell != null ) {
shell.setActiveChild( this );
}
},

load : function() {
alert("seller_id");
seller_id = "test";
},

_doResize : function() {
alert("_doResize called");
}
}
} );

My LCA looks like this:

package org.eclipse.rap.internal.ebay.ebaykit;

import java.io.IOException;

import org.eclipse.rwt.lifecycle.*;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Widget;

import org.eclipse.rap.demo.ebay.EBay;

public class EBayLCA extends AbstractWidgetLCA {
private static final String JS_PROP_SELLER_ID = "seller_id";
private static final String PROP_SELLER_ID = "seller_id";

public void preserveValues( final Widget widget ) {
ControlLCAUtil.preserveValues( ( Control )widget );
IWidgetAdapter adapter = WidgetUtil.getAdapter( widget );
adapter.preserve( PROP_SELLER_ID, ( ( EBay )widget ).getSeller_id() );
}

public void readData( final Widget widget ) {
}

public void renderInitialization( final Widget widget ) throws
IOException {
JSWriter writer = JSWriter.getWriterFor( widget );
String id = WidgetUtil.getId( widget );
writer.newWidget( "org.eclipse.rap.demo.ebay.EBay", new Object[] {
id } );
writer.set( "appearance", "composite" );
writer.set( "overflow", "hidden" );
ControlLCAUtil.writeStyleFlags( (EBay)widget );
}

public void renderChanges( final Widget widget ) throws IOException {
EBay ebay = ( EBay )widget;
ControlLCAUtil.writeChanges( ebay );
JSWriter writer = JSWriter.getWriterFor( widget );
writer.set( PROP_SELLER_ID, JS_PROP_SELLER_ID, ebay.getSeller_id() );
}

public void renderDispose( final Widget widget ) throws IOException {
JSWriter writer = JSWriter.getWriterFor( widget );
writer.dispose();
}

public void createResetHandlerCalls( String typePoolId ) throws
IOException
{
// TODO Auto-generated method stub

}

public String getTypePoolId( Widget widget )
{
// TODO Auto-generated method stub
return null;
}
}

I now would imagine that when my ebay object is created, it should call
the constructor. When I inspect the DOM in my browser, I can see my
org.eclipse.rap.demo.ebay.EBay object.

Greetings


Frank Appel schrieb:
> Hi,
>
> could you please add your LCA and the javascript implementation, so that
> we can see what's going on. It's a little bit difficult without
> sufficient information to analyse your problem.
>
> Ciao
> Frank
>
> -----Ursprüngliche Nachricht-----
> Von: Markus Joosten [mailto:markus.joosten@plumbe.de]
> Bereitgestellt: Montag, 31. März 2008 09:29
> Bereitgestellt in: eclipse.technology.rap
> Unterhaltung: Custom JavaScript code gets loaded but not executed
> Betreff: Custom JavaScript code gets loaded but not executed
>
>
> Hello folks,
>
> i have created a custom widget with my own JavaScript code based on the
> GMap demo. I have stripped everything GMap-specific and now when i run
> my app, i can see in the source code that my JS has been loaded. Using
> the LCA, I create the corresponding widget via the JSWriter.
> My JS Code basically contains a qx class with just one property.
> My constructor just contains an alert statement.
> I also copied the _doActivate() and _doResize() methods from the GMaps
> example and removed the GMap-specific stuff.
>
> Any Ideas?
> Any help would be greatly appreciated :)
>
> Greets,
> Markus
>
Re: Custom JavaScript code gets loaded but not executed [message #80362 is a reply to message #80155] Mon, 31 March 2008 13:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rsternberg.innoopract.com

Hi Markus,

your code looks good so far. If you work with Firebug you can try to
create a new instance of your widget in the Firebug console and check
that the alert is raised.

You said that the widget exists in the DOM tree. Thus, the constructor
must have been called. What exactly is the problem? Is the widget
invisible or is it displayed correctly but the alert is not brought up?

Ralf

Markus Joosten wrote:
> My JS Code is just this:
>
> qx.Class.define( "org.eclipse.rap.demo.ebay.EBay", {
> extend: qx.ui.layout.CanvasLayout,
>
> construct: function( id ) {
> alert("constructor");
> this.base( arguments );
> this.setHtmlAttribute( "id", id );
> this._id = id;
> },
>
> properties : {
> seller_id : {
> init : "",
> apply : "load"
> }
> },
>
> destruct : function() {
>
> },
>
> members : {
>
> _doActivate : function() {
> alert("doActivate!");
> var shell = null;
> var parent = this.getParent();
> while( shell == null && parent != null ) {
> if( parent.classname == "org.eclipse.swt.widgets.Shell" ) {
> shell = parent;
> }
> parent = parent.getParent();
> }
> if( shell != null ) {
> shell.setActiveChild( this );
> }
> },
>
> load : function() {
> alert("seller_id");
> seller_id = "test";
> },
>
> _doResize : function() {
> alert("_doResize called");
> }
> }
> } );
>
> My LCA looks like this:
>
> package org.eclipse.rap.internal.ebay.ebaykit;
>
> import java.io.IOException;
>
> import org.eclipse.rwt.lifecycle.*;
> import org.eclipse.swt.widgets.Control;
> import org.eclipse.swt.widgets.Widget;
>
> import org.eclipse.rap.demo.ebay.EBay;
>
> public class EBayLCA extends AbstractWidgetLCA {
> private static final String JS_PROP_SELLER_ID = "seller_id";
> private static final String PROP_SELLER_ID = "seller_id";
>
> public void preserveValues( final Widget widget ) {
> ControlLCAUtil.preserveValues( ( Control )widget );
> IWidgetAdapter adapter = WidgetUtil.getAdapter( widget );
> adapter.preserve( PROP_SELLER_ID, ( ( EBay )widget
> ).getSeller_id() );
> }
>
> public void readData( final Widget widget ) {
> }
>
> public void renderInitialization( final Widget widget ) throws
> IOException {
> JSWriter writer = JSWriter.getWriterFor( widget );
> String id = WidgetUtil.getId( widget );
> writer.newWidget( "org.eclipse.rap.demo.ebay.EBay", new Object[]
> { id } );
> writer.set( "appearance", "composite" );
> writer.set( "overflow", "hidden" );
> ControlLCAUtil.writeStyleFlags( (EBay)widget );
> }
>
> public void renderChanges( final Widget widget ) throws IOException {
> EBay ebay = ( EBay )widget;
> ControlLCAUtil.writeChanges( ebay );
> JSWriter writer = JSWriter.getWriterFor( widget );
> writer.set( PROP_SELLER_ID, JS_PROP_SELLER_ID,
> ebay.getSeller_id() );
> }
>
> public void renderDispose( final Widget widget ) throws IOException {
> JSWriter writer = JSWriter.getWriterFor( widget );
> writer.dispose();
> }
>
> public void createResetHandlerCalls( String typePoolId ) throws
> IOException
> {
> // TODO Auto-generated method stub
>
> }
>
> public String getTypePoolId( Widget widget )
> {
> // TODO Auto-generated method stub
> return null;
> }
> }
>
> I now would imagine that when my ebay object is created, it should call
> the constructor. When I inspect the DOM in my browser, I can see my
> org.eclipse.rap.demo.ebay.EBay object.
>
> Greetings
>
>
> Frank Appel schrieb:
>> Hi,
>>
>> could you please add your LCA and the javascript implementation, so that
>> we can see what's going on. It's a little bit difficult without
>> sufficient information to analyse your problem.
>>
>> Ciao
>> Frank
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Markus Joosten [mailto:markus.joosten@plumbe.de]
>> Bereitgestellt: Montag, 31. März 2008 09:29
>> Bereitgestellt in: eclipse.technology.rap
>> Unterhaltung: Custom JavaScript code gets loaded but not executed
>> Betreff: Custom JavaScript code gets loaded but not executed
>>
>>
>> Hello folks,
>>
>> i have created a custom widget with my own JavaScript code based on the
>> GMap demo. I have stripped everything GMap-specific and now when i run
>> my app, i can see in the source code that my JS has been loaded. Using
>> the LCA, I create the corresponding widget via the JSWriter.
>> My JS Code basically contains a qx class with just one property.
>> My constructor just contains an alert statement.
>> I also copied the _doActivate() and _doResize() methods from the GMaps
>> example and removed the GMap-specific stuff.
>>
>> Any Ideas?
>> Any help would be greatly appreciated :)
>>
>> Greets,
>> Markus
>>
Re: Custom JavaScript code gets loaded but not executed [message #80479 is a reply to message #80362] Tue, 01 April 2008 06:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: markus.joosten.plumbe.de

Hi,

thanks for verifying my code.
My widget on the client side contains nothing but an empty constructor
with the alert statement and one property. I didn't code further because
I wanted to check the functionality of my code so far :)
The shell of the widget is displayed correctly, but of course it's empty
because I haven't put something in it.

Greetings,
Markus

P.S.: How do I create a new instance of my widget with Firebug?

Ralf Sternberg schrieb:
> Hi Markus,
>
> your code looks good so far. If you work with Firebug you can try to
> create a new instance of your widget in the Firebug console and check
> that the alert is raised.
>
> You said that the widget exists in the DOM tree. Thus, the constructor
> must have been called. What exactly is the problem? Is the widget
> invisible or is it displayed correctly but the alert is not brought up?
>
> Ralf
>
> Markus Joosten wrote:
>> My JS Code is just this:
>>
>> qx.Class.define( "org.eclipse.rap.demo.ebay.EBay", {
>> extend: qx.ui.layout.CanvasLayout,
>>
>> construct: function( id ) {
>> alert("constructor");
>> this.base( arguments );
>> this.setHtmlAttribute( "id", id );
>> this._id = id;
>> },
>>
>> properties : {
>> seller_id : {
>> init : "",
>> apply : "load"
>> }
>> },
>>
>> destruct : function() {
>>
>> },
>>
>> members : {
>>
>> _doActivate : function() {
>> alert("doActivate!");
>> var shell = null;
>> var parent = this.getParent();
>> while( shell == null && parent != null ) {
>> if( parent.classname == "org.eclipse.swt.widgets.Shell" ) {
>> shell = parent;
>> }
>> parent = parent.getParent();
>> }
>> if( shell != null ) {
>> shell.setActiveChild( this );
>> }
>> },
>>
>> load : function() {
>> alert("seller_id");
>> seller_id = "test";
>> },
>>
>> _doResize : function() {
>> alert("_doResize called");
>> }
>> }
>> } );
>>
>> My LCA looks like this:
>>
>> package org.eclipse.rap.internal.ebay.ebaykit;
>>
>> import java.io.IOException;
>>
>> import org.eclipse.rwt.lifecycle.*;
>> import org.eclipse.swt.widgets.Control;
>> import org.eclipse.swt.widgets.Widget;
>>
>> import org.eclipse.rap.demo.ebay.EBay;
>>
>> public class EBayLCA extends AbstractWidgetLCA {
>> private static final String JS_PROP_SELLER_ID = "seller_id";
>> private static final String PROP_SELLER_ID = "seller_id";
>>
>> public void preserveValues( final Widget widget ) {
>> ControlLCAUtil.preserveValues( ( Control )widget );
>> IWidgetAdapter adapter = WidgetUtil.getAdapter( widget );
>> adapter.preserve( PROP_SELLER_ID, ( ( EBay )widget
>> ).getSeller_id() );
>> }
>> public void readData( final Widget widget ) {
>> }
>> public void renderInitialization( final Widget widget )
>> throws IOException {
>> JSWriter writer = JSWriter.getWriterFor( widget );
>> String id = WidgetUtil.getId( widget );
>> writer.newWidget( "org.eclipse.rap.demo.ebay.EBay", new
>> Object[] { id } );
>> writer.set( "appearance", "composite" );
>> writer.set( "overflow", "hidden" );
>> ControlLCAUtil.writeStyleFlags( (EBay)widget );
>> }
>>
>> public void renderChanges( final Widget widget ) throws
>> IOException {
>> EBay ebay = ( EBay )widget;
>> ControlLCAUtil.writeChanges( ebay );
>> JSWriter writer = JSWriter.getWriterFor( widget );
>> writer.set( PROP_SELLER_ID, JS_PROP_SELLER_ID,
>> ebay.getSeller_id() );
>> }
>>
>> public void renderDispose( final Widget widget ) throws
>> IOException {
>> JSWriter writer = JSWriter.getWriterFor( widget );
>> writer.dispose();
>> }
>>
>> public void createResetHandlerCalls( String typePoolId ) throws
>> IOException
>> {
>> // TODO Auto-generated method stub
>> }
>>
>> public String getTypePoolId( Widget widget )
>> {
>> // TODO Auto-generated method stub
>> return null;
>> }
>> }
>>
>> I now would imagine that when my ebay object is created, it should
>> call the constructor. When I inspect the DOM in my browser, I can see my
>> org.eclipse.rap.demo.ebay.EBay object.
>>
>> Greetings
>>
>>
>> Frank Appel schrieb:
>>> Hi,
>>>
>>> could you please add your LCA and the javascript implementation, so that
>>> we can see what's going on. It's a little bit difficult without
>>> sufficient information to analyse your problem.
>>>
>>> Ciao
>>> Frank
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: Markus Joosten [mailto:markus.joosten@plumbe.de]
>>> Bereitgestellt: Montag, 31. März 2008 09:29
>>> Bereitgestellt in: eclipse.technology.rap
>>> Unterhaltung: Custom JavaScript code gets loaded but not executed
>>> Betreff: Custom JavaScript code gets loaded but not executed
>>>
>>>
>>> Hello folks,
>>>
>>> i have created a custom widget with my own JavaScript code based on the
>>> GMap demo. I have stripped everything GMap-specific and now when i run
>>> my app, i can see in the source code that my JS has been loaded. Using
>>> the LCA, I create the corresponding widget via the JSWriter.
>>> My JS Code basically contains a qx class with just one property.
>>> My constructor just contains an alert statement.
>>> I also copied the _doActivate() and _doResize() methods from the GMaps
>>> example and removed the GMap-specific stuff.
>>>
>>> Any Ideas?
>>> Any help would be greatly appreciated :)
>>>
>>> Greets,
>>> Markus
>>>
Re: Custom JavaScript code gets loaded but not executed [message #80542 is a reply to message #80479] Tue, 01 April 2008 07:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: markus.joosten.plumbe.de

Well, i just tried to create the object via Firebug console:

new org.eclipse.rap.demo.ebay.EBay()

Now i got my alert message, so i can be sure the class definition is
correctly loaded.
So it seems, that in my LCA the JSWriter does not create the widget on
the client-side, am I right? But I can't find a mistake there.
The object i found in the DOM would be just the class definition i guess.

So what am I missing here?

Markus Joosten schrieb:
> Hi,
>
> thanks for verifying my code.
> My widget on the client side contains nothing but an empty constructor
> with the alert statement and one property. I didn't code further because
> I wanted to check the functionality of my code so far :)
> The shell of the widget is displayed correctly, but of course it's empty
> because I haven't put something in it.
>
> Greetings,
> Markus
>
> P.S.: How do I create a new instance of my widget with Firebug?
>
> Ralf Sternberg schrieb:
>> Hi Markus,
>>
>> your code looks good so far. If you work with Firebug you can try to
>> create a new instance of your widget in the Firebug console and check
>> that the alert is raised.
>>
>> You said that the widget exists in the DOM tree. Thus, the constructor
>> must have been called. What exactly is the problem? Is the widget
>> invisible or is it displayed correctly but the alert is not brought up?
>>
>> Ralf
>>
>> Markus Joosten wrote:
>>> My JS Code is just this:
>>>
>>> qx.Class.define( "org.eclipse.rap.demo.ebay.EBay", {
>>> extend: qx.ui.layout.CanvasLayout,
>>>
>>> construct: function( id ) {
>>> alert("constructor");
>>> this.base( arguments );
>>> this.setHtmlAttribute( "id", id );
>>> this._id = id;
>>> },
>>>
>>> properties : {
>>> seller_id : {
>>> init : "",
>>> apply : "load"
>>> }
>>> },
>>>
>>> destruct : function() {
>>>
>>> },
>>>
>>> members : {
>>>
>>> _doActivate : function() {
>>> alert("doActivate!");
>>> var shell = null;
>>> var parent = this.getParent();
>>> while( shell == null && parent != null ) {
>>> if( parent.classname == "org.eclipse.swt.widgets.Shell" ) {
>>> shell = parent;
>>> }
>>> parent = parent.getParent();
>>> }
>>> if( shell != null ) {
>>> shell.setActiveChild( this );
>>> }
>>> },
>>>
>>> load : function() {
>>> alert("seller_id");
>>> seller_id = "test";
>>> },
>>>
>>> _doResize : function() {
>>> alert("_doResize called");
>>> }
>>> }
>>> } );
>>>
>>> My LCA looks like this:
>>>
>>> package org.eclipse.rap.internal.ebay.ebaykit;
>>>
>>> import java.io.IOException;
>>>
>>> import org.eclipse.rwt.lifecycle.*;
>>> import org.eclipse.swt.widgets.Control;
>>> import org.eclipse.swt.widgets.Widget;
>>>
>>> import org.eclipse.rap.demo.ebay.EBay;
>>>
>>> public class EBayLCA extends AbstractWidgetLCA {
>>> private static final String JS_PROP_SELLER_ID = "seller_id";
>>> private static final String PROP_SELLER_ID = "seller_id";
>>>
>>> public void preserveValues( final Widget widget ) {
>>> ControlLCAUtil.preserveValues( ( Control )widget );
>>> IWidgetAdapter adapter = WidgetUtil.getAdapter( widget );
>>> adapter.preserve( PROP_SELLER_ID, ( ( EBay )widget
>>> ).getSeller_id() );
>>> }
>>> public void readData( final Widget widget ) {
>>> }
>>> public void renderInitialization( final Widget widget )
>>> throws IOException {
>>> JSWriter writer = JSWriter.getWriterFor( widget );
>>> String id = WidgetUtil.getId( widget );
>>> writer.newWidget( "org.eclipse.rap.demo.ebay.EBay", new
>>> Object[] { id } );
>>> writer.set( "appearance", "composite" );
>>> writer.set( "overflow", "hidden" );
>>> ControlLCAUtil.writeStyleFlags( (EBay)widget );
>>> }
>>>
>>> public void renderChanges( final Widget widget ) throws
>>> IOException {
>>> EBay ebay = ( EBay )widget;
>>> ControlLCAUtil.writeChanges( ebay );
>>> JSWriter writer = JSWriter.getWriterFor( widget );
>>> writer.set( PROP_SELLER_ID, JS_PROP_SELLER_ID,
>>> ebay.getSeller_id() );
>>> }
>>>
>>> public void renderDispose( final Widget widget ) throws
>>> IOException {
>>> JSWriter writer = JSWriter.getWriterFor( widget );
>>> writer.dispose();
>>> }
>>>
>>> public void createResetHandlerCalls( String typePoolId ) throws
>>> IOException
>>> {
>>> // TODO Auto-generated method stub
>>> }
>>>
>>> public String getTypePoolId( Widget widget )
>>> {
>>> // TODO Auto-generated method stub
>>> return null;
>>> }
>>> }
>>>
>>> I now would imagine that when my ebay object is created, it should
>>> call the constructor. When I inspect the DOM in my browser, I can see my
>>> org.eclipse.rap.demo.ebay.EBay object.
>>>
>>> Greetings
>>>
>>>
>>> Frank Appel schrieb:
>>>> Hi,
>>>>
>>>> could you please add your LCA and the javascript implementation, so
>>>> that
>>>> we can see what's going on. It's a little bit difficult without
>>>> sufficient information to analyse your problem.
>>>>
>>>> Ciao
>>>> Frank
>>>>
>>>> -----Ursprüngliche Nachricht-----
>>>> Von: Markus Joosten [mailto:markus.joosten@plumbe.de]
>>>> Bereitgestellt: Montag, 31. März 2008 09:29
>>>> Bereitgestellt in: eclipse.technology.rap
>>>> Unterhaltung: Custom JavaScript code gets loaded but not executed
>>>> Betreff: Custom JavaScript code gets loaded but not executed
>>>>
>>>>
>>>> Hello folks,
>>>>
>>>> i have created a custom widget with my own JavaScript code based on the
>>>> GMap demo. I have stripped everything GMap-specific and now when i run
>>>> my app, i can see in the source code that my JS has been loaded. Using
>>>> the LCA, I create the corresponding widget via the JSWriter.
>>>> My JS Code basically contains a qx class with just one property.
>>>> My constructor just contains an alert statement.
>>>> I also copied the _doActivate() and _doResize() methods from the GMaps
>>>> example and removed the GMap-specific stuff.
>>>>
>>>> Any Ideas?
>>>> Any help would be greatly appreciated :)
>>>>
>>>> Greets,
>>>> Markus
>>>>
Re: Custom JavaScript code gets loaded but not executed [message #80557 is a reply to message #80542] Tue, 01 April 2008 08:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: markus.joosten.plumbe.de

I got it working.
The problem was that the LCA wasn't created at all during startup.
Seemed to be some issue in my package naming conventions.
In order to avoid such mistakes in future projects, i would like to
implement the getAdapter(Class adapter) method in my widgets.
In this case, would this be my EBay() class in the package which also
holds the resources? How do I then call the getAdapter method? By hand
or is there some magic involved which calls this method?

Thanks for your help!

Greetings from Frankfurt,
Markus

Markus Joosten schrieb:
> Well, i just tried to create the object via Firebug console:
>
> new org.eclipse.rap.demo.ebay.EBay()
>
> Now i got my alert message, so i can be sure the class definition is
> correctly loaded.
> So it seems, that in my LCA the JSWriter does not create the widget on
> the client-side, am I right? But I can't find a mistake there.
> The object i found in the DOM would be just the class definition i guess.
>
> So what am I missing here?
>
> Markus Joosten schrieb:
>> Hi,
>>
>> thanks for verifying my code.
>> My widget on the client side contains nothing but an empty constructor
>> with the alert statement and one property. I didn't code further
>> because I wanted to check the functionality of my code so far :)
>> The shell of the widget is displayed correctly, but of course it's empty
>> because I haven't put something in it.
>>
>> Greetings,
>> Markus
>>
>> P.S.: How do I create a new instance of my widget with Firebug?
>>
>> Ralf Sternberg schrieb:
>>> Hi Markus,
>>>
>>> your code looks good so far. If you work with Firebug you can try to
>>> create a new instance of your widget in the Firebug console and check
>>> that the alert is raised.
>>>
>>> You said that the widget exists in the DOM tree. Thus, the
>>> constructor must have been called. What exactly is the problem? Is
>>> the widget invisible or is it displayed correctly but the alert is
>>> not brought up?
>>>
>>> Ralf
>>>
>>> Markus Joosten wrote:
>>>> My JS Code is just this:
>>>>
>>>> qx.Class.define( "org.eclipse.rap.demo.ebay.EBay", {
>>>> extend: qx.ui.layout.CanvasLayout,
>>>>
>>>> construct: function( id ) {
>>>> alert("constructor");
>>>> this.base( arguments );
>>>> this.setHtmlAttribute( "id", id );
>>>> this._id = id;
>>>> },
>>>>
>>>> properties : {
>>>> seller_id : {
>>>> init : "",
>>>> apply : "load"
>>>> }
>>>> },
>>>>
>>>> destruct : function() {
>>>>
>>>> },
>>>>
>>>> members : {
>>>>
>>>> _doActivate : function() {
>>>> alert("doActivate!");
>>>> var shell = null;
>>>> var parent = this.getParent();
>>>> while( shell == null && parent != null ) {
>>>> if( parent.classname == "org.eclipse.swt.widgets.Shell" ) {
>>>> shell = parent;
>>>> }
>>>> parent = parent.getParent();
>>>> }
>>>> if( shell != null ) {
>>>> shell.setActiveChild( this );
>>>> }
>>>> },
>>>>
>>>> load : function() {
>>>> alert("seller_id");
>>>> seller_id = "test";
>>>> },
>>>>
>>>> _doResize : function() {
>>>> alert("_doResize called");
>>>> }
>>>> }
>>>> } );
>>>>
>>>> My LCA looks like this:
>>>>
>>>> package org.eclipse.rap.internal.ebay.ebaykit;
>>>>
>>>> import java.io.IOException;
>>>>
>>>> import org.eclipse.rwt.lifecycle.*;
>>>> import org.eclipse.swt.widgets.Control;
>>>> import org.eclipse.swt.widgets.Widget;
>>>>
>>>> import org.eclipse.rap.demo.ebay.EBay;
>>>>
>>>> public class EBayLCA extends AbstractWidgetLCA {
>>>> private static final String JS_PROP_SELLER_ID = "seller_id";
>>>> private static final String PROP_SELLER_ID = "seller_id";
>>>>
>>>> public void preserveValues( final Widget widget ) {
>>>> ControlLCAUtil.preserveValues( ( Control )widget );
>>>> IWidgetAdapter adapter = WidgetUtil.getAdapter( widget );
>>>> adapter.preserve( PROP_SELLER_ID, ( ( EBay )widget
>>>> ).getSeller_id() );
>>>> }
>>>> public void readData( final Widget widget ) {
>>>> }
>>>> public void renderInitialization( final Widget widget )
>>>> throws IOException {
>>>> JSWriter writer = JSWriter.getWriterFor( widget );
>>>> String id = WidgetUtil.getId( widget );
>>>> writer.newWidget( "org.eclipse.rap.demo.ebay.EBay", new
>>>> Object[] { id } );
>>>> writer.set( "appearance", "composite" );
>>>> writer.set( "overflow", "hidden" );
>>>> ControlLCAUtil.writeStyleFlags( (EBay)widget );
>>>> }
>>>>
>>>> public void renderChanges( final Widget widget ) throws
>>>> IOException {
>>>> EBay ebay = ( EBay )widget;
>>>> ControlLCAUtil.writeChanges( ebay );
>>>> JSWriter writer = JSWriter.getWriterFor( widget );
>>>> writer.set( PROP_SELLER_ID, JS_PROP_SELLER_ID,
>>>> ebay.getSeller_id() );
>>>> }
>>>>
>>>> public void renderDispose( final Widget widget ) throws
>>>> IOException {
>>>> JSWriter writer = JSWriter.getWriterFor( widget );
>>>> writer.dispose();
>>>> }
>>>>
>>>> public void createResetHandlerCalls( String typePoolId )
>>>> throws IOException
>>>> {
>>>> // TODO Auto-generated method stub
>>>> }
>>>>
>>>> public String getTypePoolId( Widget widget )
>>>> {
>>>> // TODO Auto-generated method stub
>>>> return null;
>>>> }
>>>> }
>>>>
>>>> I now would imagine that when my ebay object is created, it should
>>>> call the constructor. When I inspect the DOM in my browser, I can
>>>> see my
>>>> org.eclipse.rap.demo.ebay.EBay object.
>>>>
>>>> Greetings
>>>>
>>>>
>>>> Frank Appel schrieb:
>>>>> Hi,
>>>>>
>>>>> could you please add your LCA and the javascript implementation, so
>>>>> that
>>>>> we can see what's going on. It's a little bit difficult without
>>>>> sufficient information to analyse your problem.
>>>>>
>>>>> Ciao
>>>>> Frank
>>>>>
>>>>> -----Ursprüngliche Nachricht-----
>>>>> Von: Markus Joosten [mailto:markus.joosten@plumbe.de]
>>>>> Bereitgestellt: Montag, 31. März 2008 09:29
>>>>> Bereitgestellt in: eclipse.technology.rap
>>>>> Unterhaltung: Custom JavaScript code gets loaded but not executed
>>>>> Betreff: Custom JavaScript code gets loaded but not executed
>>>>>
>>>>>
>>>>> Hello folks,
>>>>>
>>>>> i have created a custom widget with my own JavaScript code based on
>>>>> the
>>>>> GMap demo. I have stripped everything GMap-specific and now when i run
>>>>> my app, i can see in the source code that my JS has been loaded. Using
>>>>> the LCA, I create the corresponding widget via the JSWriter.
>>>>> My JS Code basically contains a qx class with just one property.
>>>>> My constructor just contains an alert statement.
>>>>> I also copied the _doActivate() and _doResize() methods from the GMaps
>>>>> example and removed the GMap-specific stuff.
>>>>>
>>>>> Any Ideas?
>>>>> Any help would be greatly appreciated :)
>>>>>
>>>>> Greets,
>>>>> Markus
>>>>>
Re: Custom JavaScript code gets loaded but not executed [message #80573 is a reply to message #80557] Tue, 01 April 2008 08:49 Go to previous message
Eclipse UserFriend
Originally posted by: rsternberg.innoopract.com

Hi Markus,

nice to hear that you solved your problem. Yes, the LCAs are found by
package and class name convention. If your LCA is not found, the
superclass LCA is looked up. That's what probably happened to you.

But I don't understand how implenting the Adaptable interface should
work around this kind of problem? The Adapter mechanism is only used to
access non-API properties of some widgets.

Best regards,
Ralf

Markus Joosten wrote:
> I got it working.
> The problem was that the LCA wasn't created at all during startup.
> Seemed to be some issue in my package naming conventions.
> In order to avoid such mistakes in future projects, i would like to
> implement the getAdapter(Class adapter) method in my widgets.
> In this case, would this be my EBay() class in the package which also
> holds the resources? How do I then call the getAdapter method? By hand
> or is there some magic involved which calls this method?
>
> Thanks for your help!
>
> Greetings from Frankfurt,
> Markus
>
> Markus Joosten schrieb:
>> Well, i just tried to create the object via Firebug console:
>>
>> new org.eclipse.rap.demo.ebay.EBay()
>>
>> Now i got my alert message, so i can be sure the class definition is
>> correctly loaded.
>> So it seems, that in my LCA the JSWriter does not create the widget on
>> the client-side, am I right? But I can't find a mistake there.
>> The object i found in the DOM would be just the class definition i guess.
>>
>> So what am I missing here?
>>
>> Markus Joosten schrieb:
>>> Hi,
>>>
>>> thanks for verifying my code.
>>> My widget on the client side contains nothing but an empty
>>> constructor with the alert statement and one property. I didn't code
>>> further because I wanted to check the functionality of my code so far :)
>>> The shell of the widget is displayed correctly, but of course it's empty
>>> because I haven't put something in it.
>>>
>>> Greetings,
>>> Markus
>>>
>>> P.S.: How do I create a new instance of my widget with Firebug?
>>>
>>> Ralf Sternberg schrieb:
>>>> Hi Markus,
>>>>
>>>> your code looks good so far. If you work with Firebug you can try to
>>>> create a new instance of your widget in the Firebug console and
>>>> check that the alert is raised.
>>>>
>>>> You said that the widget exists in the DOM tree. Thus, the
>>>> constructor must have been called. What exactly is the problem? Is
>>>> the widget invisible or is it displayed correctly but the alert is
>>>> not brought up?
>>>>
>>>> Ralf
>>>>
>>>> Markus Joosten wrote:
>>>>> My JS Code is just this:
>>>>>
>>>>> qx.Class.define( "org.eclipse.rap.demo.ebay.EBay", {
>>>>> extend: qx.ui.layout.CanvasLayout,
>>>>>
>>>>> construct: function( id ) {
>>>>> alert("constructor");
>>>>> this.base( arguments );
>>>>> this.setHtmlAttribute( "id", id );
>>>>> this._id = id;
>>>>> },
>>>>>
>>>>> properties : {
>>>>> seller_id : {
>>>>> init : "",
>>>>> apply : "load"
>>>>> }
>>>>> },
>>>>>
>>>>> destruct : function() {
>>>>>
>>>>> },
>>>>>
>>>>> members : {
>>>>>
>>>>> _doActivate : function() {
>>>>> alert("doActivate!");
>>>>> var shell = null;
>>>>> var parent = this.getParent();
>>>>> while( shell == null && parent != null ) {
>>>>> if( parent.classname == "org.eclipse.swt.widgets.Shell" ) {
>>>>> shell = parent;
>>>>> }
>>>>> parent = parent.getParent();
>>>>> }
>>>>> if( shell != null ) {
>>>>> shell.setActiveChild( this );
>>>>> }
>>>>> },
>>>>>
>>>>> load : function() {
>>>>> alert("seller_id");
>>>>> seller_id = "test";
>>>>> },
>>>>>
>>>>> _doResize : function() {
>>>>> alert("_doResize called");
>>>>> }
>>>>> }
>>>>> } );
>>>>>
>>>>> My LCA looks like this:
>>>>>
>>>>> package org.eclipse.rap.internal.ebay.ebaykit;
>>>>>
>>>>> import java.io.IOException;
>>>>>
>>>>> import org.eclipse.rwt.lifecycle.*;
>>>>> import org.eclipse.swt.widgets.Control;
>>>>> import org.eclipse.swt.widgets.Widget;
>>>>>
>>>>> import org.eclipse.rap.demo.ebay.EBay;
>>>>>
>>>>> public class EBayLCA extends AbstractWidgetLCA {
>>>>> private static final String JS_PROP_SELLER_ID = "seller_id";
>>>>> private static final String PROP_SELLER_ID = "seller_id";
>>>>>
>>>>> public void preserveValues( final Widget widget ) {
>>>>> ControlLCAUtil.preserveValues( ( Control )widget );
>>>>> IWidgetAdapter adapter = WidgetUtil.getAdapter( widget );
>>>>> adapter.preserve( PROP_SELLER_ID, ( ( EBay )widget
>>>>> ).getSeller_id() );
>>>>> }
>>>>> public void readData( final Widget widget ) {
>>>>> }
>>>>> public void renderInitialization( final Widget widget )
>>>>> throws IOException {
>>>>> JSWriter writer = JSWriter.getWriterFor( widget );
>>>>> String id = WidgetUtil.getId( widget );
>>>>> writer.newWidget( "org.eclipse.rap.demo.ebay.EBay", new
>>>>> Object[] { id } );
>>>>> writer.set( "appearance", "composite" );
>>>>> writer.set( "overflow", "hidden" );
>>>>> ControlLCAUtil.writeStyleFlags( (EBay)widget );
>>>>> }
>>>>>
>>>>> public void renderChanges( final Widget widget ) throws
>>>>> IOException {
>>>>> EBay ebay = ( EBay )widget;
>>>>> ControlLCAUtil.writeChanges( ebay );
>>>>> JSWriter writer = JSWriter.getWriterFor( widget );
>>>>> writer.set( PROP_SELLER_ID, JS_PROP_SELLER_ID,
>>>>> ebay.getSeller_id() );
>>>>> }
>>>>>
>>>>> public void renderDispose( final Widget widget ) throws
>>>>> IOException {
>>>>> JSWriter writer = JSWriter.getWriterFor( widget );
>>>>> writer.dispose();
>>>>> }
>>>>>
>>>>> public void createResetHandlerCalls( String typePoolId )
>>>>> throws IOException
>>>>> {
>>>>> // TODO Auto-generated method stub
>>>>> }
>>>>>
>>>>> public String getTypePoolId( Widget widget )
>>>>> {
>>>>> // TODO Auto-generated method stub
>>>>> return null;
>>>>> }
>>>>> }
>>>>>
>>>>> I now would imagine that when my ebay object is created, it should
>>>>> call the constructor. When I inspect the DOM in my browser, I can
>>>>> see my
>>>>> org.eclipse.rap.demo.ebay.EBay object.
>>>>>
>>>>> Greetings
>>>>>
>>>>>
>>>>> Frank Appel schrieb:
>>>>>> Hi,
>>>>>>
>>>>>> could you please add your LCA and the javascript implementation,
>>>>>> so that
>>>>>> we can see what's going on. It's a little bit difficult without
>>>>>> sufficient information to analyse your problem.
>>>>>>
>>>>>> Ciao
>>>>>> Frank
>>>>>>
>>>>>> -----Ursprüngliche Nachricht-----
>>>>>> Von: Markus Joosten [mailto:markus.joosten@plumbe.de]
>>>>>> Bereitgestellt: Montag, 31. März 2008 09:29
>>>>>> Bereitgestellt in: eclipse.technology.rap
>>>>>> Unterhaltung: Custom JavaScript code gets loaded but not executed
>>>>>> Betreff: Custom JavaScript code gets loaded but not executed
>>>>>>
>>>>>>
>>>>>> Hello folks,
>>>>>>
>>>>>> i have created a custom widget with my own JavaScript code based
>>>>>> on the
>>>>>> GMap demo. I have stripped everything GMap-specific and now when i
>>>>>> run
>>>>>> my app, i can see in the source code that my JS has been loaded.
>>>>>> Using
>>>>>> the LCA, I create the corresponding widget via the JSWriter.
>>>>>> My JS Code basically contains a qx class with just one property.
>>>>>> My constructor just contains an alert statement.
>>>>>> I also copied the _doActivate() and _doResize() methods from the
>>>>>> GMaps
>>>>>> example and removed the GMap-specific stuff.
>>>>>>
>>>>>> Any Ideas?
>>>>>> Any help would be greatly appreciated :)
>>>>>>
>>>>>> Greets,
>>>>>> Markus
>>>>>>
Previous Topic:Redirect user to another page after closing application
Next Topic:Implement Sorter/Comparator with VirtualTable and DeferredContentProvider
Goto Forum:
  


Current Time: Fri Sep 20 01:15:51 GMT 2024

Powered by FUDForum. Page generated in 0.04185 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top