1 15 package org.apache.tapestry.vlib.components; 16 17 import org.apache.tapestry.BaseComponent; 18 import org.apache.tapestry.IActionListener; 19 import org.apache.tapestry.IRequestCycle; 20 import org.apache.tapestry.Tapestry; 21 import org.apache.tapestry.vlib.ejb.SortColumn; 22 23 31 32 public abstract class ColumnSorter extends BaseComponent 33 { 34 public abstract SortColumn getSortColumn(); 35 36 public abstract SortColumn getSelected(); 37 public abstract void setSelected(SortColumn selected); 38 39 public abstract boolean isDescending(); 40 public abstract void setDescending(boolean descending); 41 42 public abstract IActionListener getListener(); 43 44 public void handleClick(IRequestCycle cycle) 45 { 46 SortColumn selected = getSelected(); 47 SortColumn sortColumn = getSortColumn(); 48 49 if (selected != sortColumn) 50 { 51 setSelected(sortColumn); 52 setDescending(false); 53 } 54 else 55 { 56 boolean current = isDescending(); 57 setDescending(!current); 58 } 59 60 IActionListener listener = getListener(); 61 if (listener == null) 62 throw Tapestry.createRequiredParameterException(this, "listener"); 63 64 listener.actionTriggered(this, cycle); 65 } 66 } 67 | Popular Tags |