Hi,
I believe the reason is that the priceCalcData values get serialized
into the form, and when they get deserialized upon submit, the
deserialized items are different physical objects.
Here is a simple solution: If your priceCalcData have a property that is
a primary key, say 'id', you could add the following parameter to Table:
<binding name="keyExpression" value="literal: id"/>
That says that the OGNL expression 'id' will extract the primary key of
the objects in 'source'.
You will kill two birds with one stone that way:
- the objects will not be serialized -- only their IDs will be
stored as Hidden fields and that would make the HTML much nicer
- Upon rewind (when the form is submitted) the component will try to
match the keys in the Hidden fields with the keys of the objects in
'source'. The object with a matching primary key is then used. As a
result, no new physical object is created as with serialization, and
modifications apply to the original object (the one in 'source')
Try this -- it may help.
An alternative to the above is also to make the Table volatile:
<binding name="volatile" value="true"/>
That prevent the table from making Hidden fields (behaves like the Table
from 3.x), but that will likely cause a problem if 'source' changes
between requests (e.g. external database mods, mutiple browser windows,
etc). So this method is usually not appropriate.
Hope this is of use,
-mb
seloha . wrote:
I am using the new contrib:Table since I believe contrib:FormTable is
to de deprecated.
I think I have a very stupid mistake somewhere. I am trying to update
some fields, when I get the list of table data objects they still have
the old information prior to submission. If I put an invalid entry the
form fails validation an has the new data redisplayed with an error
message, this indicates something is working!
I am using beta-5 which was checked-out from the cvs about a week ago.
Some of the code:
.page:
<property name="priceCalcData"/>
<component id="priceCalcTable" type="contrib:Table">
<binding name="source" value="ognl:priceCalcData"/>
<binding name="convertor" value="ognl:priceCalcDataItemConvertor"/>
<binding name="columns"
value="literal:
airport,
areaPostcode,
noOfPeople,
!price,
!exclusivePrice,
!onewayPrice,
!onewayExclusivePrice"/>
<binding name="rowsClass" value="ognl:'priceCalcRowbgcolor' +
beans.evenOdd.next"/>
<binding name="pageSize" value="literal:20"/>
<binding name="row" value="ognl:rowObj"/>
<binding name="persist" value="literal:session"/>
</component>
example of one of the columns to update:
<component id="priceColumnValue" type="Block"/>
<component id="editablePrice" type="TextField">
<binding name="displayName" value="literal:Price"/>
<binding name="value"
value="ognl:components.priceCalcTable.tableRow.price"/>
<binding name="translator" value="translator:number,pattern=#.##"/>
<binding name="validators" value="validators:required,min=0"/>
<binding name="id" value="ognl:'price' + rowId"/>
</component>
template:
<table class="priceCalcTable" jwcid="priceCalcTable">
<tr jwcid="airportColumnValue">
<td jwcid="displayAirport" class="priceCalcRowColor"/>
</tr>
<tr jwcid="areaPostcodeColumnValue">
<td jwcid="displayAreaPostcode"/>
</tr>
<tr jwcid="noOfPeopleColumnValue">
<td jwcid="displayNoOfPeople" class="priceCalcRowColor"/>
</tr>
<tr jwcid="priceColumnValue">
<td jwcid="editablePrice" class="priceCalcRowColor"
align="right" size="8"/>
</tr>
<tr jwcid="exclusivePriceColumnValue">
<td jwcid="editableExclusivePrice"
class="priceCalcRowColor" align="right" size="8"/>
</tr>
<tr jwcid="onewayPriceColumnValue">
<td jwcid="editableOnewayPrice" class="priceCalcRowColor"
align="right" size="8"/>
</tr>
<tr jwcid="onewayExclusivePriceColumnValue">
<td jwcid="editableOnewayExclusivePrice"
class="priceCalcRowColor" align="right" size="8"/>
</tr>
</table>
java in the form listener:
if (validationDelegate.getHasErrors()) {
return;
}
List priceCalcData = getPriceCalcData();
this last line retrieves the original values prior to submission.
I probably haven't provided enough code or detail but maybe someone
could point me in the right direction. It almost works (funny), method
getPriceCalcData() is declared as:
public abstract List getPriceCalcData();
As previously stated the validation returns the page with the entered
incorrect value. It is almost like I am reading the value at the wrong
time, but there is only one listener on the form?
Any help appreciated,
Paul
---------------------------------------------------------------------
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]