You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Thomas Fahrmeyer <th...@einsurance.de> on 2001/05/23 15:00:52 UTC

Indexed properties problem

Hi,

little problem with indexed properties ?

I want to write
	data.person(0).name

to get the 0-th Person object stored in an ArrayList in "data". Person has
the attribute name (with set/getter)
If I set up "data" with a person object the name is not displayed but if I
write

	data.getPerson(0).name

it works. That's a inconsistent behaviour, isn't it ?

I'm using Vel release 1.0.1

Thanx.

bye
Thomas




Re: Indexed properties problem

Posted by Jason van Zyl <jv...@apache.org>.
Thomas Fahrmeyer wrote:
> 
> Hi,
> 
> little problem with indexed properties ?
> 
> I want to write
>         data.person(0).name
> 
> to get the 0-th Person object stored in an ArrayList in "data". Person has
> the attribute name (with set/getter)
> If I set up "data" with a person object the name is not displayed but if I
> write
> 
>         data.getPerson(0).name
> 
> it works. That's a inconsistent behaviour, isn't it ?

Velocity doesn't support indexed properties so you have to
use the method name as you have in your former example.

We've often talked about fully supporting the bean spec,
but haven't talked about it in a while. Also supporting
the isXXX() in boolean contexts would probably also
be useful.

> 
> I'm using Vel release 1.0.1
> 
> Thanx.
> 
> bye
> Thomas

-- 
jvz.

Jason van Zyl
jvanzyl@apache.org

http://jakarta.apache.org/velocity
http://jakarta.apache.org/turbine
http://jakarta.apache.org/commons
http://tambora.zenplex.org

RE: checking Template validity

Posted by David Duddleston <da...@i2a.com>.
> However, how often in a production system will you change templates?

Not very often and thus this is not a big concern. The compulsive side of me
wants to validate the template along with the data, but I'm guessing there
is no efficient way to do this when Templates contain #import and #parse and
possibly #marco. I have this mindset due to working with a component where
if you validate a component, it will check any components in its hierarchy
for validity also. I want to treat #parse like a component, but it does not
really work that way, since components usualy need some sort of params to
determine its actions. When I get real comfortable with Velocity, I'll
probably think of some way to emulate a component template system. Right
now, I'm just dropping in a bunch of components into a context for the
template user to access, so they can determine what data goes unto the page,
sort of like a pull model, but this seem a bit fragile and it makes caching
a little difficult.

> public Template getTemplate( Reader )

That would definately make it easy to pull templates from a datasource.

> It was a long day today, so I am basically babbling

All the babbling is very much appreciated.

Thanks once again

-david






Re: checking Template validity

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
David Duddleston wrote:
> 
> Mentioned in a previously. I would like to cache the output of frequently
> accessed Templates. I can validate my data against a cache, but validating
> the Template is questionable. It seems a Template.isModified(time) would be
> useful for, at least for me. I know
> org.apache.velocity.runtime.resource.Resource has a isSourceModified, but
> unless I missed something, it does not validate referenced Templates or
> files from import or parse directives. Any thoughts. Would it be difficult
> to implement?

Yes, if you mean a template figuring out if it would be structurally
different based on #parse() or #include(), because you can

#parse( $foo )

Now what should it do?  Render $foo and figure it out?

It certainly is *possible* (everything is possible.)

However, how often in a production system will you change templates?

That said, if very, very rare, why not just use the DataSource loader,
and have your app treat the template as data, and check?

Or even better, implement your own cache... Maybe we should provide a 

public Template getTemplate( Reader )

method in o.a.v.app.Velocity to allow you to do this, to do your own
resource management at app level for those so inclined? 

(which I think will be a small minority...)

It was a long day today, so I am basically babbling, but I think there
are quite a few alternatives to consider.

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
"still climbing up to the shoulders..."

checking Template validity

Posted by David Duddleston <da...@i2a.com>.
Mentioned in a previously. I would like to cache the output of frequently
accessed Templates. I can validate my data against a cache, but validating
the Template is questionable. It seems a Template.isModified(time) would be
useful for, at least for me. I know
org.apache.velocity.runtime.resource.Resource has a isSourceModified, but
unless I missed something, it does not validate referenced Templates or
files from import or parse directives. Any thoughts. Would it be difficult
to implement?

-david