java - Unable to convert client value 'null' back into a server-side object -
this question tapestry
components issue.
i'm looking solution of issue, not workaround or alternative ways, how implement interface.
consider
ajaxformloop
element ontapestry
form:<tr t:type="ajaxformloop" t:id="items" source="getitems()" value="item">
...
</tr>
getitems()
method inside class returns synthetic combination (list
interface) of persisted objects , not-yet-persisted newly added items (withnull
id inside them).when submitting form receive error:
unable convert client value 'null' server-side object
this error occurs before onsuccessfromsave()
method (save
id of submit link).
i wonder, how can manage such not-persisted objects ajaxformloop
prevent such error. actually, want save (in db) these items inside onsucceccfrom...()
method.
what have missed here?
actually i've missed custom valueencoder
ajaxformloop
container. mentioned error produced default encoder
of component.
custom encoder should set in such way:
<tr t:type="ajaxformloop" t:id="items" source="getitems()" value="item" encoder="itemencoder">
where itemencoder
@property
annotated field in java class:
@property private valueencoder<myitem> itemencoder = new valueencoder<myitem>() { @override public string toclient(myitem value) { return value.id != null ? value.id.tostring() : ""; } @override public myitem tovalue(string clientvalue) { if (clientvalue != null && !clientvalue.isempty()) { long id = long.parselong(clientvalue); return (myitem) session.get(myitem.class, id); } return new myitem(); } };
Comments
Post a Comment