Are Map keys cached?

2 messages Options
Embed this post
Permalink
JeremyChone

Are Map keys cached?

Reply Threaded More More options
Print post
Permalink
Hi,

Using BeansWrapper.DEFAULT_WRAPPER, do the Map keys get cached by the Map bean wrapper? 

I have a use case where I would like to evaluate the keys dynamically for each template call. The current idea would be to create a Java class that implements Map and override the get() methods to implement the desired logic. The expected behavior would be that for each template call to a property (e.g., ${mySuperMap.dynaProperty}) it will call the override get() method and return the desired value. In this use-case the list of keys is dynamic and cannot be known ahead of time.

Now, if the default Map bean wrapper cache the keys or values, this model would not work.

So, does the Default Map Wapper bean cache the keys at any point? If yes, what would be the best way to accomplish my requirement? 

I understand that I could have implement a custom get properties (e.g. getProp(...)) and call it in the template. However, for template readability I would prefer to use the object.property notation.  


Thank you. 

Jeremy,


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Jeremy Chone-2

Re: Are Map keys cached?

Reply Threaded More More options
Print post
Permalink
Hum, I might have been confusing in articulating my requirement. I
will try to find a way to do it and report back.

On Tue, Oct 13, 2009 at 3:48 PM, Jeremy Chone <[hidden email]> wrote:

> Hi,
> Using BeansWrapper.DEFAULT_WRAPPER, do the Map keys get cached by the Map
> bean wrapper?
> I have a use case where I would like to evaluate the keys dynamically for
> each template call. The current idea would be to create a Java class that
> implements Map and override the get() methods to implement the desired
> logic. The expected behavior would be that for each template call to a
> property (e.g., ${mySuperMap.dynaProperty}) it will call the override get()
> method and return the desired value. In this use-case the list of keys is
> dynamic and cannot be known ahead of time.
> Now, if the default Map bean wrapper cache the keys or values, this model
> would not work.
> So, does the Default Map Wapper bean cache the keys at any point? If yes,
> what would be the best way to accomplish my requirement?
> I understand that I could have implement a custom get properties (e.g.
> getProp(...)) and call it in the template. However, for template readability
> I would prefer to use the object.property notation.
>
> Thank you.
> Jeremy,
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> FreeMarker-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user