I will try to describe what is happening:
For every input field, you define an ognl expression, which defines where the data comes from AND *gets to*.
So, if the table iterates through your list A which contains many Foo objects, and the operatorSelection works on the value "components.dataTable.tableRow.operator", which represents, for each row, the "operator" property of the corresponding Foo, then, when you submit, all Foo objects in list A, WILL AUTOMATICALLY HAVE the values you submited. Is'nt that magic?
What tapestry does is render the page again, this is called rewind. The table iterates throgh your list *again*, only this time, instead of getting values to the input fields, it sets values from the input fields to your beans.
All that is left for you is to bother of *what* you want to do with the data and not how to retrieve it, because its already there, sitting nicley and waiting for your :)
Cheers and have fun... Ron
××××× David Ethell:
I've been over the documents and searched this list many times in the
last couple days and I'm still not certain how to retrieve the submitted
data from a FormTable. I have seen the examples for LocaleList in the
workbench and some other examples using IPrimaryKeyConvertor, but I'd
like to get back the entire bean used to populate the table.
I know that it doesn't submit back into the source list, but where does it submit to? I see the iterRows parameter and I can tell it's a serialization of some sort, but what's the proper way to deserialize it back into a bean? You can see an attempt in the code below but it doesn't work. I'm about to go back to a Foreach instead of FormTable until I can find out how to get the submitted values.
Here are the relevent parts of what I have so far:
.page:
<property-specification name="searchParameterBean"
type="accolade.beans.SearchParameterBean"/>
<property-specification name="list" type="java.util.List"/>
<bean name="evenOdd" class="org.apache.tapestry.bean.EvenOdd" lifecycle="render"/>
<component id="dataTable" type="contrib:FormTable"> <binding name="source" expression="list"/> <static-binding name="columns">name, operator, searchText</static-binding> <binding name="rowsClass" expression="beans.evenOdd.next" /> </component>
<component id="operatorSelection" type="PropertySelection"> <binding name="value" expression="components.dataTable.tableRow.operator"/> <binding name="model" expression="operatorModel"/> </component>
<component id="searchText" type="ValidField">
<static-binding name="displayName" value=""/>
<binding name="value"
expression="components.dataTable.tableRow.searchText"/>
<binding name="validator" expression="beans.notRequired"/>
</component>
<component id="submitButton" type="Submit"> <message-binding name="value" key="submit"/> </component> <component id="cancelButton" type="Submit"> <binding name="listener" expression="listeners.cancel"/> <message-binding name="value" key="cancel"/> </component>
.html:
<form jwcid="form"> <A href="#" jwcid="@PageLink" page="PVSearchConfig"> Search
Configuration </a><BR>
<table class="accolade_table" jwcid="dataTable">
<tr jwcid="$remove$">
<td>Name</td>
<td>Operator</td>
<td>Search Value</td>
</tr>
<tr jwcid="$remove$">
<td>First Name:</td>
<td><select><option value="="/><option
value="<>"/><option value=">="/></select></td>
<td><input type="text"></td>
</tr>
</table>
<span jwcid="[EMAIL PROTECTED]">
<select jwcid="operatorSelection"><option value="="/><option
value="<>"/><option value=">="/></select>
</span>
<span jwcid="[EMAIL PROTECTED]">
<input jwcid="searchText" type="text"/>
</span>
<input jwcid="submitButton" type="submit" value="Search"
class="accolade_submit"/> <input jwcid="cancelButton"
type="submit" value="cancel" class="accolade_submit"/>
</form>
.java:
public void submit(IRequestCycle cycle) {
System.out.println("start of submit");
Visit visit = (Visit)getVisit();
List list = new ArrayList();
String[] rows = cycle.getRequestContext().getParameters("iterRows"); for(int i =0;i< rows.length;i++){ System.out.println("row content:" + rows[i]); ByteArrayInputStream bytes = new ByteArrayInputStream(rows[i].getBytes()); try { ObjectInputStream ois = new ObjectInputStream(bytes); SearchParameterBean sb = (SearchParameterBean)ois.readObject(); System.out.println(sb.getName() + ": " + sb.getSearchText()); list.add(sb); } catch (Exception ex) { ex.printStackTrace(); } }
Object[] params = buildParameters(list, visit.getCustomerRecid()); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
