> I thought #foreach($Customer in $lstCustomer)
You have no property called "lstCustomer". You put it into the
context as "name":
context.Put("name", lstCustomer);
You'd have to write the template as : #foreach($Customer in $name)
Although what I imagine you really want is:
context.Put("lstCustomer", lstCustomer);
Truth,
James
On Wed, Mar 24, 2010 at 9:26 PM, Jennifer Walters
<[email protected]> wrote:
>>> it looks like you are using it in a more
>>>> standalone way.
> Yes.
>
> There is a single property "name" in the Customer class.
> I filled a LIST called lstCustomer.Add with 3 Customer
>
> I thought #foreach($Customer in $lstCustomer)
> would just output $Customer.name
>
> I haven't gotten to MonoRail yet.
>
>
> On Mar 24, 9:13 pm, Stuart Laughlin <[email protected]> wrote:
>> The way you are using nvelocity here is probably a bit unusual.
>> Typically it is used within a MonoRail web application as the
>> templating engine, but it looks like you are using it in a more
>> standalone way. Is that right?
>>
>> I think your problem is that you are storing lstCustomer in a template
>> variable called 'name' but then in the template you are iterating over
>> $lstCustomer. Instead try something like "#foreach($Customer in
>> $name)".
>>
>> Disclaimer: I've been away from nvelocity for about six months!
>>
>> --Stuart
>>
>> On Wed, Mar 24, 2010 at 7:32 PM, Jennifer Walters
>>
>> <[email protected]> wrote:
>> > I am brand new to Castle (today is my first day). It always produces
>> > "No partners found". I also tried it in an IList (if you want to see
>> > the code). I wish it would at least crash. I have tried everything I
>> > can on the web so can someone point me in the right direction?
>>
>> > I have the following:
>> > List<Customer> lstCustomer = new List<Customer>();
>> > Customer oCustomer1 = new Customer();
>> > oCustomer1.name = "aaaa";
>> > lstCustomer.Add(oCustomer1);
>>
>> > Customer oCustomer2 = new Customer();
>> > oCustomer2.name = "bbbb";
>> > lstCustomer.Add(oCustomer2);
>>
>> > Customer oCustomer3 = new Customer();
>> > oCustomer3.name = "cccc";
>> > lstCustomer.Add(oCustomer3);
>>
>> > VelocityEngine velocity = new VelocityEngine();
>> > ExtendedProperties props = new ExtendedProperties();
>> > props.SetProperty("file.resource.loader.path",
>> > Server.MapPath(".")); // The base path for Templates
>> > velocity.Init(props);
>> > Template template = velocity.GetTemplate(@"testTemplate.vm");
>> > VelocityContext context = new VelocityContext();
>> > context.Put("from", "Jennifer");
>> > context.Put("to", "Our Wholesaler");
>> > context.Put("subject", "Partner request from retailer");
>> > context.Put("name", lstCustomer);
>>
>> > public class Customer
>> > {
>> > public virtual string name { get; set; }
>> > }
>>
>> > The template is:
>> > #foreach($Customer in $lstCustomer)
>> > #beforeall
>> > <table cellpadding="3" cellspacing="0" border="0" width="100%">
>> > <tr>
>> > <th >Name</th>
>> > </tr>
>> > #odd
>> > <tr class="">
>> > #even
>> > <tr>
>> > #each
>> > <td>$Customer.name </td>
>> > #after
>> > </tr>
>> > #afterall
>> > </table>
>> > #nodata
>> > No partners found
>> > #end
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups
>> > "Castle Project Users" group.
>> > To post to this group, send email to [email protected].
>> > To unsubscribe from this group, send email to
>> > [email protected].
>> > For more options, visit this group
>> > athttp://groups.google.com/group/castle-project-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Castle Project Users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/castle-project-users?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.