GUI Persistence
RapidClipse offers the possibility to persist entire views in order to be able to restore them at any time, e.g. after an application or system crash or so that the user finds his individually configured interface again with every login. However, the entire interface is not automatically saved, but only the UI components for which you set the property Properties > GUI Persistence > Persist. All parameters necessary for a later construction of the GUI are automatically read out and combined to a single string, which you then only have to save. Values already entered by the user and selections made can also be persisted by setting Properties > GUI Persistence > Persist > PersistValue. How you save the generated string is up to you, so you can implement any strategy you want, e.g.
-
Database - store the UI information at the user data in the corresponding USER table.
-
Persist 1 view - To persist 1 view, you only need to create 1 more data field VIEW.
-
USER
Data fields
Data type
USERNAME
String
PASSWORD
byte[]
…
…
VIEWNAME
String
VIEWDATA
String
-
-
Persist many views - To persist multiple views, you need another table VIEWS that is linked to the USER table via an n:1 relation.
-
USER
Data fields
Data type
USERNAME
String
PASSWORD
byte[]
…
…
VIEWS_ID
Integer
-
VIEWS
Data fields
Data type
ID
Integer
VIEWNAME
String
VIEWDATA
String
-
-
-
UI Session - The GUI data can be stored globally at the session. As long as the session exists, the interface can be restored.
-
Browser Cookie - The GUI data can be stored as a cookie on the user’s local machine.
Examples:
-
Allow string to be generated with GUI data
String viewData = GuiPersistence.save(this, this.getClass().getName()); //TODO: Persisting viewData into Database
-
Assign GUI data to a view.
//TODO: Loading viewData from database first GuiPersistence.load(this, this.getClass().getName(), viewData);
-
Save GUI data globally in UI session.
UI.getCurrent().getSession().setAttribute("ProductView", viewData);
-
Get GUI data from UI session.
Object attribute = UI.getCurrent().getSession().getAttribute("ProductView"); String viewData = attribute.toString();