TableView: Cell, Row, and Member Level Editing |
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.
tableViewEditing
.JDBCDefaultExampleControllerServlet.java
file from the
Files Tab of the Project Navigator.jdbcQuery
string from ENTER_QUERY_STRING_HERE to
"select * from sasuser.class" - you might have to copy the class
data set from sashelp to sasuser
.if (adapter == null){ try{ //Create the model adapter and set it on the session adapter = new JDBCToTableModelAdapter(sas_JDBCConnection, jdbcQuery); adapter.setReadOnly(false); if (session != null){ session.setAttribute(SAS_MODEL, adapter); } } catch(Exception e){ throw new RuntimeException(e); } }
The default JSP file will contain a TableViewComposite component.
Add a <sas:TableView> tag and a <sas:Edit> tag to allow row level editing.
<sas:TableViewComposite id="sas_TableView1" model="sas_model" actionProvider="sas_actionProvider" scope="session"> <sas:RelationalMenuBar /> <sas:TableView> <sas:Edit enabled="true" /> </sas:TableView> </sas:TableViewComposite>
Modify the <sas:Edit> tag to allow for member level editing.
<sas:TableView> <sas:Edit enabled="true" singleRowEditing="false"/> </sas:TableView>
import javax.swing.DefaultComboBoxModel;
if (session != null){ sas_actionProvider = (HttpActionProvider)session.getAttribute(ACTION_PROVIDER); String items[] = {"F", "M"}; DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel(items); session.setAttribute("sas_ComboBoxModel",comboBoxModel); }
<sas:TableView> <sas:Edit enabled="true" /> <sas:CellEditor startRow="1" endRow="-1" startColumn="2" endColumn="2"> <sas:CellContentsChoiceBoxEditor model="sas_ComboBoxModel" /> </sas:CellEditor> </sas:TableView>
For more information and options, see Web Application Example Templates.