coming along nicely

"Luther Baker" <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
My Tapestry-style web framework is coming along very nicely written in
freemarker.

Kudos to such a great library.

I have a question about resource bundles. There are three things I do when a
user makes a URL request

/context/Home (does the following)

a) look for x.y.z.Home.class if it exists
b) look for Home.ftl in various directories
c) load x.y.z.Home.properties if it exists

All of this works great - but one issue I am having with the properties
file. I am essentially loading a ResourcBundle and placing it into the root
hashmap when processing the template:

                // bundle
                try
                {
                    resourceBundle =
ResourceBundle.getBundle(javaClassName);
                }
                catch (MissingResourceException e)
                {
                    if (log.isDebugEnabled())
                        log.debug("No resource bundle defined for this
request: " + javaClassName);
                }

<snip/>

        try
        {
            // invoke the class
            HashMap<String, Object> templateMap = getValuesForThisPage();

            // resource bundle
            if (resourceBundle != null)
            {
                templateMap.put(RESOURCE_BUNDLE_KEY, resourceBundle);
            }

            // prep the template engine
            PrintWriter out = response.getWriter();
            Template template =
templateEngine.getTemplate(defaultTemplatePath);

            // write the template
            template.process(templateMap, out);
        }


All of this works just fine ... but when I echo values from the
resourceBundle in the template, it doesn't work for anything nested one or
more level deep:

IE:

# Contact.properties
[email protected]
[email protected]

Contact.ftl
        <ul>
            <li>${msg.faq}</li>
            <li>${msg.email.tutorial}</li>
        </ul>


Now, <li>${msg.faq}</li> shows up just fine but
<li>${msg.email.tutorial}</li> is a problem:

No such key: email
The problematic instruction:
----------
==> ${msg.email.tutorial} [on line 13, column 29 in support/Contact.ftl]

So, before I spend a few hours digging to see if I'm somehow mismanaging the
ResourceBundle ... can someone chime is - is this a limitation or expected
behavior or can you see something I am doing incorrectly. I started looking
at ResourceBundleModel but there isn't a whole lof of explanatory docs there
for those of us not even sure if our ResourceBundle code is correct.

As a side note ... anyone have an example using ResourceBundleModel.format?

Thanks in advance,

-Luther

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.