Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » readData() behaviour
readData() behaviour [message #80913] Wed, 02 April 2008 09:38 Go to next message
Mike Wrighton is currently offline Mike WrightonFriend
Messages: 19
Registered: July 2009
Junior Member
Hi,

(Apologies if this has already been covered in a previous post but I
couldn't find anything)

I'm trying to understand the widget lifecycle and in particular the
readData() method. It appears as though this is only called when the
user selects something e.g. I can see it being called only when my
widget goes out of (or into) focus. What I'd like is for my widget to
(for example) periodically send requests to the server, and for
readData() to be called as soon as one of those requests arrives so that
relevant parts of the UI can be updated. Is this possible?

Thanks,
Mike
Re: readData() behaviour [message #80925 is a reply to message #80913] Wed, 02 April 2008 12:16 Go to previous messageGo to next message
Martin Dilger is currently offline Martin DilgerFriend
Messages: 54
Registered: July 2009
Member
Hi ,

the readData()-Method gets called as soon as an event from the client-side
arrives at the server. This Method is used to synchronize client-state to
the server.

I donŽt understand what you mean by "so that relevant parts of the UI can
be updated.", what exactly are you trying to do?

Martin
Re: readData() behaviour [message #80931 is a reply to message #80925] Wed, 02 April 2008 12:30 Go to previous messageGo to next message
Mike Wrighton is currently offline Mike WrightonFriend
Messages: 19
Registered: July 2009
Junior Member
Ok so to explain, I've got a javascript text editor - when a user makes
modifications after a save, a request is sent to the server. I've put a
breakpoint in my readData() method and can see this request arrive, but
it only breaks when I change focus e.g. I have to click on another view
for the request to be received and the editor event to take effect. Hope
that makes sense.


Martin Dilger wrote:
> Hi ,
>
> the readData()-Method gets called as soon as an event from the
> client-side arrives at the server. This Method is used to synchronize
> client-state to the server.
>
> I donŽt understand what you mean by "so that relevant parts of the UI
> can be updated.", what exactly are you trying to do?
>
> Martin
>
Re: readData() behaviour [message #80943 is a reply to message #80931] Wed, 02 April 2008 12:57 Go to previous messageGo to next message
Martin Dilger is currently offline Martin DilgerFriend
Messages: 54
Registered: July 2009
Member
Hi again,

I donŽt really understand, what you are trying to do, the sentence "it
only breaks..." doesnŽt make too much sense to me, but could you try this
inside your createUI()-Method of your EntryPoint:

UICallback.activate(getClass().getName());

Just to make sure this is not the problem, this activates UICallbacks from
Server to Client.

Martin
Re: readData() behaviour [message #80958 is a reply to message #80943] Wed, 02 April 2008 13:06 Go to previous messageGo to next message
Mike Wrighton is currently offline Mike WrightonFriend
Messages: 19
Registered: July 2009
Junior Member
Hi,

What I meant by "it only breaks" is that the breakpoint is only hit when
I change focus. So readData() is only called when I change focus. Yep
I've already got that UICallback code at the start of my createUI() method.

I'm wondering whether I need to do any server-side polling to get this
to work...


Martin wrote:
> Hi again,
> I donŽt really understand, what you are trying to do, the sentence "it
> only breaks..." doesnŽt make too much sense to me, but could you try
> this inside your createUI()-Method of your EntryPoint:
>
> UICallback.activate(getClass().getName());
>
> Just to make sure this is not the problem, this activates UICallbacks
> from Server to Client.
>
> Martin
>
Re: readData() behaviour [message #80972 is a reply to message #80958] Wed, 02 April 2008 13:24 Go to previous messageGo to next message
Martin Dilger is currently offline Martin DilgerFriend
Messages: 54
Registered: July 2009
Member
Ok then, this should work, how did you implement this, could you post some
code?
Re: readData() behaviour [message #80986 is a reply to message #80972] Wed, 02 April 2008 13:46 Go to previous messageGo to next message
Mike Wrighton is currently offline Mike WrightonFriend
Messages: 19
Registered: July 2009
Junior Member
Ok here are a few snippets. The actual editor is inside an html page in
a qx.ui.embed.Iframe. I'm polling the editor code in the html page to
check for the editor_is_dirty flag, then sending a request:


var timer2 = new qx.client.Timer(100);
timer2.addEventListener("interval", function(e) {
if (this.getIframeWindow() && this.getIframeWindow().loaded) {
if(this.getIframeWindow().editor_is_dirty == 1){
this.getIframeWindow().editor_is_dirty = 0;
this.fireDirtyEvent();
}
}
}, this);
timer2.start();


fireDirtyEvent : function() {
var wm = org.eclipse.swt.WidgetManager.getInstance();
var id = wm.findIdByWidget(this);
var req = org.eclipse.swt.Request.getInstance();
req.addParameter(id + ".dirty", "yes");
req.send();
}


My readData method of my LCA:


public void readData( final Widget widget ) {
final GMap map = (GMap) widget;
final String isDirty = WidgetLCAUtil.readPropertyValue(map, "dirty");

if (isDirty != null){
ProcessActionRunner.add(new Runnable(){
public void run() {
map.fireDirtyEvent();
}
});
}


Hope this makes it clearer.

Mike


Martin wrote:
> Ok then, this should work, how did you implement this, could you post
> some code?
>
Re: readData() behaviour [message #81001 is a reply to message #80986] Wed, 02 April 2008 14:52 Go to previous messageGo to next message
Martin Dilger is currently offline Martin DilgerFriend
Messages: 54
Registered: July 2009
Member
Hi,

looks as if this could work, but propably quite implemented strange, I
definitely would not rely on a timer here, but use something like a
modifyListener ...
nonetheless, I cannot tell you whats the problem here, my knowledge in
qooxdoo is too bad, sorry, but someone will definitely find whats wrong.

Bye!
Re: readData() behaviour [message #81031 is a reply to message #80986] Wed, 02 April 2008 17:58 Go to previous message
Eclipse UserFriend
Originally posted by: rherrmann.innoopract.com

Hi Mike,

as others already said;) the readData method is called whenever a
request is sent. There is no condition under which readData is not
called.
As your code looks like it should do what you expect, I can only
give some guesses:
- can you ensure that the request is actually sent?
Write req.debug( "sent" ); before req.snd() and have the
debug window/Firebug open.
- Is your LCA called at all? The LCA's that is responsibe for
a certain class is resolved by a naming convention. Maybe
there is a typo?
- does the client-side widget-id match the one you expect
on the server-side? (use WidgetUtil#getId(Widget) to determine
server-side id)

Cheers,
Rüdiger


Mike Wrighton wrote:
> Ok here are a few snippets. The actual editor is inside an html page in
> a qx.ui.embed.Iframe. I'm polling the editor code in the html page to
> check for the editor_is_dirty flag, then sending a request:
>
>
> var timer2 = new qx.client.Timer(100);
> timer2.addEventListener("interval", function(e) {
> if (this.getIframeWindow() && this.getIframeWindow().loaded) {
> if(this.getIframeWindow().editor_is_dirty == 1){
> this.getIframeWindow().editor_is_dirty = 0;
> this.fireDirtyEvent();
> }
> }
> }, this);
> timer2.start();
>
>
> fireDirtyEvent : function() {
> var wm = org.eclipse.swt.WidgetManager.getInstance();
> var id = wm.findIdByWidget(this);
> var req = org.eclipse.swt.Request.getInstance();
> req.addParameter(id + ".dirty", "yes");
> req.send();
> }
>
>
> My readData method of my LCA:
>
>
> public void readData( final Widget widget ) {
> final GMap map = (GMap) widget;
> final String isDirty = WidgetLCAUtil.readPropertyValue(map, "dirty");
>
> if (isDirty != null){
> ProcessActionRunner.add(new Runnable(){
> public void run() {
> map.fireDirtyEvent();
> }
> });
> }
>
>
> Hope this makes it clearer.
>
> Mike
>
>
> Martin wrote:
>> Ok then, this should work, how did you implement this, could you post
>> some code?
>>
Previous Topic:Deploying war on Tomcat - INSTALLED
Next Topic:Extension point org.eclipse.ui.editorActions missing
Goto Forum:
  


Current Time: Fri Apr 26 15:52:24 GMT 2024

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

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

Back to the top