Author: trong.tran
Date: 2010-04-07 04:49:03 -0400 (Wed, 07 Apr 2010)
New Revision: 2519
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBody.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageWizard.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
Log:
GTNPORTAL-1020 javascript error after creating a new page
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBody.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBody.java 2010-04-07
08:40:10 UTC (rev 2518)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBody.java 2010-04-07
08:49:03 UTC (rev 2519)
@@ -76,40 +76,12 @@
public void setPageBody(PageNode pageNode, UIPortal uiPortal) throws Exception
{
WebuiRequestContext context = Util.getPortalRequestContext();
- ExoContainer appContainer =
context.getApplication().getApplicationServiceContainer();
- UserPortalConfigService userPortalConfigService =
-
(UserPortalConfigService)appContainer.getComponentInstanceOfType(UserPortalConfigService.class);
- Page page = null;
- UIPage uiPage;
-
- String pageReference = null;
-
- if (pageNode != null)
- {
- pageReference = pageNode.getPageReference();
- try
- {
- if (pageReference != null)
- {
- page = userPortalConfigService.getPage(pageReference,
context.getRemoteUser());
- }
- }
- catch (Exception e)
- {
- UIPortalApplication uiApp = getAncestorOfType(UIPortalApplication.class);
- uiApp.addMessage(new ApplicationMessage(e.getMessage(), new Object[]{}));
- }
- }
-
uiPortal.setMaximizedUIComponent(null);
- try
+ UIPage uiPage;
+ uiPage = getUIPage(pageNode, uiPortal, context);
+ if (uiPage == null)
{
- uiPage = getUIPage(pageReference, page, uiPortal, context);
- }
- catch (Exception ex)
- {
- // TODO: Print evokable message
setUIComponent(null);
return;
}
@@ -142,15 +114,30 @@
* @param uiPortal
* @return
*/
- private UIPage getUIPage(String pageReference, Page page, UIPortal uiPortal,
WebuiRequestContext context)
+ private UIPage getUIPage(PageNode pageNode, UIPortal uiPortal, WebuiRequestContext
context)
throws Exception
{
+ Page page = null;
+ String pageReference = null;
+
+ if (pageNode != null)
+ {
+ pageReference = pageNode.getPageReference();
+ if (pageReference != null)
+ {
+ ExoContainer appContainer =
context.getApplication().getApplicationServiceContainer();
+ UserPortalConfigService userPortalConfigService =
+
(UserPortalConfigService)appContainer.getComponentInstanceOfType(UserPortalConfigService.class);
+ page = userPortalConfigService.getPage(pageReference,
context.getRemoteUser());
+ }
+ }
+
//The page has been deleted
if(page == null)
{
//Clear the UIPage from cache in UIPortal
uiPortal.clearUIPage(pageReference);
- throw new Exception("The page with id " + pageReference + " has
been removed");
+ return null;
}
UIPage uiPage = uiPortal.getUIPage(pageReference);
@@ -173,11 +160,6 @@
return uiPage;
}
- public void renderChildren() throws Exception
- {
-
uicomponent_.processRender((WebuiRequestContext)WebuiRequestContext.getCurrentInstance());
- }
-
public void processRender(WebuiRequestContext context) throws Exception
{
if (maximizedUIComponent != null &&
Util.getUIPortalApplication().getModeState() % 2 == 0)
@@ -186,11 +168,6 @@
return;
}
- //TODO: Remove beneath block
- if (uicomponent_ == null)
- {
- setPageBody(Util.getUIPortal().getSelectedNode(), Util.getUIPortal());
- }
super.processRender(context);
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java 2010-04-07
08:40:10 UTC (rev 2518)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java 2010-04-07
08:49:03 UTC (rev 2519)
@@ -19,6 +19,7 @@
package org.exoplatform.portal.webui.page;
+import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.model.Page;
@@ -85,7 +86,7 @@
{
UIPagePreview uiPagePreview = getChild(UIPagePreview.class);
UIPage uiPage = (UIPage)uiPagePreview.getUIComponent();
- UIPortal uiPortal = Util.getUIPortal();
+
UIWizardPageSetInfo uiPageInfo = getChild(UIWizardPageSetInfo.class);
UIPageNodeSelector uiNodeSelector = uiPageInfo.getChild(UIPageNodeSelector.class);
@@ -116,9 +117,8 @@
DataStorage dataService = getApplicationComponent(DataStorage.class);
dataService.create(page);
dataService.save(pageNav);
+ UIPortal uiPortal = Util.getUIPortal();
setNavigation(uiPortal.getNavigations(), uiNodeSelector.getSelectedNavigation());
- PageNodeEvent<UIPortal> pnevent = new PageNodeEvent<UIPortal>(uiPortal,
PageNodeEvent.CHANGE_PAGE_NODE, pageNode.getUri());
- uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
}
private void setNavigation(List<PageNavigation> navs, PageNavigation nav)
@@ -342,7 +342,11 @@
if (isDesktopPage)
{
uiWizard.saveData();
- uiWizard.updateUIPortal(uiPortalApp, event);
+ PageNode selectedNode = uiNodeSelector.getSelectedPageNode();
+ UIPortal uiPortal = Util.getUIPortal();
+ PageNodeEvent<UIPortal> pnevent = new
PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE,
selectedNode.getUri());
+ uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
+ uiWizard.updateUIPortal(event);
return;
}
@@ -372,17 +376,14 @@
uiWizard.saveData();
UIPortalToolPanel toolPanel =
uiWorkingWS.findFirstComponentOfType(UIPortalToolPanel.class);
toolPanel.setUIComponent(null);
- uiWizard.updateUIPortal(uiPortalApp, event);
- JavascriptManager jsManager = event.getRequestContext().getJavascriptManager();
- jsManager.addJavascript("eXo.portal.portalMode=" +
UIPortalApplication.NORMAL_MODE + ";");
-
+ uiWizard.updateUIPortal(event);
UIWizardPageSetInfo uiPageInfo = uiWizard.getChild(UIWizardPageSetInfo.class);
UIPageNodeSelector uiNodeSelector =
uiPageInfo.getChild(UIPageNodeSelector.class);
PageNode selectedNode = uiNodeSelector.getSelectedPageNode();
-
- String uri = Util.getPortalRequestContext().getPortalURI() +
selectedNode.getUri();
- //Util.getPortalRequestContext().sendRedirect(uri);
- jsManager.addJavascript("window.location = '" + uri +
"';");
+
+ PortalRequestContext pcontext = Util.getPortalRequestContext();
+ String uri = pcontext.getPortalURI() + selectedNode.getUri();
+ pcontext.getResponse().sendRedirect(uri);
}
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageWizard.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageWizard.java 2010-04-07
08:40:10 UTC (rev 2518)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageWizard.java 2010-04-07
08:49:03 UTC (rev 2519)
@@ -94,7 +94,7 @@
return uiHelpWindow;
}
- void updateUIPortal(UIPortalApplication uiPortalApp, Event<? extends
UIPageWizard> event) throws Exception
+ protected void updateUIPortal(Event<? extends UIPageWizard> event) throws
Exception
{
PortalRequestContext pcontext = (PortalRequestContext)event.getRequestContext();
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2010-04-07
08:40:10 UTC (rev 2518)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2010-04-07
08:49:03 UTC (rev 2519)
@@ -199,6 +199,12 @@
return listNavs;
}
+ /**
+ * Return cached UIPage associated to the specified pageReference
+ *
+ * @param pageReference key whose associated UIPage is to be returned
+ * @return the UIPage associated to the specified pageReference or null if not any
+ */
public UIPage getUIPage(String pageReference)
{
if(all_UIPages == null)