I figured out the following: Empty values always lead to the removal of the according property (https://github.com/apache/sling/blob/c9e59667d8f9cd698bc33a51f3e6a22e85d4a952/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java#L265 <https://github.com/apache/sling/blob/c9e59667d8f9cd698bc33a51f3e6a22e85d4a952/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java#L265>). This is unfortunately not documented.
Therefore the @IgnoreBlanks suffix doesn't make any sense for single value properties (http://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html#ignoreblanks <http://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html#ignoreblanks>) Also the handling of the default value :null and :ignore (also not documented) is useless in my regard as empty values and returning null is treated the same (in contrast to what is described in the javadoc) (https://github.com/apache/sling/blob/c9e59667d8f9cd698bc33a51f3e6a22e85d4a952/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/RequestProperty.java#L195 <https://github.com/apache/sling/blob/c9e59667d8f9cd698bc33a51f3e6a22e85d4a952/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/RequestProperty.java#L195>). and would be the same as just setting no default value at all! You can see that in https://github.com/apache/sling/blob/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java#L156 <https://github.com/apache/sling/blob/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java#L156> and https://github.com/apache/sling/blob/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java#L192 <https://github.com/apache/sling/blob/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java#L192> (in any case setPropertyAsIs is called, which will remove properties with null or empty values). Could someone confirm this? Then I would a) Update the documentation in http://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html <http://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html#ignoreblanks> to make clear that empty values lead to removal of properties and to clarify the @IgnoreBlanks suffix From a code perspective the methods RequestProperty.providesValue() and getStringValues() should definitely be clarified, because I at least could not see, that for the former returning true or false makes any difference, nor that getStringValues() distinguishes between null or the empty array. Thanks, Konrad > On 13 Apr 2016, at 19:13, Konrad Windszus <[email protected]> wrote: > > Obviously when the parameter :ignore: is send as parameter for the > SlingPostServlet all properties with empty values are just removed instead of > adding those with empty values. > > Unfortunately that behaviour is neither documented at > https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html > nor could I really find where this is interpreted in the code. The only > place, where :ignore is evaluated is at > https://github.com/apache/sling/blob/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/RequestProperty.java#L195 > (but this would only evaluate the default value). But since this is not set > as default value (with the suffix @DefaultValue) I wonder how and where this > parameter is evaluated. > > Could someone give me hint, so that I can update the documentation > accordingly? > Thanks, > Konrad
