Fix for ALF-435 - Unfriendly error occurs when trying to delete renamed category from category page

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31375 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2011-10-20 11:01:47 +00:00
parent c80d13c92f
commit 70d4475e62
2 changed files with 27 additions and 10 deletions

View File

@@ -459,6 +459,12 @@ public class CategoriesDialog extends BaseDialogBean implements IContextListener
this.setCurrentCategory(ref); this.setCurrentCategory(ref);
} }
/**
* If category.equals(handler.label) then the breadcrumb reverts one step back
* (needed for deleting)
* Else current breadcrumb is updated accordingly to the current category
* (needed for editing)
*/
protected void removeFromBreadcrumb(String category) protected void removeFromBreadcrumb(String category)
{ {
// remove this node from the breadcrumb if required // remove this node from the breadcrumb if required
@@ -477,6 +483,12 @@ public class CategoriesDialog extends BaseDialogBean implements IContextListener
this.setCurrentCategory(handler.nodeRef); this.setCurrentCategory(handler.nodeRef);
} }
} }
else
{
handler=new CategoryBreadcrumbHandler (getCategory().getNodeRef(), Repository.getNameForNode(getNodeService(), getCategory().getNodeRef()));
location.set(location.size() - 1, handler);
this.setCurrentCategory(handler.nodeRef);
}
} }
@Override @Override

View File

@@ -98,6 +98,17 @@ public class EditCategoryDialog extends BaseDialogBean
setActionCategory(category); setActionCategory(category);
} }
@Override
protected String doPostCommitProcessing(FacesContext context, String outcome)
{
// add the category to the request object so it gets picked up by
// category dialog, this will allow it to be edited in the breadcrumb
context.getExternalContext().getRequestMap().put(
CategoriesDialog.KEY_CATEGORY, this.category.getName());
return outcome;
}
public String getName() public String getName()
{ {
return name; return name;
@@ -277,17 +288,11 @@ public class EditCategoryDialog extends BaseDialogBean
} }
// edit the node in the breadcrumb if required // edit the node in the breadcrumb if required
CategoriesDialog categoriesDialog = new CategoriesDialog();
List<IBreadcrumbHandler> location = getLocation(); List<IBreadcrumbHandler> location = getLocation();
IBreadcrumbHandler handler = location.get(location.size() - 1); IBreadcrumbHandler handler = categoriesDialog.new CategoryBreadcrumbHandler(nodeRef, Repository.getNameForNode(getNodeService(), nodeRef));
location.set(location.size() - 1, handler);
// see if the current breadcrumb location is our node setCategory(new Node(nodeRef));
if (nodeRef.equals(((IRepoBreadcrumbHandler) handler).getNodeRef()))
{
// and update with the modified node details
CategoriesDialog categoriesDialog = new CategoriesDialog();
IBreadcrumbHandler newHandler = categoriesDialog.new CategoryBreadcrumbHandler(nodeRef, Repository.getNameForNode(getNodeService(), nodeRef));
location.set(location.size() - 1, newHandler);
}
} }
catch (Throwable err) catch (Throwable err)
{ {