Displaying a Table using JDBC |
Data Source: JDBC
This example includes the following customizations:
Please install the latest webAF template updates prior to building this example. For more information about the server-side example templates used by this example, see Web Application Example Templates and Built-in Web Application Templates and Options.
The following example is not meant to be a complete Web application, rather it is to show how to use a particular component(s). The example does not address the issue of immediately freeing up resources when the user navigates off the Web application or closes the Web browser. Any necessary resources created in the example will stay around until the associated HTTPSession times out. If this example is used in a multi-user environment, it is possible to exhaust the available resources until HTTPSessions time out and free up their associated resources.
tableView
.JDBC Default ExampleControllerServlet.java
file
from the Files Tab of the Project Navigator.jdbcQuery
string from ENTER_QUERY_STRING_HERE
to
"select * from sashelp.prdsale"
.The default JSP file will contain a TableViewComposite component.
Add the rowPageSize and columnPageSize attributes to the <sas:TableView> custom tag. The code is shown below.
<sas:TableViewComposite id="sas_TableView1" model="sas_model" actionProvider="sas_actionProvider" scope="session"> <sas:RelationalMenuBar /> <sas:TableView rowPageSize="10" columnPageSize="8"/> </sas:TableViewComposite>
Add a <sas:CellRenderer> tag to the example to color every other row with a gray background. The code is shown below.
<sas:TableView rowPageSize="10" columnPageSize="8" > <sas:CellRenderer bgColor="dcdcdc" startRow="1" endRow="-1" repeatRowFactor="2" startColumn="1" endColumn="-1" repeatColumnFactor="1"> </sas:CellRenderer> </sas:TableView>
Modify the <sas:CellRenderer> inner tag to change the background color of column 7 to red. Add a <sas:CellContentsLabelRenderer> inner tag to the example in order to change the text font. The code is shown below.
<sas:CellRenderer bgColor="red" startRow="1" endRow="-1" repeatRowFactor="1" startColumn="7" endColumn="7" repeatColumnFactor="1"> <sas:CellContentsLabelRenderer> <sas:StyleInfo style="font-family: 'Trebuchet MS', Arial, Helvetica, sans-serif; font-size: 12pt; font-weight: bold;"/> </sas:CellContentsLabelRenderer> </sas:CellRenderer>
For more information and options, see the Web Application Example Templates paper.