Skip to Content

Language drop-down iview commit problem

Hi All,

I've developed a portal language / country selector iview which is placed on the main framework of the portal ( top left corner ). It allows the user to change the language of the portal on the fly. The component changes the language and country correctly when run in isolation but doesn't work correctly when added into the framework page.

The user logs in english and the menu / welcome iview etc are all in english. The user chooses french in the dropdown in my iview. The whole screen is automatically refreshed by that iview ( its an embedded iview so it refreshes the screen ). The dropdown iview updates the user data via the code :

String countryCode = selection.substring(0,2);

String langCode = selection.substring(3,5);

IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();

myBean.setSel(countryCode);

try {

IUserFactory userFactory = UMFactory.getUserFactory();

IUserMaint userMaint = userFactory.getMutableUser((request.getUser().getUniqueID()));

userMaint.setCountry(countryCode);

Locale l2 = new Locale(langCode);

userMaint.setLocale(l2);

userMaint.save(); userMaint.commit();

} catch (UMException umEx) {}

The portal refresh completes and everything is still in English. If I click refresh in the browser (or choose a different language in the dropdown ), then the whole screen returns in french. I can check the user management settings after each refresh and the update has occurred but the menus and the welcome user iviews are all one language / page refresh behind.

it is as if the screen returns before the user management data is updated.

Can anyone help ?

Cheers

Richard

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 19, 2005 at 11:45 AM

    Hi Richard,

    You need to refresh the page, I accomplished this in the following way.

    on the client side:

    function switchPortalLanguage()
    {
    	<%
    		 String languageSwitchComponent = profile.getProperty("languageSwitchComponent");
    	%>
    	<!-- # -->
    	var url  = top.gHistoryFrameworkObj.GetActiveTrackingEntryValue().URL;
    	var host = document.location.host;
    	var prot =  document.location.protocol;
    	document.location="<%=languageSwitchComponent%>?nav="+url+"&host="+host + "&prot="+prot;
    }
    

    , where <%=languageSwitchComponent%> points to the component where you do the following:

    ///..... your code to switch the language
    ////////////  <redirect> \\\\\
    String navigationTarget = req.getParameter("nav");
    String host = req.getParameter("host");
    String prot = req.getParameter("prot");
    String redirectURL = prot + "//" + host + "/irj/portal?NavigationTarget=" + navigationTarget;
    req.redirect(redirectURL);
    ////////////  </redirect> \\\\\
    

    tell me if this work out for you!

    regards,

    Dimitry

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 19, 2005 at 01:10 PM

    Hi Dimitry,

    Your solution got me thinking about refreshing the page. I tried document.reload() but that gives an unattractive " the page is being refreshed".

    The solution I've used is a client-side form submit.

    If the user changes the language, then a flag is set which writes some javascript that initiates a form submission. The flag is reset at the same time to avoid an infinite number of refreshes.

    <% if(myBean.isDoneSel()){

    myBean.setDoneSel(false);

    %>

    <script>

    document.forms[0].submit();

    </script>

    <%} %>

    The whole page refreshes and the new language is correctly picked up by the other components.

    Thanks for your help.

    Cheers

    Richard

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Richard,

      DoesnÂ’t this result in the user being thrown out from her navigation context, i.e. she has to start the navigation from scratch?!?! Or you do take it into the account. Another thing is to put the code of the languageSwitchComponent into doOnNodeReady() method of the servlet (should avoid redirect nuisance)

      d.

  • Posted on Aug 11, 2005 at 09:23 AM

    I was able to fix the problem. I noticed that the values are cached. I needed to run the refresh method to get the newly committed to be picked up the next time through the code.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Richard,

      I would like to ask you to give me more datails on your solution above. Could you please let me know how ypu developed a Portal language selector?

      Kind Regards,

      Gilson Teixeira

      BI 7.0 Consultant

      Message was edited by:

      Gilson Teixeira

      Message was edited by:

      Gilson Teixeira

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.