Re: Empty string property values

2012-07-19 Thread Alexander Klimetschek
On 16.07.2012, at 17:07, Jeremy Booth wrote:
 For our app we do need to
 differentiate between provided empty and not provided.

I can imagine that this makes sense sometimes (albeit I haven't come across 
this yet).

 On 16 July 2012 15:42, Carsten Ziegeler cziege...@apache.org wrote:
 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.

Yes, that was always in the code (I remember refactoring that once for the 
@Patch feature). It's clearly commented, albeit the initial reasoning seems 
lost:

// if no value is present or a single empty string is given,
// just remove the existing property (if any)
removeProperty(parent, prop);

 However, the sling post servlet docs say something different:

http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html#ManipulatingContent-TheSlingPostServlet%28servlets.post%29-%7B%7B@IgnoreBlanks%7D%7D

The 2nd example in that section:

form method=POST action=/content/page/first enctype=multipart/form-data
input type=hidden name=stringProperty@TypeHint value=String/
input type=text name=stringProperty value=/
/form

This will _not_ result in an empty property, but in no property at all (just 
tested it).

Without knowing the original reasoning for  == null, I would say the sling 
post servlet documentation is king and this is a bug :-)

But one needs to be careful here, as there are so many options involved: 
single- vs. multi-value properties, @IgnoreBlanks, @DefaultValue = :null, 
@DefaultValue = :ignore ... (see also RequestPropertyTest).

Cheers,
Alex



Empty string property values

2012-07-16 Thread Jeremy Booth
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/


RE: Empty string property values

2012-07-16 Thread Phillpotts, James
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:jer...@computerbooth.com] 
Sent: 16 July 2012 13:48
To: users@sling.apache.org
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



Re: Empty string property values

2012-07-16 Thread Carsten Ziegeler
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 james.phillpo...@experian.com:
 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:jer...@computerbooth.com]
 Sent: 16 July 2012 13:48
 To: users@sling.apache.org
 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
cziege...@apache.org