Stripes

JavaScriptResolution ignores properties with null values

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: Release 1.5
  • Fix Version/s: Release 1.5.1, Release 1.6
  • Component/s: None
  • Labels:
    None
  • Environment:
    Windows XP, Eclipse Ganymede, Java 1.6, Tomcat, Firefox

Description

JavaScriptResolution skips null valued properties. So if you try to access those properties in javascript you get an error.

For example, if I have an Address object:

public class Address() {
private String street1 = "123 Main Street";
private String street2 = null;

// getters/setters, etc...
}

Then in javascript, after retrieving an Address object:

alert(address.street1) properly displays "123 Main Street"

whereas

alert(address.street2) results in the error, "address.street2 is undefined."

P.S...

Stripes is great. I'm migrating away from XWork/WebWork/Velocity and Stripes is way, way, way better.

Thanks.
David F.

Activity

Hide
Frederic Daoud added a comment - 14/Oct/08 8:34 PM

This would be a one-liner to fix:
var _sj_root_1119058671;
var _sj_28708894 = {street1:"123 Main Street", street2:null};
_sj_root_1119058671 = _sj_28708894;
_sj_root_1119058671;

Show
Frederic Daoud added a comment - 14/Oct/08 8:34 PM This would be a one-liner to fix: var _sj_root_1119058671; var _sj_28708894 = {street1:"123 Main Street", street2:null}; _sj_root_1119058671 = _sj_28708894; _sj_root_1119058671;
Hide
Frederic Daoud added a comment - 14/Oct/08 8:36 PM

Sorry, hit submit by mistake and I can't edit the previous comment.

This would be a one-liner to fix:

Index: stripes/src/net/sourceforge/stripes/ajax/JavaScriptBuilder.java
===================================================================
— stripes/src/net/sourceforge/stripes/ajax/JavaScriptBuilder.java (revision 974)
+++ stripes/src/net/sourceforge/stripes/ajax/JavaScriptBuilder.java (working copy)
@@ -399,7 +399,7 @@
if ((readMethod != null) && !this.excludeProperties.contains(fullPropertyName)) {
Object value = property.getReadMethod().invoke(in);

  • if (isExcludedType(property.getPropertyType()) || value == null) {
    + if (isExcludedType(property.getPropertyType())) { continue; }

And would produce the output as in the example from my previous comment.

However, would this break existing applications? Do applications rely on the non-presence of properties that are null in the JavaScriptResolution, as opposed to their presence with a value of null?

Show
Frederic Daoud added a comment - 14/Oct/08 8:36 PM Sorry, hit submit by mistake and I can't edit the previous comment. This would be a one-liner to fix: Index: stripes/src/net/sourceforge/stripes/ajax/JavaScriptBuilder.java =================================================================== — stripes/src/net/sourceforge/stripes/ajax/JavaScriptBuilder.java (revision 974) +++ stripes/src/net/sourceforge/stripes/ajax/JavaScriptBuilder.java (working copy) @@ -399,7 +399,7 @@ if ((readMethod != null) && !this.excludeProperties.contains(fullPropertyName)) { Object value = property.getReadMethod().invoke(in);
  • if (isExcludedType(property.getPropertyType()) || value == null) { + if (isExcludedType(property.getPropertyType())) { continue; }
And would produce the output as in the example from my previous comment. However, would this break existing applications? Do applications rely on the non-presence of properties that are null in the JavaScriptResolution, as opposed to their presence with a value of null?
Hide
Frederic Daoud added a comment - 20/Oct/08 7:38 PM

Fixed in builds 979 and 980. JavaScriptBuilder now more accurately describes an object by including properties with a value of null instead of omitting the property altogether.

Show
Frederic Daoud added a comment - 20/Oct/08 7:38 PM Fixed in builds 979 and 980. JavaScriptBuilder now more accurately describes an object by including properties with a value of null instead of omitting the property altogether.

People

Vote (0)
Watch (1)

Dates

  • Created:
    12/Sep/08 3:34 PM
    Updated:
    04/Jan/11 2:58 PM
    Resolved:
    20/Oct/08 7:38 PM