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.

  1. consider ajaxformloop element on tapestry form:

    <tr t:type="ajaxformloop" t:id="items" source="getitems()" value="item">

    ...

    </tr>

  2. getitems() method inside class returns synthetic combination (list interface) of persisted objects , not-yet-persisted newly added items (with null id inside them).

  3. 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

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -