Re: Get Hash Value with two methods.But the one works finely, the other one is Exception.
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
You confuse something is this mail, because it's tmpmodename().key
that should work, tmpmodename().["$key"] that shouldn't work.
Supposing this was the case, there are two problems with the last.
First of all, the dot shouldn't be there; that's already a syntax
error. Secondly, although it's not an error, writing ["$key"] is
awkward, you could just write [key].
Sunday, December 21, 2008, 2:18:48 AM, Gerry Chen wrote:
> Hi Everyone!
>
> I had a question about geting a hash value,When I used the my directives.
>
> My method like this:
>
> package com.star.yxt.common.model;
>
> import ......;
>
> public class PageSizeModel implements TemplateMethodModel {
>
> private Map<String,Integer> mapPageSize = new HashMap<String,Integer>;
>
> @Override
> public Object exec(List args) throws TemplateModelException {
>
> ..............
>
> return mapPageSize;
>
> }
> }
>
> My FLT template like this:
>
> <#macro drp_pagesize selectname modelname selected>
> <#assign tmpmodename=
> (modelname!"com.star.yxt.common.model.PageSizeModel")?new()>
> <select name="${selectname}" class="input">
> <#if tmpmodename??>
> <#assign keys=tmpmodename()?keys>
> <#list keys as key>
> ${tmpmodename().["$key"]} <#-- It
does wok finely -->>
> ${tmpmodename().key} <#-- It doesn't work finely -->
> .........
>
>
> I have saw the tutorial in FreeMarker websit.The tutorial indicate that
> book["title"] equal book.title in the
> templates.(http://freemarker.org/docs/dgui_template_exp.html#dgui_template_exp_var_hash).
>
> My question is why the expression ${tmpmodename().key} can't work.
>
> Who can explain my puzzledom about this situation?
>
> Thanks!
>
>
>
>
--
Best regards,
Daniel Dekany
------------------------------------------------------------------------------