Help! How to switch portal locale programatically? - Websphere

This is a discussion on Help! How to switch portal locale programatically? - Websphere ; Hi experts, I have a 'funny' requirement here... I have two portal servers (they are not in a cluster). I have a scenario where from one portal server, it is linked to another page in the other. And when user ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Help! How to switch portal locale programatically?

  1. Help! How to switch portal locale programatically?

    Hi experts,



    I have a 'funny' requirement here... I have two portal servers (they are not in a cluster). I have a scenario where from one portal server, it is linked to another page in the other. And when user clicks on the link to the other portal server, i need to maintain the locale information from the site. For example, if i am in French on WPS A, when i click on a link to go to a page on WPS B, WPS B needs to serve the page in French as well (even though the default language is English).



    How can I do that? I am thinking of based on the URL and set the portal locale programatically. For example, if I see /wps/portal/en/mypage, i will parse the URL ('en') and set the locale. But what's the api to call?



    Anybody can shine some light...? Thanks in advance!



    Regards

  2. Re: Help! How to switch portal locale programatically?

    well you could use the offline url generator spi to create a url in wps a, that both pointed to wps b, the page you wanted and the locale.



    To set the locale with that you use

    try {

    // get the needed factories

    final LocaleAccessorFactory locFct = (LocaleAccessorFactory) service.getAccessorFactory(LocaleAccessorFactory.c lass);

    // get a new URL from the URL factory

    final EngineURL url = urlFactory.newURL(null);

    // get a locale controller which operates on the URL-specific state

    final LocaleAccessorController locCtrl =

    locFct.getLocaleAccessorController(url.getState()) ;

    try {

    // change the locale

    locCtrl.setLocale(new Locale(language));

    // return the URL;

    finalUrl = url.toString();

    } finally {

    locCtrl.dispose();

    }

    } finally {

    urlFactory.dispose();

    }

    return finalUrl;

    }



    take a look at

    http://www.ibm.com/developerworks/we...0603_behl.html

    and

    http://www.ibm.com/developerworks/we...0612_behl.html





    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM

+ Reply to Thread