You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Alexander Klimetschek (JIRA)" <ji...@apache.org> on 2008/06/16 12:21:44 UTC

[jira] Created: (SLING-538) SlingPropertyValueHelper.setPropertyAsIs() handles impossible empty-value-list 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
            Priority: Minor


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.


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

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12605287#action_12605287 ] 

Carsten Ziegeler commented on SLING-538:
----------------------------------------

Looking at the code in the RequestProperty class there is one case where an empty array is returned (line 169), so I think this code is required.

> 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.


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

Posted by "Alexander Klimetschek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12605295#action_12605295 ] 

Alexander Klimetschek commented on SLING-538:
---------------------------------------------

Oh, I missed that one completely! Looks like this is by intention, ie. using "sling:ignore" shall ignore the value.

But IIUC, this will lead to an empty property (values.length == 0 will trigger parent.setProperty(prop.getName(), "") in setPropertyAsIs(). Seems to be a bug.

> 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.


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

Posted by "Alexander Klimetschek (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-538?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexander Klimetschek updated SLING-538:
----------------------------------------

    Attachment: SLING-538.patch

Removes the code in question and adds explaining comments/javadoc.

> 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
>            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.


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

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-538?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carsten Ziegeler reassigned SLING-538:
--------------------------------------

    Assignee: Carsten Ziegeler

> 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.


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

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-538?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carsten Ziegeler closed SLING-538.
----------------------------------

    Resolution: Won't Fix

Thanks Tobi for the information. So, I'll close this bug.

> 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.


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

Posted by "Tobias Bocanegra (JIRA)" <ji...@apache.org>.
    [ 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.