com.darwinsys.util
Class DateRangeUIHelper

java.lang.Object
  extended by com.darwinsys.util.DateRangeUIHelper

public class DateRangeUIHelper
extends java.lang.Object

Utilities for using choice items like "Modified in last..." and a list of { day, week, month...}. Typical use is getDateRangeValues() to get the values, and getDateRangeLabels for the labels, when displaying the choice item to the user, and pass the chosen value to getDateFromRange(). Alternately, if your UI allows components to be displayed directly (e.g., Swing), use the public field dateRanges. For example, in Struts you might use this in a JSP:

  <jsp:useBean name="my.dates" class="...DateRangeUIHelper"/>
        <html:select ...>
  <:html:options name="my.date" property="dateRangeValues"
       labelName="my.date" labelProperty="dateRangeLabels"
       />


   // Swing Example:
   // Constructor:
   jComboBox.setListData(DateUtils.dateRanges);
   // Action Handler
   DateRangeUIHelper.Range r = (DateRangeUIHelpers.Range)jComboBox.getSelectedItem();
   Date startDate = DateRangeUIHelper.getDateFromRange(r.getChoiceValue());
 

For a runnable example, see regress.util.DateRangeUIHelper in the the darwinsys-api project.


Nested Class Summary
static class DateRangeUIHelper.Range
          Tiny data holder for a range like "7d" and its numeric equivalent.
 
Constructor Summary
DateRangeUIHelper()
           
 
Method Summary
static java.util.Date getDateFromRange(java.lang.String dropdownValue)
           
static java.lang.String[] getDateRangeLabels()
          Return the <choice> labels for use in a DropDown and in getDateFromRange().
static DateRangeUIHelper.Range[] getDateRanges()
           
static java.lang.String[] getDateRangeValues()
          Return the <choice> values for use in a DropDown and in getDateFromRange().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateRangeUIHelper

public DateRangeUIHelper()
Method Detail

getDateRanges

public static DateRangeUIHelper.Range[] getDateRanges()

getDateRangeValues

public static java.lang.String[] getDateRangeValues()
Return the <choice> values for use in a DropDown and in getDateFromRange().


getDateRangeLabels

public static java.lang.String[] getDateRangeLabels()
Return the <choice> labels for use in a DropDown and in getDateFromRange().


getDateFromRange

public static java.util.Date getDateFromRange(java.lang.String dropdownValue)


Copyright © 1996-2004 Ian F. Darwin. See license.html for usage license.