Skip to content

Instantly share code, notes, and snippets.

@mkgl
Created May 11, 2015 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkgl/d4f329d0961c7ec78c65 to your computer and use it in GitHub Desktop.
Save mkgl/d4f329d0961c7ec78c65 to your computer and use it in GitHub Desktop.
QA incorrect param candidates for multi-item actions when both ctors exist (Item vs. List<Item>)
From 5f6e12de2a6eaa5aac2d17ac9178522fa07a2866 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mika=C3=ABl=20Gelji=C4=87?= <mikael.geljic@magnolia-cms.com>
Date: Mon, 23 Feb 2015 14:48:25 +0100
Subject: [PATCH] QA incorrect param candidates for multi-item actions when
both ctors exist (Item vs. List<Item>)
---
.../info/magnolia/ui/contentapp/browser/BrowserPresenter.java | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/magnolia-ui-contentapp/src/main/java/info/magnolia/ui/contentapp/browser/BrowserPresenter.java b/magnolia-ui-contentapp/src/main/java/info/magnolia/ui/contentapp/browser/BrowserPresenter.java
index 445d84f..8ed7b5f 100644
--- a/magnolia-ui-contentapp/src/main/java/info/magnolia/ui/contentapp/browser/BrowserPresenter.java
+++ b/magnolia-ui-contentapp/src/main/java/info/magnolia/ui/contentapp/browser/BrowserPresenter.java
@@ -368,8 +368,14 @@ public class BrowserPresenter implements ActionbarPresenter.Listener, BrowserVie
selectedItems.add(contentConnector.getItem(idIt.next()));
}
- argList.add(selectedItems);
- argList.add(selectedItems.isEmpty() ? new NullItem() : selectedItems.get(0));
+ if (selectedItems.size() <= 1) {
+ // we have a simple selection; action implementation may expect either an item, either a list parameter, so we have to support both.
+ argList.add(selectedItems.isEmpty() ? new NullItem() : selectedItems.get(0));
+ argList.add(selectedItems);
+ } else {
+ // we have a multiple selection; action implementation must support a list parameter, no way around that.
+ argList.add(selectedItems);
+ }
return argList.toArray(new Object[argList.size()]);
}
}
--
1.9.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment