|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.fdsapi.FormattedDataSet
Using templates and tabular data The FormattedDataSet generates dynamic text such as HTML, XML and more. The FormattedDataSet makes a clean separation of data and presentation. The data can be any TabularData such as a ResultSet or a 2 dimensional array. The formatting is kept in templates and can be reused with any TabularData.
There are many methods that are overloaded in the FormattedDataSet. For example there are 12 different "getFormattedDataSet(...)" method calls. The main differences in the methods are the type of TabularData they take as input. For example a query can be passed in directly, or a query with a DataSourceName, a ResultSetConverter or any other form of TabularData. Also some of the methods can take a Map which contains miscellaneous data referenced in the Template with ## variable syntax (i.e. ##mapKey). Finally there are alternative signatures that take a Template name, or the Template object itself. Despite the large number of signatures remember that conceptually all the "getFormattedDataSet(...)" methods do the same thing.
The same principle applies to the multiple signatures of "getDropDownListBox(...)", "getListBox(...)", "getMultiSelectListBox(...)", "getRadioButton(...)", and "getSortedText(...)"
Note that the methods for "getDropDownListBox(...)", "getListBox(...)", "getMultiSelectListBox(...)", and "getRadioButton(...)" all take the same format of the TabularData which is dataValue, displayValue (for example "select dataValue, displayValue from table"). These correspond to the html data and display values. Many of these methods have sample code and output in the javadocs.
Note template names are case-insensitive ("mytemplate" is the same as "MYTEMPLATE").
Sample Output From Many of the Methods mentioned above follow:
1) getFormattedDataSet(...) methods (using the "BasicHtmlTable" template):
| lastNameValue | lastNameDisplay |
|---|---|
| SouzaValue | SouzaDisplay |
| BeckValue | BeckDisplay |
| ReidValue | ReidDisplay |
| HibbertValue | HibbertDisplay |
| RichardsValue | RichardsDisplay |
2) getFormattedDataSet(...) methods (using the "HtmlTable" template):
3) getFormattedDataSet(...) methods (using the "xml1" template):
<rollingstones> <row rowID='1'> <First Name>Keith</First Name> <Last Name>Richards</Last Name> </row> <row rowID='2'> <First Name>Mick</First Name> <Last Name>Jagger</Last Name> </row> <row rowID='3'> <First Name>Bill</First Name> <Last Name>Wyman</Last Name> </row> <row rowID='4'> <First Name>Ron</First Name> <Last Name>Wood</Last Name> </row> <row rowID='5'> <First Name>Charlie</First Name> <Last Name>Watts</Last Name> </row> </rollingstones>
4) getSortedText(...) methods (using the "sortedHTMLTable" template):
5) getDropDownListBox(...) methods:
6) getListBox(...) methods:
7) getMultiSelectListBox(...) methods:
8) getRadioButton(...) methods:
SouzaDisplay
BeckDisplay
ReidDisplay
HibbertDisplay
RichardsDisplay
| Constructor Summary | |
FormattedDataSet()
FormattedDataSet may either be created with a constructor or the createInstance() method |
|
| Method Summary | |
static FormattedDataSet |
createInstance()
Returns a singleton version of the FormattedDataSet. |
protected java.lang.String |
formatList(java.lang.String listBox,
java.lang.String selectedItem)
Select/hightlight an item in an html list box |
protected java.lang.String |
formatRadioButton(java.lang.String radioButton,
java.lang.String selectedItem)
Select/highlight an item in an html radio button list box |
ArrayConverter |
getArrayConverter()
Get the ArrayConverter that is set for any arrays. |
DataAccess |
getDataAccess()
Return the underlying DataAccess object. |
boolean |
getDebug()
Enable/Disable debugging. |
java.lang.String |
getDropDownListBox(java.lang.Object header,
java.lang.Object body,
java.util.Map miscData,
java.lang.String selectedItem)
Using the specified data (which has to either implement TabularData or have been checked into the TabularData factory) display an html drop down listbox. |
java.lang.String |
getDropDownListBox(java.lang.Object header,
java.lang.Object body,
java.lang.String selectedItem)
Using the specified data (which has to either implement TabularData or have been checked into the TabularData factory) display an html drop down listbox. |
java.lang.String |
getDropDownListBox(ResultSetConverter rsc,
java.util.Map miscData,
java.lang.String selectedItem)
Using a ResultSetConverter display an html drop down listbox. |
java.lang.String |
getDropDownListBox(ResultSetConverter rsc,
java.lang.String selectedItem)
Using a ResultSetConverter display an html drop down listbox. |
java.lang.String |
getDropDownListBox(java.lang.String query,
java.util.Map miscData,
java.lang.String selectedItem)
Using the specified query and default DataSource display an html drop down listbox (extra info can be passed in via a Map). |
java.lang.String |
getDropDownListBox(java.lang.String query,
java.lang.String selectedItem)
Using the specified query and the default DataSource display an html drop down listbox. |
java.lang.String |
getDropDownListBox(java.lang.String dataSource,
java.lang.String query,
java.util.Map miscData,
java.lang.String selectedItem)
Using the specified query and DataSource display an html drop down listbox (extra info can be passed in via a Map). |
java.lang.String |
getDropDownListBox(java.lang.String dataSource,
java.lang.String query,
java.lang.String selectedItem)
Using the specified query and DataSource display an html drop down listbox. |
java.lang.String |
getFormattedDataSet(java.lang.Object header,
java.lang.Object body,
java.util.Map miscData,
java.lang.String templateName)
Format the passed data using the passed template and pass in dynamic template variables. |
java.lang.String |
getFormattedDataSet(java.lang.Object header,
java.lang.Object body,
java.util.Map miscData,
Template template)
Format the passed data using the passed template object and pass in dynamic template variables. |
java.lang.String |
getFormattedDataSet(java.lang.Object header,
java.lang.Object body,
java.lang.String templateName)
Format the passed data using the passed template. |
java.lang.String |
getFormattedDataSet(ResultSetConverter rsConverter,
java.util.Map miscData,
java.lang.String templateName)
Format the ResultSetConverter using the passed template and pass in dynamic template variables. |
java.lang.String |
getFormattedDataSet(ResultSetConverter rsConverter,
java.util.Map miscData,
Template template)
Format the ResultSetConverter using the passed template object and pass in dynamic template variables. |
java.lang.String |
getFormattedDataSet(ResultSetConverter rsConverter,
java.lang.String templateName)
Format the ResultSetConverter using the passed template. |
java.lang.String |
getFormattedDataSet(java.lang.String query,
java.util.Map miscData,
java.lang.String templateName)
Execute a query against the default DataSource (jdbc/DataSource) and format the results by using the specified template, also accepting a Map which can be used to specify dynamic template variables. |
java.lang.String |
getFormattedDataSet(java.lang.String query,
java.lang.String templateName)
Execute a query against the default datasource (named jdbc/DataSource) and format the results by using the specified template. |
java.lang.String |
getFormattedDataSet(java.lang.String dataSource,
java.lang.String query,
java.util.Map miscData,
java.lang.String templateName)
Execute a query against the named datasource (named jdbc/MyDataSource) and format the results by using the specified template. |
java.lang.String |
getFormattedDataSet(java.lang.String dataSource,
java.lang.String query,
java.util.Map miscData,
Template template)
Execute a query against the named datasource (named jdbc/MyDataSource) and format the results by using the specified Template object. |
java.lang.String |
getFormattedDataSet(java.lang.String dataSource,
java.lang.String query,
java.lang.String templateName)
Execute a query against the named datasource (named jdbc/MyDataSource) and format the results by using the specified template. |
java.lang.String |
getFormattedDataSet(java.lang.String query,
Template template)
Execute a query against the default datasource (named jdbc/DataSource) and format the results by using the specified template. |
java.lang.String |
getListBox(java.lang.Object header,
java.lang.Object body,
java.util.Map miscData,
java.lang.String selectedItem,
int size)
Using the specified data (which can either be a TabularData interface or an Object that can implement this interface) display an html listbox (extra info may be passed in to the template via a Map). |
java.lang.String |
getListBox(java.lang.Object header,
java.lang.Object body,
java.lang.String selectedItem,
int size)
Using the specified data (which can either be a TabularData interface or an Object that can implement this interface) display an html listbox. |
java.lang.String |
getListBox(ResultSetConverter rsc,
java.util.Map miscData,
java.lang.String selectedItem,
int size)
Using a ResultSetConverter display an html listbox (extra info may be passed in to the template via a Map). |
java.lang.String |
getListBox(ResultSetConverter rsc,
java.lang.String selectedItem,
int size)
Using a ResultSetConverter display an html listbox (extra info may be passed in to the template via a Map). |
java.lang.String |
getListBox(java.lang.String query,
java.util.Map miscData,
java.lang.String selectedItem,
int size)
Using the specified query and default DataSource display an html listbox (extra info can be passed in via a Map). |
java.lang.String |
getListBox(java.lang.String query,
java.lang.String selectedItem,
int size)
Using the specified query and default DataSource display an html listbox. |
java.lang.String |
getListBox(java.lang.String dataSource,
java.lang.String query,
java.util.Map miscData,
java.lang.String selectedItem,
int size)
Using the specified query and a named DataSource display an html listbox (extra info can be passed in via a Map). |
java.lang.String |
getListBox(java.lang.String dataSource,
java.lang.String query,
java.lang.String selectedItem,
int size)
Using the specified query and DataSource display an html listbox. |
java.lang.String |
getMultiSelectListBox(java.lang.Object header,
java.lang.Object body,
java.util.Map miscData,
java.lang.String[] selectedItems,
int size)
Use the specified header and body to display an html multi-select listbox (which must either be an implementation of the TabularData interface or the Objects must be in the TabularData factory. |
java.lang.String |
getMultiSelectListBox(java.lang.Object header,
java.lang.Object body,
java.lang.String[] selectedItems,
int size)
Use the specified header and body to display an html multi-select lisbox (which must either be an implementation of the TabularData interface or the Objects must be in the TabularData factory). |
java.lang.String |
getMultiSelectListBox(ResultSetConverter rsc,
java.util.Map miscData,
java.lang.String[] selectedItems,
int size)
Using a ResultSetConverter display an html multi-select listbox (extra info may be passed into the template via a Map). |
java.lang.String |
getMultiSelectListBox(ResultSetConverter rsc,
java.lang.String[] selectedItems,
int size)
Using a ResultSetConverter display an html multi-select listbox. |
java.lang.String |
getMultiSelectListBox(java.lang.String query,
java.util.Map miscData,
java.lang.String[] selectedItems,
int size)
Using the specified query and the default DataSource display an html multi-select listbox (extra info can be passed in via a Map). |
java.lang.String |
getMultiSelectListBox(java.lang.String query,
java.lang.String[] selectedItems,
int size)
Using the specified query and the default DataSource display an html multi-select listbox. |
java.lang.String |
getMultiSelectListBox(java.lang.String dataSource,
java.lang.String query,
java.util.Map miscData,
java.lang.String[] selectedItems,
int size)
Using the specified query and a named DataSource display an html multi-select listbox (extra info can be passed in via a Map). |
java.lang.String |
getMultiSelectListBox(java.lang.String dataSource,
java.lang.String query,
java.lang.String[] selectedItems,
int size)
Using the specified query and a named DataSource display an html multi-select listbox. |
java.lang.String |
getRadioButton(java.lang.Object header,
java.lang.Object body,
java.util.Map miscData,
java.lang.String selectedItem)
Use the specified data (Either the TabularData interface or an object that has been placed in the TabularData factory) to display an html radio button listbox (extra info may be passed in via a Map). |
java.lang.String |
getRadioButton(java.lang.Object header,
java.lang.Object body,
java.lang.String selectedItem)
Use the specified data (Either the TabularData interface or an object that has been placed in the TabularData factory.) to display an html radio button listbox. |
java.lang.String |
getRadioButton(ResultSetConverter rsc,
java.util.Map miscData,
java.lang.String selectedItem)
Use a ResultSetConverter to display an html radio button listbox (extra info accessible in the template can be passed in via a Map). |
java.lang.String |
getRadioButton(ResultSetConverter rsc,
java.lang.String selectedItem)
Use a ResultSetConverter to display an html radio button listbox. |
java.lang.String |
getRadioButton(java.lang.String query,
java.lang.String selectedItem)
Using the specified query and the default DataSource display an HTML radio-button listbox. |
java.lang.String |
getRadioButton(java.lang.String dataSource,
java.lang.String query,
java.util.Map miscData,
java.lang.String selectedItem)
Use the specified query and DataSource to display an HTML radio-button listbox. |
java.lang.String |
getRadioButton(java.lang.String dataSource,
java.lang.String query,
java.lang.String selectedItem)
Using the specified query and DataSource display an HTML radio-button listbox. |
ResultSetConverter |
getResultSetConverter(java.lang.String query)
Execute the query against the default DataSource (jdbc/DataSource) and return a ResultSetConverter object. |
ResultSetConverter |
getResultSetConverter(java.lang.String dataSource,
java.lang.String query)
Execute the query against the named DataSource, and return a ResultSetConverter object. |
java.lang.String |
getSortedText(java.lang.Object[] header,
java.lang.Object[][] body,
java.util.Map miscData,
int sortCol,
java.lang.String sortOrder,
java.lang.String templateName)
Sort and format the input on the specified sort column and order (ascending, or descending). |
java.lang.String |
getSortedText(java.lang.Object[] header,
java.lang.Object[][] body,
java.util.Map miscData,
int sortCol,
java.lang.String sortOrder,
Template template)
Sort and format the input on the specified sort column and order (ascending, or descending). |
java.lang.String |
getSortedText(ResultSetConverter rsConverter,
java.util.Map miscData,
int sortCol,
java.lang.String sortOrder,
java.lang.String templateName)
Sort and format the ResultSetConverter on the specified sort column and order (ascending, or descending). |
java.lang.String |
getSortedText(java.lang.String query,
java.util.Map miscData,
int sortCol,
java.lang.String sortOrder,
java.lang.String templateName)
Sort and format the query on the specified sort column and order (ascending, or descending). |
java.lang.String |
getSortedText(java.lang.String dataSource,
java.lang.String query,
java.util.Map miscData,
int sortCol,
java.lang.String sortOrder,
java.lang.String templateName)
Sort and format the query on the specified sort column and order (ascending, or descending). |
Template |
getTemplate(java.lang.String templateName)
Returns a Template object which can be manipulated programmatically. |
Templates |
getTemplates()
Returns the templates that belong to the FormattedDataSet. |
protected java.lang.String |
highLightMultiSelect(java.lang.String listBox,
java.lang.String[] selectedItems)
Method that can be used to highlight selected entries in a multi-select listbox |
void |
initialize(java.lang.Object[][] templateFiles)
Pass in an array of template names and files to be parsed into Template objects contained in the FormattedDataSet instance. |
static void |
main(java.lang.String[] args)
Test code for the FormattedDataSet |
void |
putTemplate(java.lang.String templateName,
Template template)
Check in a template object to be used in subsequent calls to FormattedDataSet. |
void |
setArrayConverter(ArrayConverter arrayConverter)
Set the ArrayConverter that is used to Format any passed in data to the getSortedText routines |
void |
setDataAccessFactory(DataAccess dataAccessFactory)
This method sets the DataAccess interface that will be called by the FormattedDataSet when Database interaction is required. |
void |
setDebug(boolean debug)
Enable/Disable debugging. |
protected java.lang.String |
sizeList(java.lang.String listBox,
int size)
Change the size of an html listbox passed in as a String |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public FormattedDataSet()
| Method Detail |
public static FormattedDataSet createInstance()
Returns a singleton version of the FormattedDataSet. It is the equivalent of calling the public constructor except this method returns a singleton. Each FormattedDataSet instance is thread safe no matter how it is created.
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
String html=fds.getFormattedDataSet("select * from table", "htmlTable");
public void initialize(java.lang.Object[][] templateFiles)
Pass in an array of template names and files to be parsed into Template objects contained in the FormattedDataSet instance. The array takes a logical template name and a file. The logical template name can then be referenced in calls to getFormattedDataSet. Note although this routine takes an Object[][] it will typically be passed a String[][]. An Object[][] was taken so the ResultSetConverter.getResultSet() method can be passed directly.
Note in the example below the template name "line_item_template" is parsed using 2 files. Order is important. The first file in the array is parsed first and then the second. If there any conflicting template tags then the second files values will overwrite the first.
Sample call: If the sample code was put in a jsp within a WAR then the template files referenced would be found in the WAR subdirectory called "/templates" off of the root.
<%!
FormattedDataSet fds=FormattedDataSet.createInstance();
public void jspInit() {
String path=getServletContext().getRealPath("/");
String s[][] = {
{"line_item_template", path+"templates/sorted_table_template.html"},
{"line_item_template", path+"templates/line_item_template.html"},
{"myXMLtemplate", path+"templates/xml.html"},
};
fds.initialize(s);
} %><%= fds.getFormattedDataSet("select * from table", "myXMLTemplate") %>
public Templates getTemplates()
Templatespublic Template getTemplate(java.lang.String templateName)
Sample call:
FormattedDataSet fds=new FormattedDataSet();
Template template=fds.getTemplate("xml");
Template
public void putTemplate(java.lang.String templateName,
Template template)
Sample call:
FormattedDataSet fds=new FormattedDataSet();
fds.putTemplate("myxml", new Template());
public void setDataAccessFactory(DataAccess dataAccessFactory)
This method sets the DataAccess interface that will be called by the FormattedDataSet when Database interaction is required. For example there will be a different DataAccess class used for a J2EE application than a stand alone Java app.
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
DataAccess dataAccessFactory=new DataAccessJ2EE(new InitialContext(), "MyDataSource");
fds.setDataAccessFactory(dataAccessFactory);
public DataAccess getDataAccess()
throws java.sql.SQLException
java.sql.SQLException
public java.lang.String getFormattedDataSet(java.lang.String query,
java.lang.String templateName)
throws java.sql.SQLException
Sample Call: The following sample will execute the query and format the results as an HTML table.
FormattedDataSet fds=new FormattedDataSet();
String html=fds.getFormattedDataSet("select * from table", "htmlTable");
java.sql.SQLException
public java.lang.String getFormattedDataSet(java.lang.String query,
Template template)
throws java.sql.SQLException
Sample Call: The following sample will execute the query and format the results as an HTML table.
FormattedDataSet fds=new FormattedDataSet();
String html=fds.getFormattedDataSet("select * from table", fds.getTemplate("htmlTable").copy());
java.sql.SQLException
public java.lang.String getFormattedDataSet(java.lang.String query,
java.util.Map miscData,
java.lang.String templateName)
throws java.sql.SQLException
Sample Call:The following sample will execute the query and format the results as an HTML table.
FormattedDataSet fds=new FormattedDataSet();
Map map=new HashMap();
map.put("date", new Date()); // if template has ##date the date will be dynamically replaced with it
String html=fds.getFormattedDataSet("select * from table", map, "htmlTable");
java.sql.SQLException
public java.lang.String getFormattedDataSet(java.lang.String dataSource,
java.lang.String query,
java.lang.String templateName)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=new FormattedDataSet();
String html=fds.getFormattedDataSet("myDataSource", "select * from table", "htmlTable");
java.sql.SQLException
public java.lang.String getFormattedDataSet(java.lang.String dataSource,
java.lang.String query,
java.util.Map miscData,
java.lang.String templateName)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=new FormattedDataSet();
Map map=new HashMap();
map.put("date", new Date()); // if template has ##date the date will be dynamically replaced with it
String html=fds.getFormattedDataSet("myDataSource", "select * from table", map, "htmlTable");
java.sql.SQLException
public java.lang.String getFormattedDataSet(java.lang.String dataSource,
java.lang.String query,
java.util.Map miscData,
Template template)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=new FormattedDataSet();
Map map=new HashMap();
map.put("date", new Date()); // if template has ##date the date will be dynamically replaced with it
Template template=fds.getTemplate("htmlTable").copy();// clone template so as not to change the original
template.initialize("body_cell_data", 0, 2, "##this-##date");
String html=fds.getFormattedDataSet("myDataSource", "select * from table", map, template);
java.sql.SQLException
public ResultSetConverter getResultSetConverter(java.lang.String dataSource,
java.lang.String query)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=new FormattedDataSet();
ResultSetConverter rsc=fds.getResultSetConverter("myDataSource", "select * from table");
java.sql.SQLException
public ResultSetConverter getResultSetConverter(java.lang.String query)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=new FormattedDataSet();
ResultSetConverter rsc=fds.getResultSetConverter("select * from table");
java.sql.SQLExceptionpublic ArrayConverter getArrayConverter()
public void setArrayConverter(ArrayConverter arrayConverter)
public java.lang.String getFormattedDataSet(java.lang.Object header,
java.lang.Object body,
java.lang.String templateName)
Sample Call: (using array TabularData):
FormattedDataSet fds=new FormattedDataSet();
String[]header={"fname", "lname"};
Object[][] body={{"jeff", "beck"}, {"william", "reid"}};
String html=fds.getFormattedDataSet(header, body, "htmlTable");
Sample Output: Note the "htmltable" output looks best when formatteddataset.css is included

public java.lang.String getFormattedDataSet(java.lang.Object header,
java.lang.Object body,
java.util.Map miscData,
java.lang.String templateName)
Sample Call (using String[], and Object[][] which are both predefined TabularData types):
FormattedDataSet fds=new FormattedDataSet();
String[]header={"fname", "lname"};
Object[][] body={{"jeff", "beck"}, {"william", "reid"}};
Map map=new TreeMap();
map.put("rootElement", "guitarists");
String html=fds.getFormattedDataSet(header, body, map, "xml1");
public java.lang.String getFormattedDataSet(java.lang.Object header,
java.lang.Object body,
java.util.Map miscData,
Template template)
Sample Call (using String[], and Object[][] which are both predefined TabularData types):
FormattedDataSet fds=new FormattedDataSet();
String[]header={"fname", "fullname"};
Object[][] body={{"jeff", "beck"}, {"william", "reid"}};
Map map=new TreeMap();
map.put("rootElement", "guitarists");
Template template=fds.getTemplate("xml1").copy();// clone so as not to change the original
template.initialize("body_cell_data", 0, 2, "##1 ##2");
String html=fds.getFormattedDataSet(header, body, map, template);
public java.lang.String getFormattedDataSet(ResultSetConverter rsConverter,
java.lang.String templateName)
Sample Call:
FormattedDataSet fds=new FormattedDataSet();
String html=fds.getFormattedDataSet(fds.getResultSetConverter("select * from table"), "htmlTable");
public java.lang.String getFormattedDataSet(ResultSetConverter rsConverter,
java.util.Map miscData,
java.lang.String templateName)
Sample Call:
FormattedDataSet fds=new FormattedDataSet();
Map map=new HashMap();
map.put("rootElement", "guitarists");
String html=fds.getFormattedDataSet(fds.getResultSetConverter("select * from guitarists"), map, "xml1");
public java.lang.String getFormattedDataSet(ResultSetConverter rsConverter,
java.util.Map miscData,
Template template)
Sample Call:
FormattedDataSet fds=new FormattedDataSet();
Template template=fds.getTemplate("xml1").copy(); // so as not to change the original
template.initialize("body_cell_data",0,2,"##2, ##1"); // i.e. beck, jeff in col 2
String html=fds.getFormattedDataSet(fds.getResultSetConverter("select * from guitarists"), map, template);
public java.lang.String getSortedText(java.lang.Object[] header,
java.lang.Object[][] body,
java.util.Map miscData,
int sortCol,
java.lang.String sortOrder,
Template template)
Sample Call:
FormattedDataSet fds=new FormattedDataSet();
Map miscData=new HashMap();
miscData.put("myVar", "HelloWorld");
miscData.put("sortPageName", "mypage.jsp");
Template template=new Template();
...
// sorts column 2 (array index 1) in ascending order. possibilites for the sortOrder field are "asc" or "desc"
String html=fds.getSortedText(header, body, miscData, 2, "asc", template); // header=Object[] and body=Object[][]
public java.lang.String getSortedText(java.lang.Object[] header,
java.lang.Object[][] body,
java.util.Map miscData,
int sortCol,
java.lang.String sortOrder,
java.lang.String templateName)
Sample Call: See other getSortedText(...) methods for an example.
public java.lang.String getSortedText(ResultSetConverter rsConverter,
java.util.Map miscData,
int sortCol,
java.lang.String sortOrder,
java.lang.String templateName)
Sample Call: Note the "sortedHTMLTable" template used in the code sample is a default template and so will
so will work out of the box.
FormattedDataSet fds=new FormattedDataSet();
String query="select * from table";
ResultSetConveter rsc=fds.getResultSetConverter(query);
Map miscData=new HashMap();
miscData.put("myVar", "HelloWorld");
miscData.put("sortPageName", "mypage.jsp");
// query must be encoded. this gets put in the clickable header.
miscData.put("query", "&query="+java.net.URLEncoder.encode(query));
...
// sorts column 2 (array index 1) in ascending order. possibilites for the sortOrder field are "asc" or "desc"
String html=fds.getSortedText(rsc, miscData, 2, "asc", "sortedHTMLTable"); // header=Object[] and body=Object[][]
public java.lang.String getSortedText(java.lang.String query,
java.util.Map miscData,
int sortCol,
java.lang.String sortOrder,
java.lang.String templateName)
throws java.sql.SQLException
Sample Call: See other getSortedText(...) methods for an example.
java.sql.SQLException
public java.lang.String getSortedText(java.lang.String dataSource,
java.lang.String query,
java.util.Map miscData,
int sortCol,
java.lang.String sortOrder,
java.lang.String templateName)
throws java.sql.SQLException
Note this method uses the deprecated URLEncoder.encode(String) which was deprecated in 1.4 and replaced by a different method. However, to keep this library compatible with JDK 1.2 I elected to use the deprecated method instead. When jdk 1.2 becomes less pervasive the jdk 1.4 method should be used instead.
Sample Call: See other getSortedText(...) methods for an example.
java.sql.SQLException
public java.lang.String getDropDownListBox(java.lang.String dataSource,
java.lang.String query,
java.lang.String selectedItem)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
String html=fds.getDropDownListBox("MyDataSourceName", "select dataValue, displayValue from table", "selectedDataValue");
java.sql.SQLException
public java.lang.String getDropDownListBox(java.lang.String dataSource,
java.lang.String query,
java.util.Map miscData,
java.lang.String selectedItem)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
Map map=new HashMap();
map.put("date", new Date()); // referenced in template with ##date
String html=fds.getDropDownListBox("MyDataSourceName", "select dataValue, displayValue from table", map, "selectedDataValue");
java.sql.SQLException
public java.lang.String getDropDownListBox(java.lang.String query,
java.lang.String selectedItem)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
String html=fds.getDropDownListBox("select dataValue, displayValue from table", "selectedDataValue");
java.sql.SQLException
public java.lang.String getDropDownListBox(java.lang.String query,
java.util.Map miscData,
java.lang.String selectedItem)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
Map map=new HashMap();
map.put("date", new Date()); // referenced in template with ##date
String html=fds.getDropDownListBox("select dataValue, displayValue from table", map, "selectedDataValue");
java.sql.SQLException
public java.lang.String getDropDownListBox(java.lang.Object header,
java.lang.Object body,
java.lang.String selectedItem)
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
String[] header={"lastNameValue", "lastNameDisplay"};
String[][] body={{"SouzaValue", "SouzaDisplay"}, {"BeckValue", "BeckDisplay"}};
String html=fds.getDropDownListBox(header, body, "BeckValue");
Sample Output:
public java.lang.String getDropDownListBox(java.lang.Object header,
java.lang.Object body,
java.util.Map miscData,
java.lang.String selectedItem)
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
String[] header={"lastNameValue", "lastNameDisplay"};
String[][] body={{"Souza", "Souza"}, {"Beck", "Beck"}};
Map map=new HashMap();
map.put("myVar", "myVarValue");
String html=fds.getDropDownListBox(header, body, "Beck");
public java.lang.String getDropDownListBox(ResultSetConverter rsc,
java.lang.String selectedItem)
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
ResultSetConverter rsc=fds.getResultSetConverter("select lnameValue, lnameDisplay from table");
String html=fds.getDropDownListBox(rsc, "Beck");
public java.lang.String getDropDownListBox(ResultSetConverter rsc,
java.util.Map miscData,
java.lang.String selectedItem)
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
ResultSetConverter rsc=fds.getResultSetConverter("select lnameValue, lnameDisplay from table");
Map map=new HashMap();
map.put("myVar", "myVarValue");
String html=fds.getDropDownListBox(rsc, map, "Beck");
public java.lang.String getListBox(java.lang.String dataSource,
java.lang.String query,
java.lang.String selectedItem,
int size)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
String html=fds.getListBox("MyDataSource", "select dataValue, displayValue from table", "selectedDataValue", 10);
java.sql.SQLException
public java.lang.String getListBox(java.lang.String dataSource,
java.lang.String query,
java.util.Map miscData,
java.lang.String selectedItem,
int size)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
Map map=new HashMap();
map.put("date", new Date()); // referenced in template with ##date
String html=fds.getListBox("MyDataSource", "select dataValue, displayValue from table", map, "selectedDataValue", 5);
java.sql.SQLException
public java.lang.String getListBox(java.lang.String query,
java.lang.String selectedItem,
int size)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
String html=fds.getListBox("select dataValue, displayValue from table", "selectedDataValue", 5);
java.sql.SQLException
public java.lang.String getListBox(java.lang.String query,
java.util.Map miscData,
java.lang.String selectedItem,
int size)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
Map map=new HashMap();
map.put("date", new Date()); // referenced in template with ##date
String html=fds.getListBox("select dataValue, displayValue from table", map, "selectedDataValue", 5);
java.sql.SQLException
public java.lang.String getListBox(java.lang.Object header,
java.lang.Object body,
java.lang.String selectedItem,
int size)
Sample Call: Using ResultSet and ResultSetMetaData as the TabularData types (The code below assumes the ResultSet has already been
opened)
FormattedDataSet fds=FormattedDataSet.createInstance();
String html=fds.getListBox(resultSet.getMetaData(), resultSet, "BeckValue", 5);
Sample Output:
public java.lang.String getListBox(java.lang.Object header,
java.lang.Object body,
java.util.Map miscData,
java.lang.String selectedItem,
int size)
Sample Call: Using ResultSet and ResultSetMetaData as the TabularData types (The code below assumes the ResultSet has already been
opened)
FormattedDataSet fds=FormattedDataSet.createInstance();
Map map=new HashMap();
map.put("date", new Date()); // referenced in template with ##date
String html=fds.getListBox(resultSet.getResultSetMetaData(), resultSet, map, "selectedDataValue", 5);
public java.lang.String getListBox(ResultSetConverter rsc,
java.lang.String selectedItem,
int size)
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
ResultSetConverter rsc=fds.getResultSetConverter("select dataValue, displayValue from table");
String html=fds.getListBox(rsc, map, "selectedDataValue", 5);
public java.lang.String getListBox(ResultSetConverter rsc,
java.util.Map miscData,
java.lang.String selectedItem,
int size)
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
ResultSetConverter rsc=fds.getResultSetConverter("select dataValue, displayValue from table");
Map map=new HashMap();
map.put("date", new Date()); // referenced in template with ##date
String html=fds.getListBox(rsc, map, "selectedDataValue", 5);
public java.lang.String getMultiSelectListBox(java.lang.String dataSource,
java.lang.String query,
java.lang.String[] selectedItems,
int size)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
// both values will be selected in the listbox
String[] selectedValues={"SouzaValue", "BeckValue"};
String html=fds.getMultiSelectListBox("MyDataSource", "select dataValue, displayValue from table", selectedValues, 5);
java.sql.SQLException
public java.lang.String getMultiSelectListBox(java.lang.String dataSource,
java.lang.String query,
java.util.Map miscData,
java.lang.String[] selectedItems,
int size)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
Map map=new HashMap();
map.put("date", new Date()); // referenced in template with ##date
// both values will be selected in the listbox
String[] selectedValues={"SouzaValue", "BeckValue"};
String html=fds.getMultiSelectListBox("MyDataSource", "select dataValue, displayValue from table", map, selectedValues, 5);
java.sql.SQLException
public java.lang.String getMultiSelectListBox(java.lang.String query,
java.lang.String[] selectedItems,
int size)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
String[] selectedValues={"SouzaValue", "BeckValue"};
// both values will be selected in the listbox
String html=fds.getMultiSelectListBox("select dataValue, displayValue from table", selectedValues, 5);
java.sql.SQLException
public java.lang.String getMultiSelectListBox(java.lang.String query,
java.util.Map miscData,
java.lang.String[] selectedItems,
int size)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
Map map=new HashMap();
map.put("date", new Date()); // referenced in template with ##date
// both values will be selected in the listbox
String[] selectedValues={"SouzaValue", "BeckValue"};
String html=fds.getMultiSelectListBox("select dataValue, displayValue from table", map, selectedValues, 5);
java.sql.SQLException
public java.lang.String getMultiSelectListBox(java.lang.Object header,
java.lang.Object body,
java.lang.String[] selectedItems,
int size)
Sample Call: The example below uses ResultSetMetaData and ResultSets both of which are forms of TabularData
FormattedDataSet fds=FormattedDataSet.createInstance();
// both values will be selected in the listbox
String[] selectedValues={"SouzaValue", "BeckValue"};
String html=fds.getMultiSelectListBox(resultSet.getMetaData(), resultSet, selectedValues, 5);
Sample Output:
public java.lang.String getMultiSelectListBox(java.lang.Object header,
java.lang.Object body,
java.util.Map miscData,
java.lang.String[] selectedItems,
int size)
Sample Call: The example below uses ResultSetMetaData and ResultSets both of which are forms of TabularData
FormattedDataSet fds=FormattedDataSet.createInstance();
// both values will be selected in the listbox
String[] selectedValues={"SouzaValue", "BeckValue"};
String html=fds.getMultiSelectListBox(resultSet.getMetaData(), resultSet, selectedValues, 5);
public java.lang.String getMultiSelectListBox(ResultSetConverter rsc,
java.lang.String[] selectedItems,
int size)
Sample Call: The example below uses ResultSetMetaData and ResultSets both of which are forms of TabularData
FormattedDataSet fds=FormattedDataSet.createInstance();
ResultSetConverter rsc=fds.getResultSetConverter("select dataValue, displayValue from table");
// both values will be selected in the listbox
String[] selectedValues={"SouzaValue", "BeckValue"};
String html=fds.getMultiSelectListBox(rsc, selectedValues, 5);
public java.lang.String getMultiSelectListBox(ResultSetConverter rsc,
java.util.Map miscData,
java.lang.String[] selectedItems,
int size)
Sample Call: The example below uses ResultSetMetaData and ResultSets both of which are forms of TabularData
FormattedDataSet fds=FormattedDataSet.createInstance();
ResultSetConverter rsc=fds.getResultSetConverter("select dataValue, displayValue from table");
Map map=new HashMap();
map.put("date", new Date()); // referenced in template with ##date
// both values will be selected in the listbox
String[] selectedValues={"SouzaValue", "BeckValue"};
String html=fds.getRadioButton(rsc, map, selectedValues, 5);
protected java.lang.String highLightMultiSelect(java.lang.String listBox,
java.lang.String[] selectedItems)
public java.lang.String getRadioButton(java.lang.String dataSource,
java.lang.String query,
java.lang.String selectedItem)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
String html=fds.getRadioButton("MyDataSource", "select dataValue, displayValue from table", "selectedDataValue");
java.sql.SQLException
public java.lang.String getRadioButton(java.lang.String dataSource,
java.lang.String query,
java.util.Map miscData,
java.lang.String selectedItem)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
String html=fds.getRadioButton("MyDataSource", "select dataValue, displayValue from table", "selectedDataValue");
java.sql.SQLException
public java.lang.String getRadioButton(java.lang.String query,
java.lang.String selectedItem)
throws java.sql.SQLException
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
String html=fds.getRadioButton("select dataValue, displayValue from table", "selectedDataValue");
java.sql.SQLException
public java.lang.String getRadioButton(java.lang.Object header,
java.lang.Object body,
java.lang.String selectedItem)
Sample Call: The sample uses a ResultSet and ResultSetMetaData, however other types of TabularData are
also supported via this method.
FormattedDataSet fds=FormattedDataSet.createInstance();
String html=fds.getRadioButton(resultSet.getMetaData(), resultSet, "BeckValue");
Sample Output:
SouzaDisplay BeckDisplay ReidDisplay HibbertDisplay RichardsDisplay
public java.lang.String getRadioButton(java.lang.Object header,
java.lang.Object body,
java.util.Map miscData,
java.lang.String selectedItem)
Sample Call: The sample uses a ResultSet and ResultSetMetaData, however other types of TabularData are
also supported via this method.
FormattedDataSet fds=FormattedDataSet.createInstance();
Map map=new HashMap();
map.put("date", new Date()); // referenced in template with ##date
String html=fds.getRadioButton(resultSet.getMetaData(), resultSet, map, "BeckValue");
public java.lang.String getRadioButton(ResultSetConverter rsc,
java.lang.String selectedItem)
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
ResultSetConverter rsc=fds.getResultSetConverter("select dataValue, displayValue from table");
String html=fds.getRadioButton(rsc, "BeckValue");
public java.lang.String getRadioButton(ResultSetConverter rsc,
java.util.Map miscData,
java.lang.String selectedItem)
Sample Call:
FormattedDataSet fds=FormattedDataSet.createInstance();
ResultSetConverter rsc=fds.getResultSetConverter("select dataValue, displayValue from table");
Map map=new HashMap();
map.put("date", new Date()); // referenced in template with ##date
String html=fds.getRadioButton(rsc, map, "BeckValue");
public void setDebug(boolean debug)
public boolean getDebug()
protected java.lang.String sizeList(java.lang.String listBox,
int size)
protected java.lang.String formatList(java.lang.String listBox,
java.lang.String selectedItem)
protected java.lang.String formatRadioButton(java.lang.String radioButton,
java.lang.String selectedItem)
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||