? src/test/java/org/displaytag/jsptests/ExternalSortTest.java ? src/test/java/org/displaytag/jsptests/PartialListMissingSizeTest.java ? src/test/java/org/displaytag/jsptests/PartialListSortFullTest.java ? src/test/java/org/displaytag/jsptests/PartialListTest.java ? src/test/resources/el/externalSort.jsp ? src/test/resources/el/partialList.jsp ? src/test/resources/el/partialListMissingSize.jsp ? src/test/resources/el/partialListSortFull.jsp ? src/test/resources/standard/externalSort.jsp ? src/test/resources/standard/partialList.jsp ? src/test/resources/standard/partialListMissingSize.jsp ? src/test/resources/standard/partialListSortFull.jsp Index: src/main/java/org/displaytag/messages.properties =================================================================== RCS file: /cvsroot/displaytag/displaytag/src/main/java/org/displaytag/messages.properties,v retrieving revision 1.11 diff -u -p -r1.11 messages.properties --- src/main/java/org/displaytag/messages.properties 4 Jun 2005 18:58:56 -0000 1.11 +++ src/main/java/org/displaytag/messages.properties 4 Jul 2005 20:54:34 -0000 @@ -2,6 +2,8 @@ ExportException.msg=Unable to reset resp Be sure that no other jsp tags are used before display:table or refer to the displaytag documentation on how to configure the export filter (requires j2ee 1.3). InvalidTagAttributeValueException.msg=Invalid value for attribute "{0}" value="{1}" +InvalidTagAttributeValueExceptionWhen.msg=Invalid value for attribute "{0}" value="{1}" when "{2}"="{3}" +InvalidTypeException.msg=Object referenced by attribute "{0}" must be of type {1} TagStructureException.msg=Tag "{0}" should ne nested in "{1}" Index: src/main/java/org/displaytag/model/HeaderCell.java =================================================================== RCS file: /cvsroot/displaytag/displaytag/src/main/java/org/displaytag/model/HeaderCell.java,v retrieving revision 1.20 diff -u -p -r1.20 HeaderCell.java --- src/main/java/org/displaytag/model/HeaderCell.java 4 Jun 2005 18:58:53 -0000 1.20 +++ src/main/java/org/displaytag/model/HeaderCell.java 3 Jul 2005 16:54:45 -0000 @@ -73,6 +73,11 @@ public class HeaderCell private boolean sortable; /** + * Name given to the server when sorting this column + */ + private String sortName; + + /** * ColumnDecorator. */ private ColumnDecorator columnDecorator; @@ -332,6 +337,24 @@ public class HeaderCell } /** + * Get name given to server for sorting this column + * @return name given to server for sorting this column + */ + public String getSortName() + { + return sortName; + } + + /** + * Set name given to server for sorting this column + * @param sortName name given to server for sorting this column + */ + public void setSortName(String sortName) + { + this.sortName = sortName; + } + + /** * Gets the column title. * @return the column title. If no title is specified the capitalized bean property name is returned */ Index: src/main/java/org/displaytag/model/TableModel.java =================================================================== RCS file: /cvsroot/displaytag/displaytag/src/main/java/org/displaytag/model/TableModel.java,v retrieving revision 1.18 diff -u -p -r1.18 TableModel.java --- src/main/java/org/displaytag/model/TableModel.java 6 Jan 2005 19:53:02 -0000 1.18 +++ src/main/java/org/displaytag/model/TableModel.java 3 Jul 2005 16:55:11 -0000 @@ -52,6 +52,11 @@ public class TableModel private List rowListPage; /** + * Name of the column currently sorted (only used when sort=external) + */ + private String sortedColumnName = null; + + /** * sort order = ascending? */ private boolean sortOrderAscending = true; @@ -92,6 +97,11 @@ public class TableModel private String encoding; /** + * Are we sorting locally? (Default True) + */ + private boolean localSort = true; + + /** * Constructor for TableModel. * @param tableProperties table properties * @param charEncoding response encoding @@ -105,6 +115,22 @@ public class TableModel } /** + * Sets whether the table performs local in memory sorting of the data + * @param localSort + */ + public void setLocalSort(boolean localSort) { + this.localSort = localSort; + } + + /** + * + * @return sorting in local memory + */ + public boolean isLocalSort() { + return localSort; + } + + /** * Sets the starting offset for elements in the viewable list. * @param offset The page offset to set. */ @@ -156,6 +182,24 @@ public class TableModel } /** + * Name of the currently sorted column + * @return name of the currently sorted column + */ + public String getSortedColumnName() + { + return sortedColumnName; + } + + /** + * sets the name of the currently sorted column + * @param sortedColumnName + */ + public void setSortedColumnName(String sortedColumnName) + { + this.sortedColumnName = sortedColumnName; + } + + /** * sets the sort full table property. If true the full list is sorted, if false sorting is applied only to the * displayed sublist. * @param sortFull boolean @@ -283,9 +327,20 @@ public class TableModel */ public void addColumnHeader(HeaderCell headerCell) { - if (this.sortedColumn == this.headerCellList.size()) + if (this.sortedColumnName == null) + { + if (this.sortedColumn == this.headerCellList.size()) + { + headerCell.setAlreadySorted(); + } + } + else { + // the sorted parameter was a string so try and find that column name and set it as sorted + if (this.sortedColumnName.equals(headerCell.getSortName())) + { headerCell.setAlreadySorted(); + } } headerCell.setColumnNumber(this.headerCellList.size()); Index: src/main/java/org/displaytag/pagination/SmartListHelper.java =================================================================== RCS file: /cvsroot/displaytag/displaytag/src/main/java/org/displaytag/pagination/SmartListHelper.java,v retrieving revision 1.17 diff -u -p -r1.17 SmartListHelper.java --- src/main/java/org/displaytag/pagination/SmartListHelper.java 30 Dec 2004 12:31:55 -0000 1.17 +++ src/main/java/org/displaytag/pagination/SmartListHelper.java 4 Jul 2005 20:11:41 -0000 @@ -63,6 +63,10 @@ public class SmartListHelper private int pageCount; /** + * the list we hold is only part of the full dataset + */ + private boolean partialList; + /** * index of current page. */ private int currentPage; @@ -80,7 +84,7 @@ public class SmartListHelper * @param itemsInPage number of items in a page (int > 0) * @param tableProperties TableProperties */ - public SmartListHelper(List list, int fullSize, int itemsInPage, TableProperties tableProperties) + public SmartListHelper(List list, int fullSize, int itemsInPage, TableProperties tableProperties, boolean partialList) { if (log.isDebugEnabled()) { @@ -94,6 +98,7 @@ public class SmartListHelper this.fullListSize = fullSize; this.pageCount = computedPageCount(); this.currentPage = 1; + this.partialList = partialList; } /** @@ -139,7 +144,14 @@ public class SmartListHelper */ protected int getFirstIndexForPage(int pageNumber) { - return (pageNumber - 1) * this.pageSize; + if (this.partialList) + { + return 0; + } + else + { + return (pageNumber - 1) * this.pageSize; + } } /** @@ -149,12 +161,19 @@ public class SmartListHelper */ protected int getLastIndexForPage(int pageNumber) { + if (this.partialList) + { + // return the min of pageSize or list size on the off chance they gave us more data than pageSize allows + return Math.min(this.pageSize - 1, this.fullList.size() - 1); + } + else + { + int firstIndex = getFirstIndexForPage(pageNumber); + int pageIndex = this.pageSize - 1; + int lastIndex = this.fullListSize - 1; - int firstIndex = getFirstIndexForPage(pageNumber); - int pageIndex = this.pageSize - 1; - int lastIndex = this.fullListSize - 1; - - return Math.min(firstIndex + pageIndex, lastIndex); + return Math.min(firstIndex + pageIndex, lastIndex); + } } /** @@ -347,6 +366,7 @@ public class SmartListHelper .append("pageCount", this.pageCount) //$NON-NLS-1$ .append("properties", this.properties) //$NON-NLS-1$ .append("currentPage", this.currentPage) //$NON-NLS-1$ + .append("partialList", this.partialList) .toString(); } } \ No newline at end of file Index: src/main/java/org/displaytag/tags/ColumnTag.java =================================================================== RCS file: /cvsroot/displaytag/displaytag/src/main/java/org/displaytag/tags/ColumnTag.java,v retrieving revision 1.56 diff -u -p -r1.56 ColumnTag.java --- src/main/java/org/displaytag/tags/ColumnTag.java 4 Jun 2005 18:58:54 -0000 1.56 +++ src/main/java/org/displaytag/tags/ColumnTag.java 3 Jul 2005 16:55:36 -0000 @@ -103,6 +103,11 @@ public class ColumnTag extends BodyTagSu */ private boolean sortable; + /** + * Name given to the server when sorting this column + */ + private String sortName; + /** * Defalt sort order for this column. */ @@ -607,6 +612,15 @@ public class ColumnTag extends BodyTagSu } /** + * sets the name given to the server when sorting this column + * @param sortName name given to the server to sort this column + */ + public void setSortName(String sortName) + { + this.sortName = sortName; + } + + /** * sets the sorting order for the sorted column. * @param value "ascending" or "descending" * @throws InvalidTagAttributeValueException if value is not one of "ascending" or "descending" @@ -722,6 +736,7 @@ public class ColumnTag extends BodyTagSu headerCell.setComparator(this.comparator); headerCell.setColumnValueClass(valueClass); headerCell.setDefaultSortOrder(this.defaultorder); + headerCell.setSortName(this.sortName); // href and parameter, create link if (this.href != null) @@ -821,6 +836,7 @@ public class ColumnTag extends BodyTagSu this.paramScope = null; this.property = null; this.sortable = false; + this.sortName = null; this.supportedMedia = null; this.title = null; this.titleKey = null; Index: src/main/java/org/displaytag/tags/ColumnTagBeanInfo.java =================================================================== RCS file: /cvsroot/displaytag/displaytag/src/main/java/org/displaytag/tags/ColumnTagBeanInfo.java,v retrieving revision 1.13 diff -u -p -r1.13 ColumnTagBeanInfo.java --- src/main/java/org/displaytag/tags/ColumnTagBeanInfo.java 4 Jun 2005 18:58:55 -0000 1.13 +++ src/main/java/org/displaytag/tags/ColumnTagBeanInfo.java 2 Jul 2005 20:54:44 -0000 @@ -67,6 +67,8 @@ public class ColumnTagBeanInfo extends S ColumnTag.class, null, "setProperty")); //$NON-NLS-1$ proplist.add(new PropertyDescriptor("sortable", //$NON-NLS-1$ ColumnTag.class, null, "setSortable")); //$NON-NLS-1$ + proplist.add(new PropertyDescriptor("sortName", //$NON-NLS-1$ + ColumnTag.class, null, "setSortName")); //$NON-NLS-1$ proplist.add(new PropertyDescriptor("style", //$NON-NLS-1$ ColumnTag.class, null, "setStyle")); //$NON-NLS-1$ proplist.add(new PropertyDescriptor("title", //$NON-NLS-1$ Index: src/main/java/org/displaytag/tags/TableTag.java =================================================================== RCS file: /cvsroot/displaytag/displaytag/src/main/java/org/displaytag/tags/TableTag.java,v retrieving revision 1.101 diff -u -p -r1.101 TableTag.java --- src/main/java/org/displaytag/tags/TableTag.java 4 Jun 2005 18:58:55 -0000 1.101 +++ src/main/java/org/displaytag/tags/TableTag.java 4 Jul 2005 21:00:34 -0000 @@ -22,14 +22,12 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Map; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspTagException; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.PageContext; - import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.collections.IteratorUtils; import org.apache.commons.lang.StringUtils; @@ -68,6 +66,7 @@ import org.displaytag.util.ParamEncoder; import org.displaytag.util.RequestHelper; import org.displaytag.util.RequestHelperFactory; import org.displaytag.util.TagConstants; +import org.displaytag.Messages; /** @@ -161,6 +160,11 @@ public class TableTag extends HtmlTableT private int pagesize; /** + * list contains only viewable data + */ + private boolean partialList; + + /** * add export links. */ private boolean export; @@ -171,11 +175,26 @@ public class TableTag extends HtmlTableT private int offset; /** + * Integer containing total size of the data displaytag is paginating + */ + private Object size; + + /** + * Name of the Integer in some scope containing the size of the data displaytag is paginating + */ + private String sizeObjectName = null; + + /** * sort the full list? */ private Boolean sortFullTable; /** + * are we doing any local sorting? (defaults to True) + */ + private Boolean localSort = Boolean.TRUE; + + /** * Request uri. */ private String requestUri; @@ -341,6 +360,31 @@ public class TableTag extends HtmlTableT } /** + * set the Integer containing the total size of the data displaytag is paginating + * @param size Integer containing the total size of the data + */ + public void setSize(Object size) + { + if (size instanceof String) + { + this.sizeObjectName = (String) size; + } + else + { + this.size = size; + } + } + + /** + * set the name of the Integer in some scope containing the total size of the data to be paginated + * @param sizeObjectName name of the Integer containing the total size of the data to be paginated + */ + public void setSizeObjectName(String sizeObjectName) + { + this.sizeObjectName = sizeObjectName; + } + + /** * setter for the "sort" attribute. * @param value "page" (sort a single page) or "list" (sort the full list) * @throws InvalidTagAttributeValueException if value is not "page" or "list" @@ -355,6 +399,10 @@ public class TableTag extends HtmlTableT { this.sortFullTable = Boolean.TRUE; } + else if (TableTagParameters.SORT_AMOUNT_EXTERNAL.equals(value)) + { + this.localSort = Boolean.FALSE; + } else { throw new InvalidTagAttributeValueException(getClass(), "sort", value); //$NON-NLS-1$ @@ -517,6 +565,16 @@ public class TableTag extends HtmlTableT } /** + * tells display tag that the values contained in the list are the viewable data only, there may be more + * results not given to displaytag + * @param partialList boolean value telling us there may be more data not given to displaytag + */ + public void setPartialList(boolean partialList) + { + this.partialList = partialList; + } + + /** * Setter for the list offset attribute. * @param value String */ @@ -771,7 +829,7 @@ public class TableTag extends HtmlTableT * @throws ObjectLookupException for problems in evaluating the expression in the "name" attribute * @throws FactoryInstantiationException for problems in instantiating a RequestHelperFactory */ - private void initParameters() throws ObjectLookupException, FactoryInstantiationException + private void initParameters() throws JspTagException, FactoryInstantiationException { if (rhf == null) { @@ -779,6 +837,21 @@ public class TableTag extends HtmlTableT rhf = this.properties.getRequestHelperFactoryInstance(); } + // set the table model to perform in memory local sorting + if (this.localSort != null) + { + this.tableModel.setLocalSort(this.localSort.booleanValue()); + } + if (this.partialList) + { + // if we don't have all the data then ensure they aren't trying to sort the whole list + if (Boolean.TRUE.equals(this.sortFullTable)) + { + throw new JspTagException(Messages.getString("InvalidTagAttributeValueExceptionWhen.msg", + new Object[]{"sort", "full", "partialList", "true"})); + } + } + RequestHelper requestHelper = rhf.getRequestHelperInstance(this.pageContext); initHref(requestHelper); @@ -786,9 +859,36 @@ public class TableTag extends HtmlTableT Integer pageNumberParameter = requestHelper.getIntParameter(encodeParameter(TableTagParameters.PARAMETER_PAGE)); this.pageNumber = (pageNumberParameter == null) ? 1 : pageNumberParameter.intValue(); - Integer sortColumnParameter = requestHelper.getIntParameter(encodeParameter(TableTagParameters.PARAMETER_SORT)); - int sortColumn = (sortColumnParameter == null) ? this.defaultSortedColumn : sortColumnParameter.intValue(); - this.tableModel.setSortedColumnNumber(sortColumn); + int sortColumn = -1; + if (!this.tableModel.isLocalSort()) + { + // our sort column parameter may be a string, check that first + String sortColumnName = requestHelper.getParameter(encodeParameter(TableTagParameters.PARAMETER_SORT)); + + if (sortColumnName == null) + { + this.tableModel.setSortedColumnNumber(this.defaultSortedColumn); + } + else + { + // try parsing this value to see if its an integer + try + { + sortColumn = Integer.parseInt(sortColumnName); + this.tableModel.setSortedColumnNumber(sortColumn); // its an int set as normal + } + catch (Throwable t) + { + this.tableModel.setSortedColumnName(sortColumnName); // its a string, set as string + } + } + } + else + { + Integer sortColumnParameter = requestHelper.getIntParameter(encodeParameter(TableTagParameters.PARAMETER_SORT)); + sortColumn = (sortColumnParameter == null) ? this.defaultSortedColumn : sortColumnParameter.intValue(); + this.tableModel.setSortedColumnNumber(sortColumn); + } // default value boolean finalSortFull = this.properties.getSortFullList(); @@ -834,11 +934,32 @@ public class TableTag extends HtmlTableT this.list = this.listAttribute; } + // if we are doing partialLists then ensure we have our size object + if (this.partialList) + { + if ((this.sizeObjectName == null) && (this.size == null)) + { + } + if (this.sizeObjectName != null) + { + // retrieve the object from scope + this.size = evaluateExpression(this.sizeObjectName); + } + if (size == null) + { + throw new JspTagException(Messages.getString("MissingAttributeException.msg", new Object[]{"size"})); + } + else if (!(size instanceof Integer)) + { + throw new JspTagException(Messages.getString("InvalidTypeException.msg", new Object[]{"size", "Integer"})); + } + } + // do we really need to skip any row? - boolean wishOptimizedIteration = (this.pagesize > 0 // we are paging + boolean wishOptimizedIteration = ((this.pagesize > 0 // we are paging || this.offset > 0 // or we are skipping some records using offset || this.length > 0 // or we are limiting the records using length - ); + ) && !partialList); // only optimize if we have the full list // can we actually skip any row? if (wishOptimizedIteration && (this.list instanceof Collection) // we need to know the size @@ -1066,9 +1187,12 @@ public class TableTag extends HtmlTableT // Figure out how we should sort this data, typically we just sort // the data being shown, but the programmer can override this behavior - if (!this.tableModel.isSortFullTable()) + if (this.tableModel.isLocalSort()) { + if (!this.tableModel.isSortFullTable()) { this.tableModel.sortPageList(); + } + } // Get the data back in the representation that the user is after, do they want HTML/XML/CSV/EXCEL/etc... @@ -1363,10 +1487,12 @@ public class TableTag extends HtmlTableT // things if needed before we ask for the viewable part. (this is a bad place for this, this should be // refactored and moved somewhere else). - if (this.tableModel.isSortFullTable()) + if (this.tableModel.isLocalSort()) { + if (this.tableModel.isSortFullTable()) { // Sort the total list... this.tableModel.sortFullList(); + } } Object originalData = this.tableModel.getRowListFull(); @@ -1380,7 +1506,8 @@ public class TableTag extends HtmlTableT // SmartListHelper to figure out what page they are after, etc... if (this.pagesize > 0) { - this.listHelper = new SmartListHelper(fullList, fullList.size(), this.pagesize, this.properties); + this.listHelper = new SmartListHelper(fullList, (this.partialList)? ((Integer)size).intValue() : + fullList.size(), this.pagesize, this.properties, this.partialList); this.listHelper.setCurrentPage(this.pageNumber); pageOffset = this.listHelper.getFirstIndexForCurrentPage(); fullList = this.listHelper.getListForCurrentPage(); @@ -1571,7 +1698,14 @@ public class TableTag extends HtmlTableT Href href = new Href(this.baseHref); // add column number as link parameter - href.addParameter(encodeParameter(TableTagParameters.PARAMETER_SORT), headerCell.getColumnNumber()); + if (!this.localSort.booleanValue() && (headerCell.getSortName() != null)) + { + href.addParameter(encodeParameter(TableTagParameters.PARAMETER_SORT), headerCell.getSortName()); + } + else + { + href.addParameter(encodeParameter(TableTagParameters.PARAMETER_SORT), headerCell.getColumnNumber()); + } boolean nowOrderAscending = true; @@ -1589,7 +1723,8 @@ public class TableTag extends HtmlTableT href.addParameter(encodeParameter(TableTagParameters.PARAMETER_ORDER), sortOrderParam); // If user want to sort the full table I need to reset the page number. - if (this.tableModel.isSortFullTable()) + // or if we aren't sorting locally we need to reset the page as well. + if (this.tableModel.isSortFullTable() || !this.tableModel.isLocalSort()) { href.addParameter(encodeParameter(TableTagParameters.PARAMETER_PAGE), 1); } @@ -1876,9 +2011,11 @@ public class TableTag extends HtmlTableT this.export = false; this.length = 0; this.listAttribute = null; + this.localSort = null; this.name = null; this.offset = 0; this.pagesize = 0; + this.partialList = false; this.property = null; this.requestUri = null; this.dontAppendContext = false; Index: src/main/java/org/displaytag/tags/TableTagBeanInfo.java =================================================================== RCS file: /cvsroot/displaytag/displaytag/src/main/java/org/displaytag/tags/TableTagBeanInfo.java,v retrieving revision 1.14 diff -u -p -r1.14 TableTagBeanInfo.java --- src/main/java/org/displaytag/tags/TableTagBeanInfo.java 6 Jan 2005 19:53:03 -0000 1.14 +++ src/main/java/org/displaytag/tags/TableTagBeanInfo.java 4 Jul 2005 22:31:27 -0000 @@ -58,6 +58,8 @@ public class TableTagBeanInfo extends Si TableTag.class, null, "setOffset")); //$NON-NLS-1$ proplist.add(new PropertyDescriptor("pagesize", //$NON-NLS-1$ TableTag.class, null, "setPagesize")); //$NON-NLS-1$ + proplist.add(new PropertyDescriptor("partialList", //$NON-NLS-1$ + TableTag.class, null, "setPartialList")); //$NON-NLS-1$ proplist.add(new PropertyDescriptor("requestURI", //$NON-NLS-1$ TableTag.class, null, "setRequestURI")); //$NON-NLS-1$ proplist.add(new PropertyDescriptor("requestURIcontext", //$NON-NLS-1$ @@ -101,12 +103,16 @@ public class TableTagBeanInfo extends Si // jsp >= 1.2 proplist.add(new PropertyDescriptor("name", //$NON-NLS-1$ TableTag.class, null, "setName")); //$NON-NLS-1$ + proplist.add(new PropertyDescriptor("size", //$NON-NLS-1$ + TableTag.class, null, "setSize")); //$NON-NLS-1$ } catch (ClassNotFoundException e) { // jsp 1.1, can't use a setter with an Object parameter proplist.add(new PropertyDescriptor("name", //$NON-NLS-1$ TableTag.class, null, "setNameString")); //$NON-NLS-1$ + proplist.add(new PropertyDescriptor("size", //$NON-NLS-1$ + TableTag.class, null, "setSizeObjectName")); //$NON-NLS-1$ } } Index: src/main/java/org/displaytag/tags/TableTagParameters.java =================================================================== RCS file: /cvsroot/displaytag/displaytag/src/main/java/org/displaytag/tags/TableTagParameters.java,v retrieving revision 1.16 diff -u -p -r1.16 TableTagParameters.java --- src/main/java/org/displaytag/tags/TableTagParameters.java 13 Nov 2004 15:10:57 -0000 1.16 +++ src/main/java/org/displaytag/tags/TableTagParameters.java 3 Jul 2005 16:06:25 -0000 @@ -56,6 +56,11 @@ public final class TableTagParameters public static final String SORT_AMOUNT_LIST = "list"; //$NON-NLS-1$ /** + * let the server handle the sorting + */ + public static final String SORT_AMOUNT_EXTERNAL = "external"; //$NON-NLS-1$ + + /** * css class added to empty tables. */ public static final String CSS_EMPTYLIST = "empty"; Index: src/main/java/org/displaytag/tags/el/ELColumnTag.java =================================================================== RCS file: /cvsroot/displaytag/displaytag/src/main/java/org/displaytag/tags/el/ELColumnTag.java,v retrieving revision 1.13 diff -u -p -r1.13 ELColumnTag.java --- src/main/java/org/displaytag/tags/el/ELColumnTag.java 4 Jun 2005 18:58:57 -0000 1.13 +++ src/main/java/org/displaytag/tags/el/ELColumnTag.java 2 Jul 2005 21:35:17 -0000 @@ -129,6 +129,11 @@ public class ELColumnTag extends org.dis private String sortableExpr; /** + * Expression for the "sortName" tag attribute. + */ + private String sortNameExpr; + + /** * Expression for the "sortProperty" tag attribute. */ private String sortPropertyExpr; @@ -292,6 +297,16 @@ public class ELColumnTag extends org.dis } /** + * @param value EL expression for attribute value + * @see org.displaytag.tags.ColumnTag#setSortName(java.lang.String) + */ + public void setSortName(String value) + { + sortNameExpr = value; + } + + + /** * @see org.displaytag.tags.ColumnTag#setTitle(java.lang.String) * @param value EL expression for attribute value */ @@ -335,7 +350,7 @@ public class ELColumnTag extends org.dis { defaultorderExpr = value; } - + /** * @see javax.servlet.jsp.tagext.Tag#doStartTag() */ @@ -415,6 +430,10 @@ public class ELColumnTag extends org.dis { super.setSortable(eval.evalBoolean("sortable", sortableExpr)); //$NON-NLS-1$ } + if (sortNameExpr != null) + { + super.setSortName(eval.evalString("sortName", sortNameExpr)); //$NON-NLS-1$ + } if (styleExpr != null) { super.setStyle(eval.evalString("style", styleExpr)); //$NON-NLS-1$ Index: src/main/java/org/displaytag/tags/el/ELColumnTagBeanInfo.java =================================================================== RCS file: /cvsroot/displaytag/displaytag/src/main/java/org/displaytag/tags/el/ELColumnTagBeanInfo.java,v retrieving revision 1.9 diff -u -p -r1.9 ELColumnTagBeanInfo.java --- src/main/java/org/displaytag/tags/el/ELColumnTagBeanInfo.java 4 Jun 2005 18:58:57 -0000 1.9 +++ src/main/java/org/displaytag/tags/el/ELColumnTagBeanInfo.java 3 Jul 2005 16:56:34 -0000 @@ -17,8 +17,6 @@ import java.beans.SimpleBeanInfo; import java.util.ArrayList; import java.util.List; -import org.displaytag.tags.ColumnTag; - /** * BeanInfo descriptor for the ELColumnTag class. Unevaluated EL expression has to be kept separately @@ -71,6 +69,8 @@ public class ELColumnTagBeanInfo extends ELColumnTag.class, null, "setProperty")); //$NON-NLS-1$ proplist.add(new PropertyDescriptor("sortable", //$NON-NLS-1$ ELColumnTag.class, null, "setSortable")); //$NON-NLS-1$ + proplist.add(new PropertyDescriptor("sortName", //$NON-NLS-1$ + ELColumnTag.class, null, "setSortName")); //$NON-NLS-1$ proplist.add(new PropertyDescriptor("style", //$NON-NLS-1$ ELColumnTag.class, null, "setStyle")); //$NON-NLS-1$ proplist.add(new PropertyDescriptor("total", //$NON-NLS-1$ Index: src/main/java/org/displaytag/tags/el/ELTableTag.java =================================================================== RCS file: /cvsroot/displaytag/displaytag/src/main/java/org/displaytag/tags/el/ELTableTag.java,v retrieving revision 1.14 diff -u -p -r1.14 ELTableTag.java --- src/main/java/org/displaytag/tags/el/ELTableTag.java 20 Nov 2004 12:44:38 -0000 1.14 +++ src/main/java/org/displaytag/tags/el/ELTableTag.java 4 Jul 2005 15:43:26 -0000 @@ -89,6 +89,11 @@ public class ELTableTag extends org.disp private String pagesizeExpr; /** + * Expression for the "partialList" tag attribute. + */ + private String partialListExpr; + + /** * Expression for the "requestURI" tag attribute. */ private String requestURIExpr; @@ -104,6 +109,11 @@ public class ELTableTag extends org.disp private String rulesExpr; /** + * Expression for the "size" tag attribute + */ + private String sizeExpr; + + /** * Expression for the "sort" tag attribute. */ private String sortExpr; @@ -277,6 +287,14 @@ public class ELTableTag extends org.disp } /** + * @param value EL expression for attribute value + * @see org.displaytag.tags.TableTag#setRules(java.lang.String) + */ + public void setSize(String value) + { + sizeExpr = value; + } + /** * @see org.displaytag.tags.TableTag#setSort(java.lang.String) * @param value EL expression for attribute value */ @@ -399,6 +417,10 @@ public class ELTableTag extends org.disp { super.setPagesize(eval.evalInt("pagesize", pagesizeExpr)); //$NON-NLS-1$ } + if (partialListExpr != null) + { + super.setPartialList(eval.evalBoolean("partialList", partialListExpr)); //$NON-NLS-1$ + } if (requestURIExpr != null) { super.setRequestURI(eval.evalString("requestURI", requestURIExpr)); //$NON-NLS-1$ @@ -411,6 +433,21 @@ public class ELTableTag extends org.disp { super.setRules(eval.evalString("rules", rulesExpr)); //$NON-NLS-1$ } + if (sizeExpr != null) + { + Object source = eval.eval("size", sizeExpr, Object.class); //$NON-NLS-1$ + + // be more user-friendly: accept both EL and legacy expressions + if (source instanceof String) + { + super.setSizeObjectName((String) source); + } + else + { + // evaluate size only once, so assign it to the "size" object + super.setSize(source); + } + } if (sortExpr != null) { super.setSort(eval.evalString("sort", sortExpr)); //$NON-NLS-1$ @@ -443,9 +480,11 @@ public class ELTableTag extends org.disp this.nameExpr = null; this.offsetExpr = null; this.pagesizeExpr = null; + this.partialListExpr = null; this.requestURIExpr = null; this.requestURIcontextExpr = null; this.rulesExpr = null; + this.sizeExpr = null; this.sortExpr = null; this.styleExpr = null; this.summaryExpr = null; Index: src/main/java/org/displaytag/tags/el/ELTableTagBeanInfo.java =================================================================== RCS file: /cvsroot/displaytag/displaytag/src/main/java/org/displaytag/tags/el/ELTableTagBeanInfo.java,v retrieving revision 1.9 diff -u -p -r1.9 ELTableTagBeanInfo.java --- src/main/java/org/displaytag/tags/el/ELTableTagBeanInfo.java 4 Jan 2005 22:34:54 -0000 1.9 +++ src/main/java/org/displaytag/tags/el/ELTableTagBeanInfo.java 4 Jul 2005 22:31:59 -0000 @@ -63,12 +63,16 @@ public class ELTableTagBeanInfo extends ELTableTag.class, null, "setOffset")); //$NON-NLS-1$ proplist.add(new PropertyDescriptor("pagesize", //$NON-NLS-1$ ELTableTag.class, null, "setPagesize")); //$NON-NLS-1$ + proplist.add(new PropertyDescriptor("partialList", //$NON-NLS-1$ + ELTableTag.class, null, "setPartialList")); //$NON-NLS-1$ proplist.add(new PropertyDescriptor("requestURI", //$NON-NLS-1$ ELTableTag.class, null, "setRequestURI")); //$NON-NLS-1$ proplist.add(new PropertyDescriptor("requestURIcontext", //$NON-NLS-1$ ELTableTag.class, null, "setRequestURIcontext")); //$NON-NLS-1$ proplist.add(new PropertyDescriptor("rules", //$NON-NLS-1$ ELTableTag.class, null, "setRules")); //$NON-NLS-1$ + proplist.add(new PropertyDescriptor("size", //$NON-NLS-1$ + ELTableTag.class, null, "setSize")); //$NON-NLS-1$ proplist.add(new PropertyDescriptor("sort", //$NON-NLS-1$ ELTableTag.class, null, "setSort")); //$NON-NLS-1$ proplist.add(new PropertyDescriptor("style", //$NON-NLS-1$ Index: src/main/resources/META-INF/displaytag-el.tld =================================================================== RCS file: /cvsroot/displaytag/displaytag/src/main/resources/META-INF/displaytag-el.tld,v retrieving revision 1.1 diff -u -p -r1.1 displaytag-el.tld --- src/main/resources/META-INF/displaytag-el.tld 4 Jun 2005 18:58:53 -0000 1.1 +++ src/main/resources/META-INF/displaytag-el.tld 4 Jul 2005 22:24:02 -0000 @@ -182,7 +182,8 @@ false true - Use 'page' if you want to sort only visible records, or 'list' if you want to sort the full list + Use 'page' if you want to sort only visible records, or 'list' if you want to sort the full list, or 'external' + if the data is sorted outside displaytag. @@ -202,6 +203,23 @@ The default order for the sorted column. Valid values are "ascending" (default) or "descending" + + partialList + false + true + boolean + enable/disable partialLists. Valid values are true or false + + + size + false + true + + Used only when partialList=true. Reference to the Integer object containing the size of the total dataset. + Can be an expression like requestScope.object.property. In the EL version of the taglibrary this must be + an EL expression which points to the source object. + + @@ -472,6 +490,17 @@ specified for the entire table, then this decorator will decorate that decorator. + + sortName + false + true + java.lang.String + + Used with sort="external", the name that should be given to the server to sort this column. + IE if sortName="buzz", then the href for this column to sort will have a parameter d-(encodedId)-s=buzz. + If sortName is ommitted the value for the sort param will default to the column number. + + setProperty Index: src/main/resources/META-INF/displaytag.tld =================================================================== RCS file: /cvsroot/displaytag/displaytag/src/main/resources/META-INF/displaytag.tld,v retrieving revision 1.1 diff -u -p -r1.1 displaytag.tld --- src/main/resources/META-INF/displaytag.tld 4 Jun 2005 18:58:53 -0000 1.1 +++ src/main/resources/META-INF/displaytag.tld 4 Jul 2005 22:24:02 -0000 @@ -242,7 +242,8 @@ true java.lang.String - Use 'page' if you want to sort only visible records, or 'list' if you want to sort the full list + Use 'page' if you want to sort only visible records, or 'list' if you want to sort the full list, or 'external' + if the data is sorted outside displaytag. @@ -263,6 +264,23 @@ The default order for the sorted column. Valid values are "ascending" (default) or "descending" + + partialList + false + true + boolean + enable/disable partialLists. Valid values are true or false + + + size + false + true + + Used only when partialList=true. Reference to the Integer object containing the size of the total dataset. + Can be an expression like requestScope.object.property. In the EL version of the taglibrary this must be + an EL expression which points to the source object. + + @@ -588,6 +606,17 @@ specified for the entire table, then this decorator will decorate that decorator. + + sortName + false + true + java.lang.String + + Used with sort="external", the name that should be given to the server to sort this column. + IE if sortName="buzz", then the href for this column to sort will have a parameter d-(encodedId)-s=buzz. + If sortName is ommitted the value for the sort param will default to the column number. + + setProperty Index: src/test/java/org/displaytag/util/ToStringTest.java =================================================================== RCS file: /cvsroot/displaytag/displaytag/src/test/java/org/displaytag/util/ToStringTest.java,v retrieving revision 1.2 diff -u -p -r1.2 ToStringTest.java --- src/test/java/org/displaytag/util/ToStringTest.java 9 Nov 2004 19:04:15 -0000 1.2 +++ src/test/java/org/displaytag/util/ToStringTest.java 4 Jul 2005 17:09:53 -0000 @@ -50,7 +50,7 @@ public class ToStringTest extends TestCa */ public void testSmartListHelper() { - checkToString(new SmartListHelper(new ArrayList(), 100, 10, TableProperties.getInstance(null))); + checkToString(new SmartListHelper(new ArrayList(), 100, 10, TableProperties.getInstance(null), false)); } /**