Constructor and Description |
---|
FormUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
fillCheckboxGroup(CheckboxGroup cbg,
List list,
Class beanClass,
String valueMethodName,
String htmlTextMethodName)
Fills in the specified checkboxgroup with values from the supplied list.
|
static void |
fillRadioGroup(RadioGroup rg,
List list,
Class beanClass,
String valueMethodName,
String htmlTextMethodName)
Fills in the specified radiogroup with values from the supplied list.
|
static void |
fillSelect(Select select,
List list,
String message,
Class beanClass,
String valueMethodName,
String htmlTextMethodName)
Note: This method is almost never needed.
|
static void |
fillSelect(Select select,
Map values,
String message)
Note: This method is almost never needed.
|
static Select |
fillSelectWithDays(Select s)
Fills the specified select from years, starting with the specified year.
|
static Select |
fillSelectWithDays(Select s,
Calendar cal)
Fills the specified select from years, starting with the specified year.
|
static Select |
fillSelectWithDaysToday(Select s)
Fills the specified select from years, starting with the specified year.
|
static Select |
fillSelectWithMonths(Select s,
boolean monthsAsText)
Fills the specified select from years, starting with the specified year.
|
static Select |
fillSelectWithMonths(Select s,
boolean monthsAsText,
Calendar cal)
Fills the specified select from years, starting with the specified year.
|
static Select |
fillSelectWithMonthsToday(Select s,
boolean monthsAsText)
Fills the specified select from years, starting with the specified year.
|
static Select |
fillSelectWithYears(Select s,
int startYear)
Fills the specified select from years, starting with the specified year
till the current year.
|
static Select |
fillSelectWithYears(Select s,
int startYear,
Calendar yearToSelect)
Fills the specified select from years, starting with the specified year,
upto the current year.
|
static Select |
fillSelectWithYears(Select s,
int startYear,
int endYear,
Calendar cal)
Fills the specified select from years, from the specified start and end
years (both inclusive).
|
static Select |
fillSelectWithYearsToday(Select s,
int startYear)
Fills the specified select from years, starting with the specified year.
|
static void |
main(String[] args) |
static Date |
toDate(String year,
String month,
String day)
Converts a year, month and day into a java.sql.Date
|
static Time |
toTime(String time)
Converts a time string into a java.sql.Time.
|
public FormUtil()
public static void fillSelect(Select select, List list, String message, Class beanClass, String valueMethodName, String htmlTextMethodName)
Select.useQuery(Connection, String)
method instead.
Fills in the specified select with values from the supplied list. This is
intended to show a select widget corresponding to a lookup table in the
database. The list will typically be returned by getAll/getWhere
methods of some generated DBOMgr
class.
For example, given a lookup table object Foo and a corresponding
manager object FooMgr and an empty previously-instantiated
select:
and where table Foo has the following data
Select select = new Select("myselect")
fillSelect(select, FooMgr.getAll(),
"--choose--",
Foo.class, "getID",
"getValue");
will add the following values to the select:Table Foo ID Value ----------------------------------- 1 "lookup_one" 2 "lookup_two" 3 "lookup_three"
<option>--choose--</option> <option value=1>lookup_one</option> <option value=2>lookup_two</option> <option value=3>lookup_three</option>
select
- a select object to be filled inlist
- list of objects of type beanClass. Typically
this would be obtained via invoking the
beanClassMgr.getAll() methodmessage
- an optional message to show as the first value of
the select option (typically ---select--
or --choose an option-- etc.). Specify
null to skip creating this optional message.beanClass
- the DBO
class corresponding to some lookuptable in the
databasevalueMethodName
- the name of the method in the DBO
class which will be used to
create the value for a radio button [ without "()"]htmlTextMethodName
- the name of the method in the DBO
class which will be used to
create the html text displayed to the user for a radio button [name
should be without "()"]IllegalArgumentException
- if an error occurred in getting the specified methods
from the specified class and invoking them on the
specified listpublic static void fillSelect(Select select, Map values, String message)
Select.useQuery(Connection, String)
method instead.
Fills in the specified select with values from the supplied map. This is
intended to show a select widget corresponding to a lookup table in the
database. The list will typically be returned by getAll/getWhere
methods of some generated DBOMgr
class.
For example, given a lookup table object Foo and a corresponding
manager object FooMgr and an empty previously-instantiated
select:
and where table Foo has the following data
Select select = new Select("myselect")
fillSelect(select, FooMgr.getAll(),
"--choose--",
Foo.class, "getID",
"getValue");
will add the following values to the select:Table Foo ID Value ----------------------------------- 1 "lookup_one" 2 "lookup_two" 3 "lookup_three"
<option>--choose--</option> <option value=1>lookup_one</option> <option value=2>lookup_two</option> <option value=3>lookup_three</option>
select
- a select object to be filled invalues
- A map containing the values for the select. For each key, value pair,
the following will be generated for the select:
message
- an optional message to show as the first value of the select option
(typically ---select-- or --choose an option-- etc.).
Specify null to skip creating this optional message.public static void fillRadioGroup(RadioGroup rg, List list, Class beanClass, String valueMethodName, String htmlTextMethodName)
DBOMgr
class. For
example, given a lookup table object Foo and a corresponding
manager object FooMgr and a empty previously-instantiated radio
group:
and where table Foo has the following data:
RadioGroup rg = new RadioGroup("myradio")
fillRadioGroup(select, FooMgr.getAll(),
Foo.class, "getID",
"getValue");
will add those values to the radio group.Table Foo ID Value ----------------------------------- 1 "lookup_one" 2 "lookup_two" 3 "lookup_three"
rg
- a radio group object to be filled inlist
- list of objects of type beanClass. Typically
this would be obtained via invoking the
beanClassMgr.getAll() methodbeanClass
- the DBO
class corresponding to some lookuptable in the
databasevalueMethodName
- the name of the method in the DBO
class which will be used to
create the value for a radio button [ without "()"]htmlTextMethodName
- the name of the method in the DBO
class which will be used to
create the html text displayed to the user for a radio button [name
should be without "()"]IllegalArgumentException
- if an error occurred in getting the specified methods
from the specified class and invoking them on the
specified listpublic static void fillCheckboxGroup(CheckboxGroup cbg, List list, Class beanClass, String valueMethodName, String htmlTextMethodName)
DBOMgr
class.
For example, given a lookup table object Foo and a corresponding
manager object FooMgr and a empty previously-instantiated
checkbox group:
and where table Foo has the following data:
CheckboxGroup rg = new CheckboxGroup("mycbgroup")
fillCheckboxGroup(select, FooMgr.getAll(),
Foo.class, "getID",
"getValue");
will add those values to the checkbox group.Table Foo ID Value ----------------------------------- 1 "lookup_one" 2 "lookup_two" 3 "lookup_three"
cbg
- a checkbox group object to be filled inlist
- list of objects of type beanClass. Typically
this would be obtained via invoking the
beanClassMgr.getAll() methodbeanClass
- the DBO
class corresponding to some lookuptable in the
databasevalueMethodName
- the name of the method in the DBO
class which will be used to
create the value for a radio button [ without "()"]htmlTextMethodName
- the name of the method in the DBO
class which will be used to
create the html text displayed to the user for a radio button [name
should be without "()"]IllegalArgumentException
- if an error occurred in getting the specified methods
from the specified class and invoking them on the
specified listpublic static Select fillSelectWithYears(Select s, int startYear)
public static Select fillSelectWithYearsToday(Select s, int startYear)
public static Select fillSelectWithYears(Select s, int startYear, Calendar yearToSelect)
public static Select fillSelectWithYears(Select s, int startYear, int endYear, Calendar cal)
public static Select fillSelectWithMonths(Select s, boolean monthsAsText)
public static Select fillSelectWithMonthsToday(Select s, boolean monthsAsText)
public static Select fillSelectWithMonths(Select s, boolean monthsAsText, Calendar cal)
public static Select fillSelectWithDays(Select s)
public static Select fillSelectWithDaysToday(Select s)
public static Select fillSelectWithDays(Select s, Calendar cal)
public static Date toDate(String year, String month, String day)
public static Time toTime(String time)