Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Auto refresh page
Auto refresh page [message #994891] Fri, 28 December 2012 15:23 Go to next message
Li Hao is currently offline Li HaoFriend
Messages: 28
Registered: August 2011
Junior Member
Is there any way to auto refresh a table page periodically?

For RAP client, I may be able to add a auto refresh meta header in the page itself so that it will auto refresh, but for swing or swt client what are the possible way to do this?

Re: Auto refresh page [message #994912 is a reply to message #994891] Fri, 28 December 2012 16:13 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 43
Registered: November 2010
Member
This depends on what you want to achieve. There are basically two ways, the client can take actions "on its own":

  • Notification: If you want the client to take some action when a certain event happens on the server, use a "client notification". See here and here for more information.
  • Polling: If you want to simlate "periodically pressing F5" (e.g. to visually monitor some data), create and start your own client job. If that job is asynchronous (i.e. extends ClientAsyncJob) it is run as a background and is not visible to the user. When you want to change something in the Scout model (e.g. replacing all rows in a table), you have to get synchronous again. Here is a quick example:

    ...
    // (add this code somewhere in the initialization part of your page)
    new ClientAsyncJob("my async background job", ClientSession.get()) {
      @Override
      protected void runVoid(IProgressMonitor monitor) throws Throwable {
        while (!stopCondition) {
          // (***1***) Do some background work here, or just Thread.sleep(...)
          new ClientSyncJob("synchronize with Scout model thread", ClientSession.get()) {
            @Override
            protected void runVoid(IProgressMonitor monitor) throws Throwable {
              // (***2***) update Scout model, e.g. myPage.reload();
            }
          }.schedule();
        }
      }
    }.schedule();
    ...
    


    This pattern might look slightly confusing, but is actually quite common. Code at location ***1*** is executed in the background and may take long, while code ***2*** is executed in the foreground (visible to the user) and should not take too long (because other user actions have to wait until it's done).

Does that already help you?
Re: Auto refresh page [message #994936 is a reply to message #994912] Fri, 28 December 2012 17:18 Go to previous message
Li Hao is currently offline Li HaoFriend
Messages: 28
Registered: August 2011
Junior Member
I think for my case, polling looks like a good solution, I will give it a try.
Previous Topic:"Crowdwriting" the Eclipse Scout Book (Feedback Thread)
Next Topic:P/Users, does not match outer scope rule
Goto Forum:
  


Current Time: Wed Nov 26 05:52:06 GMT 2014

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

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