Class FormUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidfillCheckboxGroup(CheckboxGroup cbg, List list, Class beanClass, String valueMethodName, String htmlTextMethodName) Fills in the specified checkboxgroup with values from the supplied list.static voidfillRadioGroup(RadioGroup rg, List list, Class beanClass, String valueMethodName, String htmlTextMethodName) Fills in the specified radiogroup with values from the supplied list.static voidfillSelect(Select select, List list, String message, Class beanClass, String valueMethodName, String htmlTextMethodName) Note: This method is almost never needed.static voidfillSelect(Select select, Map values, String message) Note: This method is almost never needed.static SelectFills the specified select from years, starting with the specified year.static SelectfillSelectWithDays(Select s, Calendar cal) Fills the specified select from years, starting with the specified year.static SelectFills the specified select from years, starting with the specified year.static SelectfillSelectWithMonths(Select s, boolean monthsAsText) Fills the specified select from years, starting with the specified year.static SelectfillSelectWithMonths(Select s, boolean monthsAsText, Calendar cal) Fills the specified select from years, starting with the specified year.static SelectfillSelectWithMonthsToday(Select s, boolean monthsAsText) Fills the specified select from years, starting with the specified year.static SelectfillSelectWithYears(Select s, int startYear) Fills the specified select from years, starting with the specified year till the current year.static SelectfillSelectWithYears(Select s, int startYear, int endYear, Calendar cal) Fills the specified select from years, from the specified start and end years (both inclusive).static SelectfillSelectWithYears(Select s, int startYear, Calendar yearToSelect) Fills the specified select from years, starting with the specified year, upto the current year.static SelectfillSelectWithYearsToday(Select s, int startYear) Fills the specified select from years, starting with the specified year.static voidstatic DateConverts a year, month and day into a java.sql.Datestatic TimeConverts a time string into a java.sql.Time.
-
Constructor Details
-
FormUtil
public FormUtil()
-
-
Method Details
-
fillSelect
public static void fillSelect(Select select, List list, String message, Class beanClass, String valueMethodName, String htmlTextMethodName) Note: This method is almost never needed. Use theSelect.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
DBOMgrclass.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 dataSelect 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>
- Parameters:
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- theclass corresponding to some lookuptable in the databaseinvalid reference
DBOvalueMethodName- the name of the method in theclass which will be used to create the value for a radio button [ without "()"]invalid reference
DBOhtmlTextMethodName- the name of the method in theclass which will be used to create the html text displayed to the user for a radio button [name should be without "()"]invalid reference
DBO- Throws:
IllegalArgumentException- if an error occurred in getting the specified methods from the specified class and invoking them on the specified list
-
fillSelect
Note: This method is almost never needed. Use theSelect.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
DBOMgrclass.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 dataSelect 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>
- Parameters:
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.
-
fillRadioGroup
public static void fillRadioGroup(RadioGroup rg, List list, Class beanClass, String valueMethodName, String htmlTextMethodName) Fills in the specified radiogroup with values from the supplied list. This is intended to show radio groups corresponding to a lookup table in the database. The list will typically be returned by getAll/getWhere methods of some generatedDBOMgrclass.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"
- Parameters:
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- theclass corresponding to some lookuptable in the databaseinvalid reference
DBOvalueMethodName- the name of the method in theclass which will be used to create the value for a radio button [ without "()"]invalid reference
DBOhtmlTextMethodName- the name of the method in theclass which will be used to create the html text displayed to the user for a radio button [name should be without "()"]invalid reference
DBO- Throws:
IllegalArgumentException- if an error occurred in getting the specified methods from the specified class and invoking them on the specified list
-
fillCheckboxGroup
public static void fillCheckboxGroup(CheckboxGroup cbg, List list, Class beanClass, String valueMethodName, String htmlTextMethodName) Fills in the specified checkboxgroup with values from the supplied list. This is intended to show checkbox groups corresponding to a lookup table in the database. The list will typically be returned by getAll or getWhere methods of some generatedDBOMgrclass.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"
- Parameters:
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- theclass corresponding to some lookuptable in the databaseinvalid reference
DBOvalueMethodName- the name of the method in theclass which will be used to create the value for a radio button [ without "()"]invalid reference
DBOhtmlTextMethodName- the name of the method in theclass which will be used to create the html text displayed to the user for a radio button [name should be without "()"]invalid reference
DBO- Throws:
IllegalArgumentException- if an error occurred in getting the specified methods from the specified class and invoking them on the specified list
-
fillSelectWithYears
Fills the specified select from years, starting with the specified year till the current year. No year option is pre-selected. -
fillSelectWithYearsToday
Fills the specified select from years, starting with the specified year. The current year (on the server) is pre-selected. -
fillSelectWithYears
Fills the specified select from years, starting with the specified year, upto the current year. The date from the specified calendar is pre-selected. -
fillSelectWithYears
Fills the specified select from years, from the specified start and end years (both inclusive). The date from the specified calendar is pre-selected. -
fillSelectWithMonths
Fills the specified select from years, starting with the specified year. monthsAsText specifies whether months are displayed as names or numbers. (true for names). No month is preselected. -
fillSelectWithMonthsToday
Fills the specified select from years, starting with the specified year. monthsAsText specifies whether months are displayed as names or numbers. (true for names). The current month (on the server) is preselected. -
fillSelectWithMonths
Fills the specified select from years, starting with the specified year. monthsAsText specifies whether months are displayed as names or numbers. (true for names). The current month from the specified calendar is is preselected. -
fillSelectWithDays
Fills the specified select from years, starting with the specified year. No day is pre-selected. -
fillSelectWithDaysToday
Fills the specified select from years, starting with the specified year. Today (on the server side) is preselected. -
fillSelectWithDays
Fills the specified select from years, starting with the specified year. The day in the specified date is preselected. -
toDate
-
toTime
Converts a time string into a java.sql.Time. Time is of the format: HH:MM (for example: 1:23 or 01:23). Returns null if the string could not be parsed. (Hours upto 12 are allowed but not 13 or more). This method is suitable for a text box that takes 1-12 hours and a seperate am/pm select option next to it. -
main
-