You can use this:
public void refreshTable() {
Timer t = new Timer() {
public void run() {
//Retrieve Data
//Refresh table
refreshTable();
}
};
// Schedule the timer to run once in 5 minutes.
t.schedule(300000);
}
This essentially this creates a recursive loop, that will halt for 5
minutes every time it starts a loop cycle.
This will not hang your single treated Javascript like your earlier
approach.
On Jul 15, 2:41 am, Irving Ruan <[email protected]> wrote:
> Hi all,
>
> So I understand that onModuleLoad() method in the class that
> implements EntryPoint is the method that basically initiates the GWT
> web app. On this web app, I have some headers and metadata info, such
> as the main title. However, I have a Table which dynamically pulls in
> data from a local SQL DB. While I am able to successfully read from
> the DB and display the data, I want the table to automatically reload
> ever 5 minutes, which in return, refreshes the view if the DB changes
> info.
>
> I tried implementing a sleep timer function within the onModuleLoad()
> within an infinite while loop but that does not work and the page
> never completely loads because onModuleLoad() needs to finish being
> called before the view gets loaded. Any ideas on how to implement an
> automatic table or page refresher ever X minutes?
>
> Here's the code in my onModuleLoad() function:
>
> public void onModuleLoad() {
>
> // Set alignment and size
> DockPanel mainPanel = new DockPanel();
> mainPanel.setSize("100%", "100%");
> mainPanel.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE);
> mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
>
> final AppTableView tableView = new AppTableView();
> final AppFrameView frameView = new AppFrameView();
>
> // Add view modules to the page
> mainPanel.add(appFrameView, DockPanel.NORTH);
> mainPanel.add(appTableView, DockPanel.CENTER);
>
> RootPanel.get().add(mainPanel);
>
> while (true)
> {
>
> // This method pulls in data from the SQL db
> and displays it
> tableView.draw();
>
> timer(500);
> }
> }
>
> The tableView.draw() method is the one that pulls in data from the SQL
> DB and displays it.
>
> Thanks in advance,
> -I.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.