1

For some condition, I have replaced a pageModel with a default pageModel and the page contents load properly. The page loads properly. In some cases, I additionally have to change the localization from A to D where A is my webRequestContext.localization and D is the localization of the default pageModel. In this case, the Navigation sitemap that comes from the NavigationController loads the sitemap based on webRequestContext.localization.

How can I change webRequestContext.localization without redirecting to the default page?

if(redirectSiteLang.equals("en")) {
        localization = localizationfactory.createLocalization("10", "/en");
    }else if (redirectSiteLang.equals("ar")) {
        localization = localizationfactory.createLocalization("11", "/ar");
    }
localizationResolver.refreshLocalization(localization);
request.setAttribute(PAGE_MODEL, pageModel); // new pageModel set
request.setAttribute(LOCALIZATION, localization); // new localization set

When I do a webRequestContext.getPage(); it prints all the regions with their respective include page ids pointing to the 11 publication.

meta={regions=RegionModelSetImpl(modelMapByName={WebSiteNav=AbstractViewModel(extensionData=null, htmlClasses=null,
        xpmMetadata={IncludedFromPageID=tcm:11-126524-64, IncludedFromPageTitle=WebSiteNav, IncludedFromPageFileName=web-site-nav}, mvcData=MvcDataImpl(controllerAreaName=Framework, controllerName=Region, actionName=Region, areaName=Core, viewName=WebSiteNav, regionAreaName=null, regionName=null, routeValues={}, metadata={}))
  • Why do you want to change the Localization? Is the Localization not resolved correctly based on the page URL? – Rick Pannekoek Feb 6 at 15:54
  • In one of the cases, user might be in the root localization (so neither en nor ar) but I need to show the content from appropriate localization based on user's history. – Rache Feb 6 at 18:48
  • @rickpannekoek to add to my above comment, even though I manage to load the pageModel of the required publication some of the other components in that page comes from the core controller which reads the localization from the webRequestContext. Any way to refresh the webRequestContext localization without redirecting. – Rache Feb 7 at 6:50
0

In your example use case, the WebRequestContext doesn't really change: the Web Request was done in a particular Localization context (based on the URL of the Web Request).

But I understand you want to be able to retrieve content from another Localization? Note that the ContentProvider methods take a Localization parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.