XdevProgressBar
You can view the progress of a running process with an XdevProgressBar. The progress is specified with the help of a value between 0.0 and 1.0. To view the current progress of a process, you must first determine its complete scope. In many cases, it is sufficient to display a progress wheel, which simply lets the user know that a process of unspecified duration is currently running. This option is easy to implement.
However, if you want to display the progress in real time, want to update further UI components next to XdevProgressBar, or do not want to block the interface during a background process, you must execute the process in a separate, parallel running thread and must update the interface in the browser after each change.
Important events:
valueChange - Is triggered after changes to the content, mainly by adding or deleting characters, however only if the UI component loses the focus.
Important properties:
- Value - Current progress, which must be specified with value between 0.0 and 1.0.
- Indeterminate - Instead of a progress bar, a continuously running progress wheel is displayed. Thus, the current status cannot be identified.
Examples:
Opening a pop-up window for displaying the progress. The pop-up window blocks the entire user interface and closes automatically, as soon as the process closes in the background.
- Create a new ProgressView. Select the XdevGridLayout as an initial layout.
- Change the size of the view to 300 x 200 pixel. For this, click on px in the Toolbox under Width and enter 300, and under Height click on px and enter 200.
- Insert an XdevProgressBar in an empty view.
- Under Caption, enter Please Wait!
Create another view, insert an XdevButton, define a buttonClick event and open the ProgressView view as PopupWindow in it, which closes automatically as soon as the process ends:
Progress wheel during process - Only displays a progress wheel that shows the current progress in the XdevProgressBar.
private void button_buttonClick(Button.ClickEvent event) { Window popup = PopupWindow.For(new ProgressView()).closable(false).draggable(false).resizable(false).modal(true).show(); UI.getCurrent().push(); // Start your process here popup.close(); }
Select XdevProgressBar > Properties > Indeterminate in the ProgressView.
Dynamically update XdevProgressBar - Shows the current progress in the XdevProgressBar. The entire process must run in a separate thread. Since the thread runs on the server and the XdevProgressBar in the browser does not get any information about it, a server push must be executed for every update of the XdevProgressBar through the invoking of getUI().access(()→progressBar.setValue(value)); method.
private void progressBar_attach(ClientConnector.AttachEvent event) { // Find out the lenght of your process in total. The value is 1.0. // Starts a new thread on the serverside Runnable task = ()->{ // Start your process. Find out the current progress and store it in 'value'. Value must be between 0.1 and 1.0. // Server Push to update in the ProgressBar in the Browser getUI().access(()->progressBar.setValue(value)); }; new Thread(new RunnableAccessWrapper(task)).start(); }
XDEV Software Corp. - One Embarcadero Center, San Francisco, CA 94111, US
Copyright © 2015. XDEV Software Corp. All rights reserved.