Dynamic updating - Comet/Polling, etc. [message #25309] |
Thu, 17 May 2007 13:08  |
Eclipse User |
|
|
|
Originally posted by: kendotlarson.mindspring.com
I am interested in looking in to ways to get my RAP app to do some
dynamic updating. I understand this is a longer-range idea for RAP itself.
I was wondering if anyone had any pointers as to where I could get started.
My first approach was going to just try to hack some things to try and
get something to work. First, I would try to write my own javascript
that would do the equivalent of clicking a button (I would make a
specific button in my UI just for this purpose). This javascript would
initially be called in a polling loop, perhaps from a browser widget.
The button click handler on the server side would run any async
runnables (which would normally be submitted to Display.asyncExec) that
were pending before returning.
Any tips on calling the right function to click a specific button?
Any tips on executing some of my own custom javascript in the browser?
Thanks,
Ken
|
|
|
Re: Dynamic updating - Comet/Polling, etc. [message #25720 is a reply to message #25309] |
Fri, 18 May 2007 02:52  |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
I don't think that you have to use a special button. Below I have added the
content of two files and a plugin.xml snippet to perform a simple polling
every 5 seconds. Note that continues-polling increases your serverload so be
careful using this if you expect a lot of concurrent user sessions.
Depending on the responsiveness needs of your application you may think
about lowering the polling rate.
To use these snippets first create a file
'org.eclipse.rap.showcase.Trigger.js' in a source folder of one of your RAP
dependend plug-ins. Of course you can choose a different name, but don't
forget to adjust the fully qualified names in the file's content. Second
create the TriggerJS.java class adjusted to your needs in the same plug-in.
Third include the extension snippet into the plugin.xml. That's all.
To do something useful at serverside with those requests you can use
PhaseListener. The workbench plug-in itself uses such listeners and you may
have a look at the 'org.eclipse.ui.workbench.preserveWidgetValues' extension
to see how it is done.
Hope that helps!
Ciao
Frank
Content of Trigger.js
qx.OO.defineClass( "org.eclipse.rap.showcase.Trigger" );
org.eclipse.rap.showcase.Trigger.sentTriggerRequest = function() {
org.eclipse.swt.Request.getInstance().send();
};
setInterval( "org.eclipse.rap.showcase.Trigger.sentTriggerRequest();",
5000 );
Content of TriggerJS.java
package org.eclipse.rap.showcase;
import org.eclipse.swt.resources.IResource;
import com.w4t.HTML;
import com.w4t.IResourceManager.RegisterOptions;
public class TriggerJS implements IResource {
public String getCharset() {
return HTML.CHARSET_NAME_ISO_8859_1;
}
public ClassLoader getLoader() {
return this.getClass().getClassLoader();
}
public String getLocation() {
return "org/eclipse/rap/showcase/Trigger.js";
}
public RegisterOptions getOptions() {
return RegisterOptions.VERSION;
}
public boolean isExternal() {
return false;
}
public boolean isJSLibrary() {
return true;
}
}
Registration in plugin.xml:
<extension
point="org.eclipse.rap.ui.workbench.resources">
<resource class="org.eclipse.rap.showcase.TriggerJS"/>
</extension>
"Ken Larson" <kendotlarson@mindspring.com> schrieb im Newsbeitrag
news:f2i1oq$l7e$1@build.eclipse.org...
>I am interested in looking in to ways to get my RAP app to do some dynamic
>updating. I understand this is a longer-range idea for RAP itself.
>
> I was wondering if anyone had any pointers as to where I could get
> started.
>
> My first approach was going to just try to hack some things to try and get
> something to work. First, I would try to write my own javascript that
> would do the equivalent of clicking a button (I would make a specific
> button in my UI just for this purpose). This javascript would initially
> be called in a polling loop, perhaps from a browser widget.
>
> The button click handler on the server side would run any async runnables
> (which would normally be submitted to Display.asyncExec) that were pending
> before returning.
>
> Any tips on calling the right function to click a specific button?
>
> Any tips on executing some of my own custom javascript in the browser?
>
> Thanks,
>
> Ken
|
|
|
Powered by
FUDForum. Page generated in 0.02013 seconds