java/code/src/com/redhat/rhn/frontend/taglibs/list/DataSetManipulator.java | 20
+++++++--
java/code/src/com/redhat/rhn/frontend/taglibs/list/ListFilterHelper.java | 22
++++++----
java/code/src/com/redhat/rhn/frontend/taglibs/list/ListTag.java | 22
+++++++++-
java/code/src/com/redhat/rhn/frontend/taglibs/rhn-list.tld | 11 ++++-
java/code/webapp/WEB-INF/pages/systems/duplicate/duplicateIPList.jsp | 4 +
5 files changed, 65 insertions(+), 14 deletions(-)
New commits:
commit aa08c95f9340b930c7f0c52bfb6a403b97708af8
Author: Partha Aji <paji(a)redhat.com>
Date: Mon May 3 18:47:21 2010 -0400
Updated the list tag to deal with parent vs child filtering
diff --git a/java/code/src/com/redhat/rhn/frontend/taglibs/list/DataSetManipulator.java
b/java/code/src/com/redhat/rhn/frontend/taglibs/list/DataSetManipulator.java
index d5a7676..90ce809 100644
--- a/java/code/src/com/redhat/rhn/frontend/taglibs/list/DataSetManipulator.java
+++ b/java/code/src/com/redhat/rhn/frontend/taglibs/list/DataSetManipulator.java
@@ -62,6 +62,9 @@ public class DataSetManipulator {
private int unfilteredDataSize;
private boolean parentIsAnElement;
+ private boolean searchParent;
+ private boolean searchChild;
+
private String defaultSortAttribute;
private static final String IMG_FIRST = "/img/list-allbackward.gif";
private static final String IMG_FIRST_UNFOCUSED =
@@ -90,9 +93,15 @@ public class DataSetManipulator {
* @param parentIsElement true of the parent value
* in the list should be considered as an element
* this is useful for tree like data
+ * @param doSearchParent true if we want to search the parent value
+ * in the list when filtering.
+ * @param doSearchChild true if we want to search the child value
+ * in the list when filtering.
*/
public DataSetManipulator(int pageSizeIn, List datasetIn,
- HttpServletRequest requestIn, String listNameIn, boolean parentIsElement) {
+ HttpServletRequest requestIn, String listNameIn,
+ boolean parentIsElement, boolean doSearchParent,
+ boolean doSearchChild) {
pageSize = pageSizeIn;
dataset = datasetIn;
request = requestIn;
@@ -100,6 +109,8 @@ public class DataSetManipulator {
totalDataSetSize = dataset.size();
unfilteredDataSize = dataset.size();
parentIsAnElement = parentIsElement;
+ searchParent = doSearchParent;
+ searchChild = doSearchChild;
}
private List expand(List data) {
@@ -109,9 +120,9 @@ public class DataSetManipulator {
if (obj instanceof Expandable) {
Expandable ex = (Expandable) obj;
List children = ex.expand();
- if (filter != null) {
+ if (searchChild && filter != null) {
expanded.addAll(ListFilterHelper.filter(children,
- filter, filterBy, filterValue));
+ filter, filterBy, filterValue, searchParent, searchChild));
}
else {
expanded.addAll(children);
@@ -410,7 +421,8 @@ public class DataSetManipulator {
filterClass.setAttribute("value",
f.getClass().getCanonicalName());
ListTagUtil.write(context, filterClass.render());
- dataset = ListFilterHelper.filter(dataset, f, filterBy, filterValue);
+ dataset = ListFilterHelper.filter(dataset, f, filterBy, filterValue,
+ searchParent, searchChild);
totalDataSetSize = dataset.size();
}
}
diff --git a/java/code/src/com/redhat/rhn/frontend/taglibs/list/ListFilterHelper.java
b/java/code/src/com/redhat/rhn/frontend/taglibs/list/ListFilterHelper.java
index 8c2d41a..6efb977 100644
--- a/java/code/src/com/redhat/rhn/frontend/taglibs/list/ListFilterHelper.java
+++ b/java/code/src/com/redhat/rhn/frontend/taglibs/list/ListFilterHelper.java
@@ -39,10 +39,14 @@ public class ListFilterHelper {
* @param filter the filter to use
* @param filterBy which value to filter by in the bean
* @param filterValue the value to filter on
+ * @param searchParent true if we want to search the parent value
+ * in the list when filtering.
+ * @param searchChild true if we want to search the child value
+ * in the list when filtering.
* @return the filtered list
*/
public static List filter(List dataSet, ListFilter filter, String filterBy,
- String filterValue) {
+ String filterValue, boolean searchParent, boolean searchChild) {
String tmp = null;
try {
tmp = URLDecoder.decode(filterBy, "UTF-8");
@@ -74,14 +78,18 @@ public class ListFilterHelper {
Expandable parent = null;
for (Object object : dataSet) {
if (object instanceof Expandable) {
- parent = (Expandable) object;
- for (Object child : parent.expand()) {
- if (filter.filter(child, filterBy, filterValue)) {
- filteredData.add(parent);
- break;
+ if (searchParent && filter.filter(object, filterBy, filterValue))
{
+ filteredData.add(object);
+ }
+ if (searchChild) {
+ parent = (Expandable) object;
+ for (Object child : parent.expand()) {
+ if (filter.filter(child, filterBy, filterValue)) {
+ filteredData.add(parent);
+ break;
+ }
}
}
-
}
else if (filter.filter(object, filterBy, filterValue)) {
filteredData.add(object);
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 6c5a265..670d50c 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
@@ -84,7 +84,25 @@ public class ListTag extends BodyTagSupport {
private String title;
private boolean sortable;
private boolean parentIsElement;
+ private boolean searchParent = true;
+ private boolean searchChild;
+
+ /**
+ * @param searchParentIn The searchParent to set.
+ */
+ public void setSearchparent(String searchParentIn) {
+ searchParent = ListTagUtil.toBoolean(searchParentIn);
+ }
+
+
+ /**
+ * @param searchChildIn The searchChild to set.
+ */
+ public void setSearchchild(String searchChildIn) {
+ searchChild = ListTagUtil.toBoolean(searchChildIn);
+ }
+
/**
* method to let the list tag know
* that atleast one of its columns
@@ -587,7 +605,7 @@ public class ListTag extends BodyTagSupport {
setPageSize();
manip = new DataSetManipulator(pageSize, pageData,
(HttpServletRequest) pageContext.getRequest(),
- getUniqueName(), isParentAnElement());
+ getUniqueName(), isParentAnElement(), searchParent, searchChild);
int retval = BodyTagSupport.EVAL_BODY_INCLUDE;
emitId();
@@ -678,6 +696,8 @@ public class ListTag extends BodyTagSupport {
title = null;
sortable = false;
parentIsElement = true;
+ searchParent = true;
+ searchChild = false;
super.release();
}
diff --git a/java/code/src/com/redhat/rhn/frontend/taglibs/rhn-list.tld
b/java/code/src/com/redhat/rhn/frontend/taglibs/rhn-list.tld
index 16abb68..d4b31a2 100644
--- a/java/code/src/com/redhat/rhn/frontend/taglibs/rhn-list.tld
+++ b/java/code/src/com/redhat/rhn/frontend/taglibs/rhn-list.tld
@@ -91,7 +91,16 @@
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
-
+ <attribute>
+ <name>searchparent</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>searchchild</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
<attribute>
<name>reflink</name>
<required>false</required>
diff --git a/java/code/webapp/WEB-INF/pages/systems/duplicate/duplicateIPList.jsp
b/java/code/webapp/WEB-INF/pages/systems/duplicate/duplicateIPList.jsp
index 1c4fa92..7ac9b2f 100644
--- a/java/code/webapp/WEB-INF/pages/systems/duplicate/duplicateIPList.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/duplicate/duplicateIPList.jsp
@@ -23,6 +23,8 @@
<rl:list
emptykey="nosystems.message"
parentiselement = "false"
+ searchparent="true"
+ searchchild="false"
<rl:rowrenderer name="ExpandableRowRenderer" />
@@ -44,7 +46,7 @@
<!-- Name Column -->
- <rl:column headerkey="systemlist.jsp.system" filterattr="id">
+ <rl:column headerkey="systemlist.jsp.system"
filterattr="key">
<rl:expandable rendericon="true">${current.key}
<em>(${rl:countChildren(current)} systems)</em> </rl:expandable>
<rl:non-expandable
rendericon="true">${current.id}</rl:non-expandable>