velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Townson <christopher.town...@gmail.com>
Subject Re: Properties that are classes
Date Sun, 09 Oct 2011 12:22:41 GMT
if you have

public class UserData {

    private Address address;

    public Address getAddress() { return address; }

}

public class Address {

    private String line1;

    public String getLine1() { return line1; }

}

In your template ...

$userData.address.line1

or

$userData.getAddress().getLine1()

On 9 October 2011 13:07, Andrew Ducker <andrew@ducker.org.uk> wrote:
> Can I have a sub-class?
>
> i.e.
> in addition to
> $userData.emailAddress
> can I have
> $userData.Address.Line1 ?
>
> Or do I need to completely flatten my object structure for Velocity to cope
> with it?
>
> At the moment I get:
>
> Couldn't instantiate instance of tool for: Unusable Tool 'userdata' =>
> feedthistothat.UserData with 1 properties [key -auto-> userdata;
> ](java.lang.IllegalArgumentException: No class
> 'feedthistothat.DataTypes.FeedParameters' was registered)
>
> if I add a property userData.getFeedParameters to my class
> Do I need to register this class somewhere?  Or is there a best practice to
> deal with this situation?
>
> Thanks,
>
> Andy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Mime
View raw message