A while ago I created a dashboard widget to help people accessing the admin side of Ceros. It saves a lot of time with remember user credentials, and acts as a master key for accessing restricted areas.

One thing that was causing a bit of a problem was saving preferences (passwords) when the users restarted their machine, or logged out. This caused the user to re-enter their password every time, making it a lot less useful.

I tried searching Google for ways to save data from dashboard widgets, write data to a dashboard widget database, store data in dashboard widgets etc with no joy. I flirted with the idea of writing to a database on a web server, although this seemed a bit of an overkill for a few settings.

Eventually I discovered that you can set preferences via the widget class, which the dashboard framework then saves for you (probably in an unsecured way) for access at a later point.

Essentially you use the function:

widget.setPreferenceForKey("Goodbye, World!","worldString");

And then get the data back like so:

var worldString = widget.preferenceForKey("worldString");

More info on saving preferences can be found here.

This entry was posted on Thursday, July 3rd, 2008 at 12:10 pm and is filed under Random. You can leave a comment and follow any responses to this entry through the RSS 2.0 feed.

Leave a Reply