Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » updating table from server push in RAP
updating table from server push in RAP [message #116983] Mon, 22 December 2008 21:59 Go to next message
Tom H is currently offline Tom HFriend
Messages: 139
Registered: July 2009
Senior Member
I noted this article;
http://www.devx.com/webdev/Article/36101/1954

and some discussion of server push in this thread;
http://dev.eclipse.org/newslists/news.eclipse.technology.rap /msg01751.html

but I couldn't make any sense of it. Is there a code example of using a
server side push to update a widget somewhere that I can take a look at?

Many Thanks,

Tom
Re: updating table from server push in RAP [message #117031 is a reply to message #116983] Tue, 23 December 2008 10:53 Go to previous messageGo to next message
Tom H is currently offline Tom HFriend
Messages: 139
Registered: July 2009
Senior Member
Ah, it's all a lot simpler than it seems at first glance;

so with a call from somewhere in the UI I can start a server push;

public void widgetSelected(SelectionEvent e) {
System.out.println("Starting UICallback");
UICallBack.activate("notifierId");
PlatformUI.createDisplay().asyncExec(runnable);
UICallBack.deactivate("notifierId");
}

and the runnable can just do anything;
final Runnable runnable = new Runnable(){
public void run(){

//if(Event.waitFor()){
System.out.println("executing Runnable");
// MessageDialog.openInformation( parent.getShell(),
// "Treeviewer", "You selected " );
List buffer = new ArrayList();

Random generator = new Random();
int myInt = generator.nextInt(100);

for (int i = 0; i < ROWS; i++) {
String[] row = new String[COLUMNS];
row[0] = securities[i];
for (int j = 1; j < COLUMNS; j++) {
row[j] = String.valueOf(generator.nextInt(100));
}
buffer.add(row);
viewer.replace(row,i);
}
}
};


so my runnable can sit and wait for updates to the table, and do "replace"
as necessary... Is this the right way to do it?

(I am trying to implement a stock table that is updated via push, like in
this example from lightstreamer with their version of AJAX widgets;
http://app.lightstreamer.com/StockListDemoAdv/


Cheers,

T.
Re: updating table from server push in RAP [message #126808 is a reply to message #116983] Wed, 01 April 2009 20:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ben.fern.yahoo.com

Tom H wrote:


> I noted this article;
> http://www.devx.com/webdev/Article/36101/1954

> and some discussion of server push in this thread;
> http://dev.eclipse.org/newslists/news.eclipse.technology.rap /msg01751.html

> but I couldn't make any sense of it. Is there a code example of using a
> server side push to update a widget somewhere that I can take a look at?

> Many Thanks,

> Tom

Hi,

I'm also interested in something like that but I don't really get it.
Have you find what you were looking for?
If yes, could you share it please?

Thank you.
Re: updating table from server push in RAP [message #126820 is a reply to message #126808] Wed, 01 April 2009 20:54 Go to previous messageGo to next message
Austin Riddle is currently offline Austin RiddleFriend
Messages: 128
Registered: July 2009
Senior Member
Hi Tom,

Without understanding your situation, here are two considerations to keep
in mind for "pushing" information from the server:

1. The only normal way that something can get back to the client-side is
through the request life-cycle.

2. You must have a reference to the Display that belongs to the client you
are trying to "push" something to.

The idea of "pushing" something to the clients is sort of a misnomer,
since the request life-cycle only occurs when the user does something, or
while you have a UI callback active. We have a dirty little trick in our
app that actually embeds a heartbeat (a little javascript that will
initiate the life-cycle at an interval) because we found that the
UICallback mechanism was not adequate in our situation. With any of these
means you can push information to a display from application scope.

Now, in terms of updating clients, another dirty trick is to register
listeners from session scope on the data you are interested in as OSGi
services. Then when the data is changed, all of the listeners will be
notified. If those listeners have a reference to the display for that
client then the UI can be updated. Just make sure that when your app is
disposed, that those listeners are unregistered.

There are some issues with this approach (I am sure the RAP guys are
rolling their eyes right now) :). But it is perfectly viable in certain
circumstances.

Anyway, hope this helps.
Re: updating table from server push in RAP [message #126833 is a reply to message #126808] Thu, 02 April 2009 01:44 Go to previous messageGo to next message
Cho HyunJong is currently offline Cho HyunJongFriend
Messages: 105
Registered: July 2009
Location: korea
Senior Member

Hi.

First step.

1. You make TableViewer.
....
tableViewer = new TableViewer(container, SWT.BORDER);
// data define
tableViewer.setContentProvider(new ShowErrorContentProvider());
tableViewer.setInput(getViewSite());

// table refresh
UICallBack.activate(ShowErrorViewer.ID);
Thread notifierThread = new Thread(createRunnable(tableViewer));
notifierThread.setDaemon(true);
notifierThread.setName("ShowErrorViewer notifier");
notifierThread.start();
.....

@Override
public void dispose() {
// call back thread stop code
ControlStatus.getInstance().setSHOWERROR_VIEWER_THREAD(false );
super.dispose();
}

// runnable define
private Runnable createRunnable(final TableViewer tableViewer) {
return new Runnable() {
public void run() {
.........
// Table refresh code. refresh code is called the
ShowErrorContentProvider#getElements()
tableViewer.refresh();
.....

// refresh term code is Thread.sleep()
Thread.sleep(
ControlStatus.getInstance().getRefershSecode() * 1000 );
...

2. ContentProvider define.
public class ShowErrorContentProvider implements
IStructuredContentProvider {
..........
/**
* ControlStatus thread is get latest of the data.
*/
public Object[] getElements(Object inputElement) {
ControlStatus status = ControlStatus.getInstance();
return status.getStatusList();
}
.........

3. server push data define. DB or Socket code define there.
public class ControlStatus extends Thread {
public void run() {
... server push data there
...
}

// The latest of the data
public Object[] getStatusList() {
return (agentDAO.toArray()).clone();
}

End.
Re: updating table from server push in RAP [message #126912 is a reply to message #126833] Thu, 02 April 2009 18:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ben.fern.yahoo.com

Thank you 2 for your help and advices!
Re: updating table from server push in RAP [message #127026 is a reply to message #126912] Fri, 03 April 2009 09:10 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
Ben,

are you aware of the Jobs API? Without understanding your situation,
I would recommend it for common use cases (a background thread needs
to update the UI)

Cheers,
Rüdiger


Ben wrote:
> Thank you 2 for your help and advices!
>
>
>
Re: updating table from server push in RAP [message #127201 is a reply to message #127026] Sat, 04 April 2009 14:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ben.fern.yahoo.com

Hello,

In fact I'd like to update a view's tableviewer of all others users that
have the same view displayed in their browser.

In fact, I have a view (Tableview) which has a tableviewer (filled with
object from a database). In this tableviewer, I have modify and delete
actions.
So when USER1 (for example) uses these actions, I'd like to update
automatically USER2's Tableview as a consequence.
I though to use server push for make that work.

Perhaps I should open a new entry in this newsgroup.
Re: updating table from server push in RAP [message #127236 is a reply to message #127201] Sun, 05 April 2009 16:35 Go to previous message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
Ben wrote:
> Hello,
>
> In fact I'd like to update a view's tableviewer of all others users that
> have the same view displayed in their browser.
>
> In fact, I have a view (Tableview) which has a tableviewer (filled with
> object from a database). In this tableviewer, I have modify and delete
> actions.
> So when USER1 (for example) uses these actions, I'd like to update
> automatically USER2's Tableview as a consequence.
> I though to use server push for make that work.
>
> Perhaps I should open a new entry in this newsgroup.
Sounds like a good idea...

>
>
Previous Topic:TreeViewer not expanding, and Tree widget
Next Topic:why swt classes in the RAP demo examples?
Goto Forum:
  


Current Time: Sun Jan 29 12:39:00 GMT 2023

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

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

Back to the top