You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Tobias Bocanegra (JIRA)" <ji...@apache.org> on 2009/03/10 22:10:50 UTC

[jira] Commented: (SLING-538) SlingPropertyValueHelper.setPropertyAsIs() handles impossible empty-value-list case

    [ https://issues.apache.org/jira/browse/SLING-538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680619#action_12680619 ] 

Tobias Bocanegra commented on SLING-538:
----------------------------------------

the value handling should work like this:

prop = "foo"
prop@DefaultValue = "xyz"
--> set "foo"

prop = ""
prop@DefaultValue = "xyz"
--> set "xyz"

prop = ""
prop@DefaultValue = ":null"
--> remove

prop = ""
prop@DefaultValue = ":ignore"
--> don't create new values

the use case for the :ignore is the following:
if you have a form (basic html, no dhml or ajax) where you have several input fields that are initially empty,
and you don't want to create all the properties if the user doesn't fill them, then you need the ":ignore", since the
browser sends a value for all fields that are not disabled.
if the properties already have a value, then you want the empty string to clear them (:ignore) or even remove them (:null).

so i guess, this code is correct, but maybe a bit a questionable use case. 



> SlingPropertyValueHelper.setPropertyAsIs() handles impossible empty-value-list case
> -----------------------------------------------------------------------------------
>
>                 Key: SLING-538
>                 URL: https://issues.apache.org/jira/browse/SLING-538
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets Post
>            Reporter: Alexander Klimetschek
>            Assignee: Carsten Ziegeler
>            Priority: Minor
>         Attachments: SLING-538.patch
>
>
> The list of values of the request property can never have the length of null - RequestProperty.getStringValues() ensures this, and it also does not make any sense with form posts, since a request parameter must always have at least one value, otherwise it would simply not exist in the request. So this code is superfluous (also for single-value property handling):
>         } else if (values.length == 0) {
>             // do not create new prop here, but clear existing
>             if (parent.hasProperty(prop.getName())) {
>                 response.onModified(
>                     parent.setProperty(prop.getName(), "").getPath()
>                 );
>             }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.