Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

Commit

Permalink
GTNPORTAL-3076 Javascript module configured for specific portal site …
Browse files Browse the repository at this point in the history
…is not loaded properly
  • Loading branch information
phuong_vu authored and trongtt committed May 30, 2013
1 parent 1ac5e9f commit 6ac7d1a
Showing 1 changed file with 24 additions and 18 deletions.
Expand Up @@ -314,29 +314,26 @@ public Map<String, Boolean> getScripts() {
PortalRequestContext prc = PortalRequestContext.getCurrentInstance();
JavascriptManager jsMan = prc.getJavascriptManager();

// Add current portal
String portalOwner = Util.getPortalRequestContext().getPortalOwner();
jsMan.loadScriptResource(ResourceScope.PORTAL, portalOwner);

// Support for legacy resource declaration
jsMan.loadScriptResource(ResourceScope.SHARED, JavascriptConfigParser.LEGACY_JAVA_SCRIPT);

// Need to add bootstrap as immediate since it contains the loader
jsMan.loadScriptResource(ResourceScope.SHARED, "bootstrap");

//
FetchMap<ResourceId> requiredResources = jsMan.getScriptResources();
log.debug("Resource ids to resolve: {}", requiredResources);

//
JavascriptConfigService service = getApplicationComponent(JavascriptConfigService.class);
LinkedHashMap<String, Boolean> ret = new LinkedHashMap<String, Boolean>();
Map<ScriptResource, FetchMode> tmp = service.resolveIds(requiredResources);
for (ScriptResource rs : tmp.keySet()) {
Map<String, Boolean> ret = new LinkedHashMap<String, Boolean>();
Map<String, Boolean> tmp = new LinkedHashMap<String, Boolean>();
Map<ScriptResource, FetchMode> resolved = service.resolveIds(requiredResources);
for (ScriptResource rs : resolved.keySet()) {
ResourceId id = rs.getId();
boolean isRemote = !rs.isEmpty() && rs.getModules().get(0) instanceof Module.Remote;
ret.put(id.toString(), isRemote);
//SHARED/bootstrap should be loaded first
if (ResourceScope.SHARED.equals(id.getScope()) && "bootstrap".equals(id.getName())) {
ret.put(id.toString(), false);
} else {
boolean isRemote = !rs.isEmpty() && rs.getModules().get(0) instanceof Module.Remote;
tmp.put(id.toString(), isRemote);
}
}
ret.putAll(tmp);
for (String url : jsMan.getExtendedScriptURLs()) {
ret.put(url, true);
}
Expand Down Expand Up @@ -586,14 +583,23 @@ public void processAction(WebuiRequestContext context) throws Exception {
* skins to reload are set in the <div class="PortalResponseScript">
*/
public void processRender(WebuiRequestContext context) throws Exception {
Writer w = context.getWriter();
PortalRequestContext pcontext = (PortalRequestContext) context;

JavascriptManager jsMan = context.getJavascriptManager();
// Add JS resource of current portal
String portalOwner = pcontext.getPortalOwner();
jsMan.loadScriptResource(ResourceScope.PORTAL, portalOwner);

//
Writer w = context.getWriter();
if (!context.useAjax()) {
// Support for legacy resource declaration
jsMan.loadScriptResource(ResourceScope.SHARED, JavascriptConfigParser.LEGACY_JAVA_SCRIPT);
// Need to add bootstrap as immediate since it contains the loader
jsMan.loadScriptResource(ResourceScope.SHARED, "bootstrap");

super.processRender(context);
} else {
PortalRequestContext pcontext = (PortalRequestContext) context;

UIMaskWorkspace uiMaskWS = getChildById(UIPortalApplication.UI_MASK_WS_ID);
if (uiMaskWS.isUpdated())
pcontext.addUIComponentToUpdateByAjax(uiMaskWS);
Expand Down

0 comments on commit 6ac7d1a

Please sign in to comment.