Author: liem_nguyen
Date: 2010-02-07 22:28:46 -0500 (Sun, 07 Feb 2010)
New Revision: 1541
Modified:
portal/trunk/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardContainer.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNavigation.java
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UITabPaneDashboard.java
Log:
GTNPORTAL-443 NPE when delete tab in special case
Modified:
portal/trunk/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardContainer.java
===================================================================
---
portal/trunk/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardContainer.java 2010-02-08
02:15:15 UTC (rev 1540)
+++
portal/trunk/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardContainer.java 2010-02-08
03:28:46 UTC (rev 1541)
@@ -123,12 +123,13 @@
UIPortlet currentUIPortlet = UIPortlet.getCurrentUIPortlet();
// Get dashboard for merging
- Container dashboard;
+ Container dashboard = null;
if (currentUIPortlet.getStorageId() != null)
{
dashboard = service.loadDashboard(currentUIPortlet.getStorageId());
}
- else
+
+ if (dashboard == null)
{
dashboard = createContainer(COLUMN_CONTAINER, null);
}
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNavigation.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNavigation.java 2010-02-08
02:15:15 UTC (rev 1540)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNavigation.java 2010-02-08
03:28:46 UTC (rev 1541)
@@ -21,7 +21,6 @@
import org.exoplatform.portal.pom.data.NavigationData;
import org.exoplatform.portal.pom.data.NavigationNodeData;
-import org.gatein.mop.core.api.workspace.NavigationContainer;
import java.util.ArrayList;
import java.util.LinkedHashMap;
Modified:
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UITabPaneDashboard.java
===================================================================
---
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UITabPaneDashboard.java 2010-02-08
02:15:15 UTC (rev 1540)
+++
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UITabPaneDashboard.java 2010-02-08
03:28:46 UTC (rev 1541)
@@ -105,7 +105,7 @@
}
*/
-
+
public int getCurrentNumberOfTabs() throws Exception
{
@@ -162,51 +162,56 @@
List<PageNode> nodes = pageNavigation.getNodes();
PageNode tobeRemoved = nodes.get(nodeIndex);
PageNode selectedNode = uiPortal.getSelectedNode();
-
- // Refresh Node List to prevent session conflict
- nodes.clear();
- PageNavigation updateNav =
configService.getPageNavigation(pageNavigation.getOwnerType(),
pageNavigation.getOwnerId());
- int count = 0;
+
+ boolean isRemoved = true; // To check
+ PageNavigation updateNav =
+ configService.getPageNavigation(pageNavigation.getOwnerType(),
pageNavigation.getOwnerId());
for (PageNode pageNode : updateNav.getNodes())
{
- nodes.add(pageNode);
- if (pageNode.getUri().equals(tobeRemoved.getUri())) {
- nodeIndex = count;
- tobeRemoved = pageNode;
+ if (pageNode.getUri().equals(tobeRemoved.getUri()))
+ {
+ isRemoved = false;
+ break;
}
- if (pageNode.getUri().equals(selectedNode.getUri())) {
- selectedNode = pageNode;
- }
- count ++;
}
-
- if (tobeRemoved.getUri().equals(selectedNode.getUri()))
+
+ if (nodes.size() >= 2)
{
- selectedNode = nodes.get(Math.max(0, nodeIndex - 1));
-
- } else if (!nodes.contains(selectedNode)) {
- selectedNode = nodes.get(0);
- }
-
- if (nodes.size() >= 2)
- {
+ // Remove node
nodes.remove(tobeRemoved);
- String pageRef = tobeRemoved.getPageReference();
- if (pageRef != null && pageRef.length() > 0)
+
+ // Choose selected Node
+ if (tobeRemoved.getUri().equals(selectedNode.getUri()))
{
- Page page = configService.getPage(pageRef);
- if (page != null)
- configService.remove(page);
+ selectedNode = nodes.get(Math.max(0, nodeIndex - 1));
+
}
-
- uiPortal.setSelectedNode(selectedNode);
- configService.update(pageNavigation);
- } else {
+ else if (!nodes.contains(selectedNode))
+ {
+ selectedNode = nodes.get(0);
+ }
+
+ // Update
+ if (!isRemoved)
+ {
+ String pageRef = tobeRemoved.getPageReference();
+ if (pageRef != null && pageRef.length() > 0)
+ {
+ Page page = configService.getPage(pageRef);
+ if (page != null)
+ configService.remove(page);
+ }
+ uiPortal.setSelectedNode(selectedNode);
+ configService.update(pageNavigation);
+ }
+ }
+ else
+ {
getAncestorOfType(UIApplication.class).addMessage(
new
ApplicationMessage("UITabPaneDashboard.msg.cannotDeleteLastTab", null));
return null;
}
-
+
return selectedNode;
}
catch (Exception ex)
@@ -385,20 +390,21 @@
public void execute(Event<UITabPaneDashboard> event) throws Exception
{
UITabPaneDashboard source = event.getSource();
- WebuiRequestContext context = event.getRequestContext();
+ WebuiRequestContext context = event.getRequestContext();
int removedNodeIndex =
Integer.parseInt(context.getRequestParameter(UIComponent.OBJECTID));
PageNode selectedNode = source.removePageNode(removedNodeIndex);
//If the node is removed successfully, then redirect to the node specified by
tab on the left
if (selectedNode != null)
{
- // set maximizedUIComponent of UIPageBody is null if it is maximized portlet
of removed page
- UIPortal uiPortal = Util.getUIPortal();
- UIPageBody uiPageBody = uiPortal.findFirstComponentOfType(UIPageBody.class);
- if(uiPageBody != null && uiPageBody.getMaximizedUIComponent() !=
null){
- uiPageBody.setMaximizedUIComponent(null);
- }
-
+ // set maximizedUIComponent of UIPageBody is null if it is maximized portlet
of removed page
+ UIPortal uiPortal = Util.getUIPortal();
+ UIPageBody uiPageBody = uiPortal.findFirstComponentOfType(UIPageBody.class);
+ if (uiPageBody != null && uiPageBody.getMaximizedUIComponent() !=
null)
+ {
+ uiPageBody.setMaximizedUIComponent(null);
+ }
+
PortalRequestContext prContext = Util.getPortalRequestContext();
prContext.setResponseComplete(true);
prContext.getResponse().sendRedirect(prContext.getPortalURI() +
selectedNode.getUri());
Show replies by date