cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grzegorz Kossakowski <gkossakow...@apache.org>
Subject Re: HashMap in repeater binding via javascript
Date Fri, 04 Jan 2008 21:03:05 GMT
Dev at weitling pisze:
> Hi Harald,
> 
> thanks for your help, but it I'm sorry to say it doesn't match my problem.
> An example:
>     Map<String,String> locales = new HashMap<String,String>();
>     locales.put("de","deutsch");
>     locales.put("en","english");
>     locales.put("fr","francais");
> 
> I now want a repeater binding iterating over the keys with presenting
> the keys with their values in the template, something like (doesn't work!):
>     <fb:repeater id="localeRepeater" path="locales">
>         <fb:identity>
>            <fb:value id="key" path="key"/>
>         </fb:identity>
>         <fb:on-bind>
>            <fb:value id="value" path="value"/>
>         </fb:on-bind>
>     </fb:repeater>
> 
> Alas, Map defines methods keySet() instead of getKeySet(). entrySet()
> returns a Set with MapEntry-objects with getKey()/getValue(), but it's
> name should be getEntrySet(). *Argh*
> 
> So I have to provide a custom binding via Javascript or Java.

Hi Florian,

Have you tried following:
    <fb:repeater id="localeRepeater" path="locales">
        <fb:identity>
           <fb:value id="key" path="@name"/>
        </fb:identity>
        <fb:on-bind>
           <fb:value id="value" path="."/>
        </fb:on-bind>
    </fb:repeater>

According to last paragraph of Attributes section of JXPath documentation[1] it may work.

[1] http://commons.apache.org/jxpath/users-guide.html#Attributes

-- 
Grzegorz Kossakowski
Committer and PMC Member of Apache Cocoon
http://reflectingonthevicissitudes.wordpress.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message