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={}))