Hi Line 203 in SlingPropertyValueHandler looks at the values array and checks for a null values array, or a single, 0 length string, if it finds those conditions match then it assumes this is a delete and removes the property. I think that the or portion ought to swap with the else if on line 208, this would mean that if no values are provided the property is deleted, if one is provided that has 1 value of length 0 then clear the property?. For our app we do need to differentiate between provided empty and not provided.
Thanks Jeremy On 16 July 2012 15:42, Carsten Ziegeler <[email protected]> wrote: > Hi, > > the handling of the empty value happens in the Sling Post servlet - > afaik this was a decision in the early days of the post servlet to > treat an empty value like no value. > > The question is, does your app have to distinguish between those two cases? > > When reading values, using the Sling resource api, adapting the > resource to a value map and doing a get(prop_name, "") usually does > the trick for rendering. > > Regards > Carsten > > 2012/7/16 Phillpotts, James <[email protected]>: >> Hi, >> >> The relevant section of the spec would appear to be 10.4.2.4 >> (http://www.day.com/specs/jcr/2.0/10_Writing.html): >> >> <snip> >> Every property must have a value. The range of property states does not >> include having a "null value", or "no value". Setting a property to "null" >> is equivalent to removing that property (see ยง10.9 Removing Nodes and >> Properties). >> </snip> >> >> I wouldn't classify an empty string as either "null value" or "no value" >> myself - unless the type of the property is specified as non-string, in >> which case it would be "no value". >> >> Sounds like a bug to me... >> >> Cheers, >> James >> >> -----Original Message----- >> From: Jeremy Booth [mailto:[email protected]] >> Sent: 16 July 2012 13:48 >> To: [email protected] >> Subject: Empty string property values >> >> Hi >> >> If we setup some initial content to have an empty string as a value it goes >> in to the jcr backend fine, but if we later try to update a value to be an >> empty string the property gets deleted. I see the @deleted suffix can be >> added if delete is the required operation (which we do elsewhere), but in >> this case, we want the value to be present, but blank (empty string). Some >> digging suggests that the block in SlingPropertyValueHandler is making the >> decision that blank string means delete. I can't see anything in the jcr >> specs that suggest a blank string (rather than null) is not valid. Wondering >> if this is a bug, or I've missed something here. >> >> Thanks >> >> Jeremy >> >> -- >> >> Homepage: http://www.computerbooth.com/ >> Codepage: http://www.newdawnsoftware.com/ >> >> >> >> Information in this e-mail and any attachments is confidential, and may not >> be copied or used by anyone other than the addressee, nor disclosed to any >> third party without our permission. There is no intention to create any >> legally binding contract or other binding commitment through the use of this >> electronic communication unless it is issued in accordance with the Experian >> Limited standard terms and conditions of purchase or other express written >> agreement between Experian Limited and the recipient. Although Experian has >> taken reasonable steps to ensure that this communication and any attachments >> are free from computer virus, you are advised to take your own steps to >> ensure that they are actually virus free. >> >> Companies Act information: Registered name: Experian Limited. Registered >> office: Landmark House, Experian Way, NG2 Business Park, Nottingham, NG80 >> 1ZZ, United Kingdom. Place of registration: England and Wales. Registered >> number: 653331 >> > > > > -- > Carsten Ziegeler > [email protected] -- Homepage: http://www.computerbooth.com/ Codepage: http://www.newdawnsoftware.com/
