ISIS-390: fix for NPE in wicket viewer when rendering actions... ... that are invisible to a particular user.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/0ef9dd81 Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/0ef9dd81 Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/0ef9dd81 Branch: refs/heads/master Commit: 0ef9dd81e4adfce7ce2349bdeef638b81e30c0c7 Parents: 8cc29a3 Author: Dan Haywood <[email protected]> Authored: Fri Apr 26 17:04:34 2013 +0100 Committer: Dan Haywood <[email protected]> Committed: Fri Apr 26 17:04:34 2013 +0100 ---------------------------------------------------------------------- .../ui/components/widgets/cssmenu/CssMenuItem.java | 17 +++++++++----- 1 files changed, 11 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/isis/blob/0ef9dd81/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/cssmenu/CssMenuItem.java ---------------------------------------------------------------------- diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/cssmenu/CssMenuItem.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/cssmenu/CssMenuItem.java index d4c5148..e2c1a3c 100644 --- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/cssmenu/CssMenuItem.java +++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/cssmenu/CssMenuItem.java @@ -203,19 +203,24 @@ public class CssMenuItem implements Serializable { */ public Builder newSubMenuItem(final ObjectAdapterMemento targetAdapterMemento, final ObjectAction objectAction, final CssMenuLinkFactory cssMenuLinkFactory) { - final LinkAndLabel linkAndLabel = cssMenuLinkFactory.newLink(targetAdapterMemento, objectAction, PageAbstract.ID_MENU_LINK); - final AbstractLink link = linkAndLabel.getLink(); - final String actionLabel = linkAndLabel.getLabel(); - - // check visibility and whether enabled + // check visibility final AuthenticationSession session = getAuthenticationSession(); - final ObjectAdapter adapter = targetAdapterMemento.getObjectAdapter(ConcurrencyChecking.CHECK); final Consent visibility = objectAction.isVisible(session, adapter, where); if (visibility.isVetoed()) { return null; } + // build the link + final LinkAndLabel linkAndLabel = cssMenuLinkFactory.newLink(targetAdapterMemento, objectAction, PageAbstract.ID_MENU_LINK); + if(linkAndLabel==null) { + // can only get a null if invisible, so this should not happen given guard above + return null; + } + final AbstractLink link = linkAndLabel.getLink(); + final String actionLabel = linkAndLabel.getLabel(); + + // check whether enabled final Consent usability = objectAction.isUsable(session, adapter, where); final String reasonDisabledIfAny = usability.getReason();
