Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Sapphire » DefaultValue not written in resource
DefaultValue not written in resource [message #1114998] Mon, 23 September 2013 14:13 Go to next message
Peter Benedikovič is currently offline Peter BenedikovičFriend
Messages: 8
Registered: September 2013
Junior Member
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 #1115014 is a reply to message #1114998] Mon, 23 September 2013 14:27 Go to previous messageGo to next message
Greg Amerson is currently offline Greg AmersonFriend
Messages: 119
Registered: March 2010
Senior Member
Which version of sapphire are you using? I know that on 0.7.x you can/should do:
model.getName().content( true )
Re: DefaultValue not written in resource [message #1115057 is a reply to message #1115014] Mon, 23 September 2013 15:44 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
The default value is not intended to be stored. It is intended to provide value for when the stored value is null. It sounds like you need @InitialValue. Can you describe what you've tried with @InitialValue?
Re: DefaultValue not written in resource [message #1121328 is a reply to message #1115057] Mon, 30 September 2013 14:00 Go to previous messageGo to next message
Peter Benedikovič is currently offline Peter BenedikovičFriend
Messages: 8
Registered: September 2013
Junior Member
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 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
@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 Go to previous message
Peter Benedikovič is currently offline Peter BenedikovičFriend
Messages: 8
Registered: September 2013
Junior Member
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()).
Previous Topic:Sapphire 0.7 delayed
Next Topic:Respond to carriage return in text box
Goto Forum:
  


Current Time: Thu Mar 28 12:11:35 GMT 2024

Powered by FUDForum. Page generated in 0.04775 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top