java/code/src/com/redhat/rhn/frontend/struts/BaseSetHelper.java | 33
+++++-----
java/code/src/com/redhat/rhn/frontend/taglibs/list/ListTag.java | 14 +++-
java/code/src/com/redhat/rhn/frontend/taglibs/list/ListTagHelper.java | 16 ++++
java/code/src/com/redhat/rhn/frontend/taglibs/list/ListTagUtil.java | 15 +++-
java/code/src/com/redhat/rhn/frontend/taglibs/list/SelectableColumnTag.java | 22
+++++-
java/code/src/com/redhat/rhn/frontend/taglibs/list/helper/ListSetHelper.java | 7 +-
web/html/javascript/check_all.js | 10 ++-
7 files changed, 86 insertions(+), 31 deletions(-)
New commits:
commit 778819c665331767b6d04d011d9cc0912bff9bd0
Author: Partha Aji <paji(a)redhat.com>
Date: Wed May 5 15:38:34 2010 -0400
Fixed checkstyle
diff --git a/java/code/src/com/redhat/rhn/frontend/taglibs/list/SelectableColumnTag.java
b/java/code/src/com/redhat/rhn/frontend/taglibs/list/SelectableColumnTag.java
index dd8275a..6f9d2b9 100644
--- a/java/code/src/com/redhat/rhn/frontend/taglibs/list/SelectableColumnTag.java
+++ b/java/code/src/com/redhat/rhn/frontend/taglibs/list/SelectableColumnTag.java
@@ -240,7 +240,7 @@ public class SelectableColumnTag extends TagSupport {
BodyTagSupport.findAncestorWithClass(this, ListTag.class);
if (!parent.isParentAnElement() &&
RhnListTagFunctions.isExpandable(getCurrent())) {
- itemsName = "parent_" + itemsName ;
+ itemsName = "parent_" + itemsName;
}
ListTagUtil.write(pageContext, "\" name=\"" + itemsName +
"\" ");
ListTagUtil.write(pageContext, "value=\"");
@@ -372,7 +372,7 @@ public class SelectableColumnTag extends TagSupport {
BodyTagSupport.findAncestorWithClass(this, ListTag.class);
if (!parent.isParentAnElement() &&
RhnListTagFunctions.isExpandable(getCurrent())) {
- pageItems = "parent_" + pageItems ;
+ pageItems = "parent_" + pageItems;
}
ListTagUtil.write(pageContext, "\" name=\"" + pageItems +
"\" ");
ListTagUtil.write(pageContext, "value=\"");
commit 4ffe26ea6537179c1414f0c4a495c79d4b1bbeb4
Author: Partha Aji <paji(a)redhat.com>
Date: Wed May 5 15:37:42 2010 -0400
Commiting the Select All magic stuff
diff --git a/java/code/src/com/redhat/rhn/frontend/struts/BaseSetHelper.java
b/java/code/src/com/redhat/rhn/frontend/struts/BaseSetHelper.java
index a265d9c..3bb892f 100644
--- a/java/code/src/com/redhat/rhn/frontend/struts/BaseSetHelper.java
+++ b/java/code/src/com/redhat/rhn/frontend/struts/BaseSetHelper.java
@@ -21,6 +21,7 @@ import com.redhat.rhn.domain.rhnset.RhnSet;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.frontend.context.Context;
import com.redhat.rhn.frontend.taglibs.ListDisplayTag;
+import com.redhat.rhn.frontend.taglibs.RhnListTagFunctions;
import com.redhat.rhn.frontend.taglibs.list.ListFilter;
import com.redhat.rhn.frontend.taglibs.list.ListFilterHelper;
import com.redhat.rhn.frontend.taglibs.list.ListTagHelper;
@@ -144,7 +145,7 @@ public class BaseSetHelper {
}
}
-
+
protected boolean lookupEquals(String lookupKey, String value) {
if (value == null) {
return false;
@@ -256,21 +257,25 @@ public class BaseSetHelper {
public void selectAll(Set set,
String listName,
List dataSet) {
+ boolean everyThingIsAnElement = ListTagHelper.
+ isParentAnElement(request, listName);
for (Object obj : dataSet) {
- if (obj instanceof Selectable) {
- Selectable next = (Selectable) obj;
- if (next.isSelectable()) {
- set.add(next.getSelectionKey());
+ if (everyThingIsAnElement || !RhnListTagFunctions.isExpandable(obj)) {
+ if (obj instanceof Selectable) {
+ Selectable next = (Selectable) obj;
+ if (next.isSelectable()) {
+ set.add(next.getSelectionKey());
+ }
}
- }
- else if (obj instanceof Map) {
- Map next = (Map) obj;
- set.add((String)next.get(SessionSetHelper.KEY));
- }
- else {
- Identifiable next = (Identifiable) obj;
- set.add(next.getId());
- }
+ else if (obj instanceof Map) {
+ Map next = (Map) obj;
+ set.add((String)next.get(SessionSetHelper.KEY));
+ }
+ else {
+ Identifiable next = (Identifiable) obj;
+ set.add(next.getId().toString());
+ }
+ }
}
storeSet(set);
ListTagHelper.setSelectedAmount(listName, set.size(), request);
diff --git a/java/code/src/com/redhat/rhn/frontend/taglibs/list/ListTag.java
b/java/code/src/com/redhat/rhn/frontend/taglibs/list/ListTag.java
index 9fc7121..e788225 100644
--- a/java/code/src/com/redhat/rhn/frontend/taglibs/list/ListTag.java
+++ b/java/code/src/com/redhat/rhn/frontend/taglibs/list/ListTag.java
@@ -51,7 +51,8 @@ public class ListTag extends BodyTagSupport {
private static final long serialVersionUID = 8581790371344355223L;
private static final String[] PAGINATION_NAMES = { "allBackward",
"backward", "forward", "allForward" };
-
+ private static final String HIDDEN_TEXT = "<input type=\"hidden\"
" +
+ "name=\"%s\"
value=\"%s\"/>";
private boolean haveColsEnumerated = false;
private boolean haveTblHeadersRendered = false;
private boolean haveTblFootersRendered = false;
@@ -465,7 +466,12 @@ public class ListTag extends BodyTagSupport {
dec.setCurrentList(this);
dec.beforeList();
}
-
+ ListTagUtil.write(pageContext, String.format(HIDDEN_TEXT,
+ ListTagUtil.makeFilterSearchParentLabel(uniqueName), searchParent));
+ ListTagUtil.write(pageContext, String.format(HIDDEN_TEXT,
+ ListTagUtil.makeFilterSearchChildLabel(uniqueName), searchChild));
+ ListTagUtil.write(pageContext, String.format(HIDDEN_TEXT,
+ ListTagUtil.makeParentIsAnElementLabel(uniqueName),
parentIsElement));
setupFilterUI();
if (filter != null && !isEmpty()) {
ListTagUtil.renderFilterUI(pageContext, filter,
@@ -653,7 +659,9 @@ public class ListTag extends BodyTagSupport {
excludeParams.add(ListTagUtil.makeOldFilterValueByLabel(getUniqueName()));
excludeParams.add(ListTagUtil.makeFilterSearchChildLabel(getUniqueName()));
excludeParams.add(ListTagUtil.
- makeFilterSearchParentLabel(getUniqueName()));
+ makeFilterSearchParentLabel(getUniqueName()));
+ excludeParams.add(ListTagUtil.
+ makeParentIsAnElementLabel(getUniqueName()));
ListTagUtil.write(pageContext,
ListTagUtil.makeParamsLink(pageContext.getRequest(), name,
diff --git a/java/code/src/com/redhat/rhn/frontend/taglibs/list/ListTagHelper.java
b/java/code/src/com/redhat/rhn/frontend/taglibs/list/ListTagHelper.java
index f020a55..ef1f63d 100644
--- a/java/code/src/com/redhat/rhn/frontend/taglibs/list/ListTagHelper.java
+++ b/java/code/src/com/redhat/rhn/frontend/taglibs/list/ListTagHelper.java
@@ -233,7 +233,7 @@ public class ListTagHelper {
* (always true for normal list)
* @param request the request to look in
* @param uniqueName the unique (hashed) name for the list
- * @return true if the parent is allowed to search
+ * @return true if the parent is allowed to search
*/
public static boolean canSearchByParent(ServletRequest request, String uniqueName) {
return ListTagUtil.toBoolean(request.getParameter(
@@ -245,12 +245,24 @@ public class ListTagHelper {
* search on the child object (always false for normal list)
* @param request the request to look in
* @param uniqueName the unique (hashed) name for the list
- * @return true if the search is allowed to search
+ * @return true if the child is allowed to search
*/
public static boolean canSearchByChild(ServletRequest request, String uniqueName) {
return ListTagUtil.toBoolean(request.getParameter(
ListTagUtil.makeFilterSearchChildLabel(uniqueName)));
}
+
+ /**
+ * returns true if the list that is being filtered upon is allowed to
+ * to treat the parent as an element (always true for normal list)
+ * @param request the request to look in
+ * @param uniqueName the unique (hashed) name for the list
+ * @return true if the parent can be treated as an element.
+ */
+ public static boolean isParentAnElement(ServletRequest request, String uniqueName) {
+ return ListTagUtil.toBoolean(request.getParameter(
+ ListTagUtil.makeParentIsAnElementLabel(uniqueName)));
+ }
/**
* Returns the object id given an object
diff --git a/java/code/src/com/redhat/rhn/frontend/taglibs/list/ListTagUtil.java
b/java/code/src/com/redhat/rhn/frontend/taglibs/list/ListTagUtil.java
index 83456c9..30943c3 100644
--- a/java/code/src/com/redhat/rhn/frontend/taglibs/list/ListTagUtil.java
+++ b/java/code/src/com/redhat/rhn/frontend/taglibs/list/ListTagUtil.java
@@ -586,6 +586,16 @@ public class ListTagUtil {
}
}
}
+
+ /**
+ * Returns the name of the attribute that holds the parent is an element
+ * value (used by list tag)
+ * @param listName the list name
+ * @return the label of the parent is an element attribute
+ */
+ public static String makeParentIsAnElementLabel(String listName) {
+ return "list_" + listName + "_parent_is_an_element";
+ }
/**
* Renders the filter UI
@@ -615,10 +625,7 @@ public class ListTagUtil {
//We set this so we know next time around what the old filter value was
ListTagUtil.write(pageContext, String.format(HIDDEN_TEXT,
makeOldFilterValueByLabel(uniqueName), filterValue));
- ListTagUtil.write(pageContext, String.format(HIDDEN_TEXT,
- makeFilterSearchParentLabel(uniqueName), searchParent));
- ListTagUtil.write(pageContext, String.format(HIDDEN_TEXT,
- makeFilterSearchChildLabel(uniqueName), searchChild));
+
ListTagUtil.write(pageContext, "<td");
ListTagUtil.write(pageContext, " align=\"left\">");
diff --git a/java/code/src/com/redhat/rhn/frontend/taglibs/list/SelectableColumnTag.java
b/java/code/src/com/redhat/rhn/frontend/taglibs/list/SelectableColumnTag.java
index 4bd4e7a..dd8275a 100644
--- a/java/code/src/com/redhat/rhn/frontend/taglibs/list/SelectableColumnTag.java
+++ b/java/code/src/com/redhat/rhn/frontend/taglibs/list/SelectableColumnTag.java
@@ -233,8 +233,16 @@ public class SelectableColumnTag extends TagSupport {
ListTagUtil.write(pageContext, "id=\"");
ListTagUtil.write(pageContext, checkboxId);
- ListTagUtil.write(pageContext, "\" name=\"" + ListTagUtil.
- makeSelectedItemsName(listName) +
"\" ");
+
+
+ String itemsName = ListTagUtil.makeSelectedItemsName(listName);
+ ListTag parent = (ListTag)
+ BodyTagSupport.findAncestorWithClass(this, ListTag.class);
+ if (!parent.isParentAnElement() &&
+ RhnListTagFunctions.isExpandable(getCurrent())) {
+ itemsName = "parent_" + itemsName ;
+ }
+ ListTagUtil.write(pageContext, "\" name=\"" + itemsName +
"\" ");
ListTagUtil.write(pageContext, "value=\"");
ListTagUtil.write(pageContext, value);
ListTagUtil.write(pageContext, "\" ");
@@ -359,8 +367,14 @@ public class SelectableColumnTag extends TagSupport {
ListTagUtil.write(pageContext, "<input type=\"hidden\"
");
ListTagUtil.write(pageContext, "id=\"");
ListTagUtil.write(pageContext, "list_items_" + listName + "_"
+ listId);
- ListTagUtil.write(pageContext, "\" name=\"" +
- ListTagUtil.makePageItemsName(listName) + "\"
");
+ String pageItems = ListTagUtil.makePageItemsName(listName);
+ ListTag parent = (ListTag)
+ BodyTagSupport.findAncestorWithClass(this, ListTag.class);
+ if (!parent.isParentAnElement() &&
+ RhnListTagFunctions.isExpandable(getCurrent())) {
+ pageItems = "parent_" + pageItems ;
+ }
+ ListTagUtil.write(pageContext, "\" name=\"" + pageItems +
"\" ");
ListTagUtil.write(pageContext, "value=\"");
ListTagUtil.write(pageContext, value);
ListTagUtil.write(pageContext, "\" />\n");
diff --git a/java/code/src/com/redhat/rhn/frontend/taglibs/list/helper/ListSetHelper.java
b/java/code/src/com/redhat/rhn/frontend/taglibs/list/helper/ListSetHelper.java
index 4ad7e5e..762ad3b 100644
--- a/java/code/src/com/redhat/rhn/frontend/taglibs/list/helper/ListSetHelper.java
+++ b/java/code/src/com/redhat/rhn/frontend/taglibs/list/helper/ListSetHelper.java
@@ -89,7 +89,7 @@ abstract class ListSetHelper extends ListHelper {
private boolean ignoreEmptySelection = false;
private boolean willClearSet = true;
private boolean preSelectAll = false;
-
+ private boolean parentIsElement = true;
private Set initSet = Collections.EMPTY_SET;
/**
* constructor
@@ -128,6 +128,10 @@ abstract class ListSetHelper extends ListHelper {
}
+ protected boolean isParentAnElement() {
+ return parentIsElement;
+ }
+
/** {@inheritDoc} */
public void execute() {
RequestContext context = getContext();
@@ -173,7 +177,6 @@ abstract class ListSetHelper extends ListHelper {
add(selSet);
}
-
// if its a list action update the set and the selections
if (ListTagHelper.getListAction(getListName(), request) != null) {
execute(dataSet);
diff --git a/web/html/javascript/check_all.js b/web/html/javascript/check_all.js
index de93333..dd73a49 100644
--- a/web/html/javascript/check_all.js
+++ b/web/html/javascript/check_all.js
@@ -28,9 +28,15 @@ function check_all_on_page(form, set_label) {
process_check_all(set_label, cboxes, flag, []);
}
-function process_check_all(set_label, cboxes, flag, ignorables_ids) {
- var boxes = process_group(set_label, cboxes, flag);
+function process_check_all(set_label, cbox_items, flag, ignorables_ids) {
var ignorables = ids_to_elements(ignorables_ids);
+ var cboxes = new Array();
+ cboxes = cboxes.concat(ignorables);
+ for (var i = 0 ; i < cbox_items.length; i++) {
+ cboxes.push(cbox_items[i]);
+ }
+
+ var boxes = process_group(set_label, cboxes, flag);
var includes = new Array();
for (var i = 0; i < boxes.length; i++) {
var include = true;