Stamps in tables may render controls that can be edited by a user. For example, suppose you want to render an editable form input element in every cell of a table column, so that users can enter or change data in those cells. To ensure that the unique value in each cell is sent to the server, set the nameTransformed attribute on the table component to true.
When name transformation is turned on, the table treats the name attribute on any of its stamps as special, and alters it before rendering the stamp into a given cell. For instance, if a column stamp was an input control with the name "foo", the table would alter the actual value of the name rendered into each cell to take the form:
tableName:foo:rowIndex
where tableName
would be replaced by the value of the
table's name attribute and the rowIndex
would be replaced
with an integer indicating which row that stamp is being rendered into.
This means that an input element named "foo", rendered in a table named
"myTestTable" in the third row would get the name:
myTestTable:foo:3
When the form containing the table (as shown in the following example) is submitted, either as the result of a navigation bar link or any other form-triggering action, the server will receive four Form Control Name/Initial Value pairs representing the values in the textInput column:
Note: You can disable name transformation on a single
column without disabling name transformation on the entire table. The
column component also has a nameTransformed attribute. By default name
transformation on a single column is on, unless nameTransformed
on the table has been set to false.
...
<dataScope ... >
<provider>
...
</provider>
<contents>
<form name="testForm">
<contents>
<table name="myTestTable" ... >
<contents>
<column>
<columnHeader>First Header</columnHeader>
<contents>
<textInput text="${uix.current.firstColumnText}" name="foo"/>
</contents>
</column>
<column>
<columnHeader>Second Header</columnHeader>
<contents>
<button text="${uix.current.secondColumnText}" destination="http://www.example.com"/>
</contents>
</column>
</contents>
</table>
</contents>
</form>
</contents>
</dataScope>
...
UIX also provides utility classes for retrieving the values on the server after they have been submitted. They are:
Each of the classes implements a DataObjectList of all the input elements in a given table. The length of this list is the number of rows in the table. Each DataObject in this list corresponds to a row in the table. Use the name of an input element, as the key (with each DataObject) to get the value of that element (on the respective row).
The following example implements an event handler that pulls out all the table input element values and concatenates them.
Example:
public static EventResult doSubmitEvent(BajaContext bc, Page page,
PageEvent event)
{
// create a new FlattenedDataSet for the table "myTestTable"
DataSet tableInputs = new PageEventFlattenedDataSet(event, "myTestTable");
StringBuffer s = new StringBuffer(40);
// this would be the number of rows in the table
int sz = tableInputs.getLength();
for(int i=0; i<sz ;i++)
{
// get the DataObject representing all the input elements on the current
// table row.
DataObject row = tableInputs.getItem(i);
// get the value of the input element named "foo". we can safely use
// null for the RenderingContext here:
Object value = row.selectValue(null, "foo");
s.append(value);
}
EventResult result = new EventResult(page);
result.setProperty("case", "submit");
// store the concatenation of the values of all the "foo" elements on the
// EventResult
result.setProperty("result", s);
return result;
}
Automatic name transformation may be undesirable in some cases. For example, if you wanted to render a radio button group vertically down a column, then you would have to ensure that each radio element has the same name (so that they belong in the same group and are mutually exclusive). Currently, the only way to do this is to turn off the automatic name transformation (set nameTransformed attribute on the table component to false) and handle name transformations privately by data binding each name attribute.
If you would still like to use PageEventFlattenedDataSet (or ServletRequestDataSet) to get at your data on the server, then you should use oracle.cabo.ui.data.FlattenedDataSet to transform all the table input elements. To get the transformation of input element "foo" on row 5 of table "myTestTable" use:
String newName = FlattenedDataSet.getFlattenedName("myTestTable",
5, "foo");
To get the transformation of your special radio group column with name "radio" use:
String newName = FlattenedDataSet.getFlattenedName("myTestTable",
"radio");
DataSet tableInputs = new PageEventFlattenedDataSet(event,
"myTestTable");
Object radioValue = tableInputs.selectValue(null, "radio");
About Table and its Named Children
Copyright © 1997, 2004, Oracle. All rights reserved.