Skip to content

Problem mapping to nested command objects #7

@marcoscarceles

Description

@marcoscarceles

Hi,

I'm migrating a shopping cart checkout to use the webflow plugin. The former implementation used to perform validation of the order's delivery address using a custom UserDetailsCommand object which included a AddressCommand address property, as shown below:

@Validateable
class UserDetailsCommand implements Serializable {

    String firstName
    String lastName
    AddressCommand deliveryAddress
    ...

    static constraints = {
        firstName nullable: false, blank: false, size: 1..50
        lastName nullable: false, blank: false, size: 1..50
        deliveryAddress cascade:true
        ...
    }
    ...
}

@Validateable
class AddressCommand implements Serializable {
    String address1
    String address2
    String city
    String county
    String postcode

    static constraints = {
        address1 blank:false, size: 1..50
        address2 blank:false, size: 1..50
        city blank:false, size: 1..50
        county  blank:false, size: 1..50
        postcode blank:false, matches: /[A-Za-z]{1,2}[0-9Rr][0-9A-Za-z]?\s?[0-9][ABD-HJLNP-UW-Zabd-hjlnp-uw-z]{2}/
    }
}

After migrating to use the webflow plugin I realised that the address field on the UserDetailsCommand was always coming as null on my transitions and actions, failing therefore validation (in an incorrect way) even though the parameters names seemed to be correct (eg. ["firstName:"David", "deliveryAddress.address1": "10 Downing Street"]).

My webflow now looks something like:

class CartController { 
    def checkoutFlow = {
        startCheckout {
            action {
                ...
            }
            on("success").to "deliveryDetails"
        }
        deliveryDetails {
            on("proceed") { UserDetailsCommand userDetailsCommand ->
                ...
            }
        }
        ...
    }
    ...
}

I believe this set up is correct and there's an issue on the plugin's data binding. If not, could you please provide indications on what I'm doing wrong?

Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions