on 07-19-2005 11:44 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Richard,
Doesnt 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.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.