Problem with Preferences plugin with griffon 2.8.0

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with Preferences plugin with griffon 2.8.0

Scott_Walton
I created a new Griffon 2.8.0 application with lazybones, added the preferences plugin to it, and setup up the model with the following:
    @PreferencesAware
    @ArtifactProviderFor(GriffonModel)
    @ToString(includeFields = true, includeNames = true, includePackage = false)
    class PrefsModel {

        @Preference(defaultValue = "def")
        @Observable String textContents = ""

        @Observable String text2 = ""

        @Preference(defaultValue = "save")
        String savePrefs
}

The first (textContents) is bound to a textfield in the view (mutual: true). The second (savePrefs) is only modified by the controller when a "Copy" button is pressed. The Controller has an "exitButton" which logs the contents of the model. I don't see the contents of the preferences file containing anything other than the default values. Am I missing something here? I've created an issue for this as I think it's a bug.
   By the way, the preferences file is called "default.json" and I don't see a way to change that. I could set the value in configuration for preferences.persistor.location but this requires a directory location with a tree structure like <userHome>/.<application>/.preferences/<name> If the file exists it silently attempts to make a sub-directory. If the file does not exist it fails. It would be very useful to be able to set the both the name and the location (with the location being something like a simple ".") Should I create an Enhancement request?

Scott Walton
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Preferences plugin with griffon 2.8.0

aalmiray
Administrator
Hi Scott,

Do you ever call `PreferencesManager.save()` with the model instance? See http://griffon-plugins.github.io/griffon-preferences-plugin/api/griffon/plugins/preferences/PreferencesManager.html#save-java.lang.Object-

The preferences plugin does not automatically sync back preferences to the store, you must perform this task explicitly.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Preferences plugin with griffon 2.8.0

Scott_Walton
No - I didn't -- that should certainly be mentioned on the plugin documentation page. The implication there is that it's automatic:

"When the application is run for the first the title property will have "Sample" as its value. Preferences will be written to disk when the application is shutdown. Here are the contents of the default.json file (JSON support is enabled if the griffon-preferences-json dependency is added to the classpath)"

I'll try that
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Preferences plugin with griffon 2.8.0

aalmiray
Administrator
Remember the documentation issues was fixed months ago but the docs were not pushed.
Just released version 1.3.0 with a couple of updates besides the new docs.

Cheers,
Andres
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Preferences plugin with griffon 2.8.0

Scott_Walton
Got it! Thank you. That solves the problem. It would be useful to include injecting the PreferencesManager, as useful way to get the reference to do the save.

On Sun, Oct 9, 2016 at 9:27 AM, aalmiray [via griffon-user] <[hidden email]> wrote:
Remember the documentation issues was fixed months ago but the docs were not pushed.
Just released version 1.3.0 with a couple of updates besides the new docs.

Cheers,
Andres


If you reply to this email, your message will be added to the discussion below:
http://griffon-user.74797.x6.nabble.com/Problem-with-Preferences-plugin-with-griffon-2-8-0-tp248p251.html
To unsubscribe from Problem with Preferences plugin with griffon 2.8.0, click here.
NAML



--
Scott Walton