PropertiesComponent not persisting?

Answered

Hi,

i just want to store some small data in my plugin. I expected that when i run 1 action which saves data like this:

PropertiesComponent.getInstance().setValue("a", "testvalue");

and i run another action which reads this data with this code:

PropertiesComponent.getInstance().getValue("a");

That i get the values, but its always null.

The interesting thing is that when i do this in the storing action:

PropertiesComponent.getInstance().setValue("a", "testvalue");
PropertiesComponent.getInstance().getValue("a");

The value is as expected.

So somehow the data is not persisted anywhere, but onyl in "memory" of the action... what is wrong?

 

2 comments
Comment actions Permalink

Hi,

It should work as you expect. Please make sure you use exactly the same keys (not typos) in setting and getting values.

If the problem still exists, please provide more details about actions, context, etc. The plugin source code and test project would be perfect if possible.

0
Comment actions Permalink

Okay i finally figured this out. 

The problem is the api, which works in a non intuitive way:

setValue("a", false); //this is not setting the value to "false", but UNSETS it
getValue("a", true); //since "a" doesnt exist, default value will be true

The correct way to use this api is:

setValue("a", false);
getValue("a", false); 
0

Please sign in to leave a comment.