Hi,

I want to continue with problem described in
http://thread.gmane.org/gmane.comp.java.wicket.user/19711 and discuss my
current solution.

I have slightly modified WebRequestCodingStrategy, the urlPrefix() is not
final and the call to request.getPath() in addResourceParameters() was
changed to getRequestPath(request), it seems like bug (if the description of
getRequestPath is correct).

Now I can build MyRequestCodingStrategy

public class MyRequestCodingStrategy extends WebRequestCodingStrategy {
    protected String getRequestPath(final Request request) {
        return MySession.get().removePreParams(request.getPath());
    }

    protected CharSequence urlPrefix(final RequestCycle requestCycle) {
        return MySession.get().addPreParams(
            super.urlPrefix(requestCycle).toString());
    }
}

MySession:

public String removePreParams(String path) {
/*
Remove the pre params from the path. The number of pre parameters is fixed,
they must be always present, for instance /<language>/whatever
The <language> is used to set session locale
*/
}

public String addPrependParams(final String path) {
/*
Do the reverse of removePreParams(), read data from session and
apend it to "path".
*/
return path + '/' + getLocale().getLanguage();
}

Now the language is part of the URL.

I can switch between languages with:
add(new Link("langCzech") {
    public void onClick() { MySession.get().setLocale(new Locale("cs")); }
});

It seems to work fine with wicket 1.2.3. I have couple of questions:
1. In wicket 1.3 and 2.0, can I make something similar?
2. Are there any hidden problems?

Thank you for any comment, Jan




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to