DefaultValue not written in resource [message #1114998] |
Mon, 23 September 2013 14:13  |
Eclipse User |
|
|
|
I am using Sapphire to implement wizard for server adapter. I have specified @DefaultValue annotation on my model which has value binding to IServerWorkingCopy resource. After wizard is shown, I can see default value in grey letters but after I click Finish (and calling IServerWorkingCopy.save) the default value is not stored. I have expected that the annotation will initialise the resource attribute with default value. Or do I have to the initialisation programatically (e.g. resource.setName(model.getName.getDefaultContent))). I have also tried @InitialValue annotation.
|
|
|
|
|
Re: DefaultValue not written in resource [message #1121328 is a reply to message #1115057] |
Mon, 30 September 2013 14:00   |
Eclipse User |
|
|
|
I'll try:). So for server admin name property, I used @InitialValue(text = "admin"). After the model is instantiated from the resource and it is shown on wizard page, the admin field is empty. The read call from ValuePropertyBinding return (String)null.
There is tooltip that enables me to restore initial value to admin, which works. This triggers ValuePropertyBinding.write and read calls that refreshes the field value. For the admin name, I am using also @Required annotation if this information helps you.
|
|
|
Re: DefaultValue not written in resource [message #1121459 is a reply to message #1121328] |
Mon, 30 September 2013 16:43   |
Eclipse User |
|
|
|
@InitialValue takes effect when the element is considered to be new. When loading from a resource, the element is not new, so initial value is not written. Framework assumes that the value has been explicitly erased.
Why is it important to write the value to the resource? If you always use the model for accessing the resource, then you can use @DefaultValue and it wouldn't matter that the value was never written to the resource.
|
|
|
Re: DefaultValue not written in resource [message #1123488 is a reply to message #1121459] |
Wed, 02 October 2013 16:14  |
Eclipse User |
|
|
|
Yes, that is the issue. Some parts of plugin are still working with resource directly and I want to have all the necessary values stored when the wizard is finished. I have solved it by manual initialization of model values - e.g. model.setProperty(model.getProperty().content()).
|
|
|
Powered by
FUDForum. Page generated in 0.02650 seconds