Skip to main content

Appframework: how-to restore session state dynamically?

6 replies [Last post]
kleopatra
Offline
Joined: 2003-06-11

Works fine for everything actually added to the demo app at startup. Problem are that the demo pages themselves are loaded and added only when selected. Any way to restore their state? And if so, how-to?

BTW, in case you have not noticed yet: XProperties (the version in the demos, not sure if I already updated the one in my incubator) now support saving/restoring the collapsed state of task-panes :-)

CU
Jeanette

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
5er_levart
Offline
Joined: 2003-10-28

Use:

Application.getInstance().getContext().getSessionStorage().save(component, filename);

and:

Application.getInstance().getContext().getSessionStorage().restore(component, filename);

By default SingleFrameApplication does this automatically at startup/shutdown for it's main Frame and uses:

mainFrame.getName() + ".session.xml"

as the filename. You'll have to generate unique persistent filenames for each of your "dynamic" components.

Peter

Also note that with SingleFrameApplication the restore() is done when you call SingleFrameApplication.show(frame) (usually from the startup() method). This restores the state for those subcomponents that are present in the Frame at that time. Any components added later in the life of the application are not restored automatically so it is a good practice to remove all "dynamically added" components that were not present at the show() time from the Frame in the Application.shutdown() method before calling super. This will prevent their state to be unnecessarily saved. You will restore/save the state of "dynamically added" components into separate file(s) as you see fit.

Message was edited by: 5er_levart

kleopatra
Offline
Joined: 2003-06-11

Peter,

will try that next time playing with the demos and report back how it goes (probably add some support into SingleXFrameApplication, have to revisit that anyway as never updated its state to a more recent appframework version)

Thanks
Jeanette

martinm1000
Offline
Joined: 2003-06-12

Any way to get to the code of XProperties.java ?

Can't find it under the http svn (and its also slow!) org.jdesktop.swingx.appframework ?

Can't copy and paste from the source code window of the demo !

kleopatra
Offline
Joined: 2003-06-11

that's a trick question, right ? Checkout the swinglabs demo code. Yeah, sounds a good enhancement to support c&p from the source code view - please file an issue in the swinglabs-demos issue tracker.

Good night
Jeanette

martinm1000
Offline
Joined: 2003-06-12

Nice !

So in the demos you have an up-to-date version of XProperties ? Does it support saving the state of [b]JXTables [/b](sorting and filtering and all ?)

I've played with the old version a week ago but decided to wait before trying to make it work with the current code...

kleopatra
Offline
Joined: 2003-06-11

>
> So in the demos you have an up-to-date version of
> XProperties ? Does it support saving the state of
> [b]JXTables [/b](sorting and filtering and all ?)

yeah - but regarding JXTable it had been updated to 1.6 a while ago (in the incubator). One open issue is to store all sortkeys (currently only stores the primary) not a big deal but has to be done. Could miss other parts of "and all :-) Please feel free to contribute or point out what you are missing.

Thanks
Jeanette