Hi

I just wanted to make sure that my idea makes some sense if implemented this
way. My prerequisites:

1. I want to mount my homepage and all it's children (which are not that
many) multiple times at different mountpoints
2. Each mountpoint is prefixed with a language identifier which ultimately
decides in which language the content is presented (the site consists to 95%
of dynamic content which resides pre-localized in a database). Example: 

http://domain.com -> homepage english
http://domain.com/items -> item info page english

http://domain.com/de -> homepage german
http://domain.com/de/items-> item info page german

In order to achieve the desired behavior I've subclassed the WebRequestCycle
like shown below. Since I'm still pretty new to wicket, I would like to know
if this is how it should be done the "Wicket Way" or if there's a better
solution. 

class MyRequestCycle extends WebRequestCycle
{
        public MyRequestCycle(WebApplication application, WebRequest request,
Response response)
        {
                super(application, request, response);

                // init locale map
                mapPatch2Locale = new HashMap<String, Locale>();
                mapPatch2Locale.put("de", Locale.GERMAN);
                mapPatch2Locale.put("fr", Locale.FRENCH);
                mapPatch2Locale.put("es", new Locale("es"));
        }

        /** Maps Request Path to associated Locale **/
        HashMap<String, Locale> mapPatch2Locale;

        protected void onBeginRequest()
        {
                super.onBeginRequest();

                // adjust locale to url prefix
                String path = getRequest().getPath();
                Locale locale = null;

                Set<String> keys = mapPatch2Locale.keySet();
                while(keys.iterator().hasNext())
                {
                        String _path = keys.iterator().next();
                        if(path.equals(_path) || path.startsWith(_path + "/"))
                        {
                                locale = mapPatch2Locale.get(_path);
                                break;
                        }
                }

                // default is english
                if(locale == null)
                        locale = Locale.ENGLISH;

                // setup locale for this request
                getSession().setLocale(locale);
        }
}

-- 
View this message in context: 
http://www.nabble.com/Multiple-Homepage-Mountpoints-for-Localization-tp15507606p15507606.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to