Stripes

Indexed properties fail to be set to null or empty (DefaultActionBeanPropertyBinder problem)

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: Release 1.4
  • Fix Version/s: None
  • Component/s: Validation
  • Labels:
    None
  • Environment:
    Windows, Java 1.5, Tomcat 6

Description

Hi,

When using indexed properties in the JSP, these cannot be set to empty as this is ignored and no binding to the property.

The problem points to the following class DefaultActionBeanPropertyBinder.validateRequiredFields(...). This method removes any indexed properties where value is set to null or empty. Therefore the resulting binding to the property never occurs and the value is unaffected.

Thanks
Shaf.

Activity

Hide
Frederic Daoud added a comment - 28/May/08 7:57 AM

I'm pretty sure that this is the expected behavior. The idea with indexed properties is that if you have rows of fields, any row that is completely empty is ignored.
See http://www.stripesframework.org/display/stripes/Indexed+Properties under 'Validation of Indexed Properties' for a more detailed explanation.

Show
Frederic Daoud added a comment - 28/May/08 7:57 AM I'm pretty sure that this is the expected behavior. The idea with indexed properties is that if you have rows of fields, any row that is completely empty is ignored. See http://www.stripesframework.org/display/stripes/Indexed+Properties under 'Validation of Indexed Properties' for a more detailed explanation.
Hide
Mohammed Shafiq added a comment - 28/May/08 8:21 AM

Hi Frederic,

Thanks for your reply.

I have read the above link and understand why the validation behaves in the manner it does but the issue is with the binding of the properties.

If all the values of the row are empty then no binding of the properties takes place. This means that the values can never be blank.

Take the example with a List of Person objects.

List<Person> persons;

Person{
name: String;
age: String;
}

If I wanted to blank one item in the list i.e. set name to "" and age to "", stripes will remove these parameters from the list before the binding. This neans this item in the list is never touched and the values remain as originally set.

Show
Mohammed Shafiq added a comment - 28/May/08 8:21 AM Hi Frederic, Thanks for your reply. I have read the above link and understand why the validation behaves in the manner it does but the issue is with the binding of the properties. If all the values of the row are empty then no binding of the properties takes place. This means that the values can never be blank. Take the example with a List of Person objects. List<Person> persons; Person{ name: String; age: String; } If I wanted to blank one item in the list i.e. set name to "" and age to "", stripes will remove these parameters from the list before the binding. This neans this item in the list is never touched and the values remain as originally set.
Hide
Frederic Daoud added a comment - 28/May/08 8:37 AM

Hi Shaf,
Thanks for the example, I understand your use case better now. I think this may indirectly be related to STS-303.

Show
Frederic Daoud added a comment - 28/May/08 8:37 AM Hi Shaf, Thanks for the example, I understand your use case better now. I think this may indirectly be related to STS-303.
Hide
Mohammed Shafiq added a comment - 28/May/08 9:00 AM

Thanks Frederic,

Looking at STS-303 I believe the problem is related but I do not think the fix proposed will also solve this problem. This issue occurs after STS-303. I may be wrong.

Would you classify this as a separate bug?

Thanks for you help.

Show
Mohammed Shafiq added a comment - 28/May/08 9:00 AM Thanks Frederic, Looking at STS-303 I believe the problem is related but I do not think the fix proposed will also solve this problem. This issue occurs after STS-303. I may be wrong. Would you classify this as a separate bug? Thanks for you help.
Hide
John Newman added a comment - 28/May/08 10:24 AM

I think this is the same thing as STS-476

My users have complained about this as well. I understand why stripes does what it does, and apart from this case where you want to remove an item by blanking it out, I think it is the correct behavior. But maybe it isn't correct, or it should be configurable application wide or field specific. This is something we should discuss.

It is weird when you do what Mohammed is describing, only to come back to the page and see that the old values are still there. What I currently have done is added a little trash can icon next to the indexed items to fire an ajax event to remove them. This might be what we are supposed to do to remove items - should we expect "" and "" to mean delete it? But if not shouldn't the empty string at least replace whatever was stored there before?

A lot to talk about here, I'm not sure if this is a bug or if it is indeed a feature.

Show
John Newman added a comment - 28/May/08 10:24 AM I think this is the same thing as STS-476 My users have complained about this as well. I understand why stripes does what it does, and apart from this case where you want to remove an item by blanking it out, I think it is the correct behavior. But maybe it isn't correct, or it should be configurable application wide or field specific. This is something we should discuss. It is weird when you do what Mohammed is describing, only to come back to the page and see that the old values are still there. What I currently have done is added a little trash can icon next to the indexed items to fire an ajax event to remove them. This might be what we are supposed to do to remove items - should we expect "" and "" to mean delete it? But if not shouldn't the empty string at least replace whatever was stored there before? A lot to talk about here, I'm not sure if this is a bug or if it is indeed a feature.

People

Vote (2)
Watch (1)

Dates

  • Created:
    28/May/08 3:32 AM
    Updated:
    28/May/08 10:24 AM