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);
}
/**
* 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)
{
// remove this node from the breadcrumb if required
@@ -477,6 +483,12 @@ public class CategoriesDialog extends BaseDialogBean implements IContextListener
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

View File

@@ -98,6 +98,17 @@ public class EditCategoryDialog extends BaseDialogBean
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()
{
return name;
@@ -277,17 +288,11 @@ public class EditCategoryDialog extends BaseDialogBean
}
// edit the node in the breadcrumb if required
List<IBreadcrumbHandler> location = getLocation();
IBreadcrumbHandler handler = location.get(location.size() - 1);
// see if the current breadcrumb location is our node
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);
}
List<IBreadcrumbHandler> location = getLocation();
IBreadcrumbHandler handler = categoriesDialog.new CategoryBreadcrumbHandler(nodeRef, Repository.getNameForNode(getNodeService(), nodeRef));
location.set(location.size() - 1, handler);
setCategory(new Node(nodeRef));
}
catch (Throwable err)
{