CP2JavaWS 0.8 : Direct2CP Master/Detail view

Posted: July 14, 2009 in IT/Dev
Tags: , , , , , ,

masterDetailViewA new version of CP2JavaWS is available. Besides enhancements for CPTableViewDelegate and bug fixes, it brings a Direct2CP mode (Direct2Java like for CP client), that allows to display a Master/Detail view, by simply providing the CP elements class name (and additional selection criteria for the master table if needed) :

– refactored the request management (mode switch, CPURLConnection/CPJSONP creation, delegate and auth. delegate creation, encoding and decoding) in a new class, CP2JavaWSHttpSender, as it is used by both CPRemoteService and CP2JavaWSTableViewDelegate. The CP2JavaWSHttpSender allows to specify if call arguments have to be encoded (CP to js conversion before js to JSON), and if result has to be decoded (js to CP after JSON to js).

– For remote service methods that have generic argument types (Object), we can now pass to the CP2JavaWSHttpSender an array of generic parameters indexes (required as on the Java server side we then cannot discover the generic Object type from the passed parameter value).

– reponses with error code didn’t trigger anymore the failHandler since CPURConnection doesn’t check anymore for error codes (in order to allow to perform action depending on the error code).

– fixed a problem in Decoder, where empty Date on JS object was setted as undefined on the CP object instead of null, and where JS boolean fields with false value where treated as unset.

– CP2JavaWSTableViewDelegate can now be used in two modes : in the first mode the full CP objects are returned for each requested row (slower but we then still have the full object if we select it for editing in the detail view – then no need for additional read request).
In the second mode the return (for a row) is a tab of values (each value is the final attribute corresponding to the specified attribute path – setted as the column’s id), that is faster (attributes paths are passed to the select HQL request – faster than a select *, and no decoding occurs on the client side – result encoding to JSON on the server side is also faster) but requires an additional read for editing. In both cases the displayed values correspond to the columns’ ids, and can be nested attributes paths.

– a new object, CP2JavaWSMasterDetailView allows to display and manage automatically a Master/Detail view for a specified CP business class (sort of a Direct2CP, that uses CP2JavaWSTableViewDelegate). We can specify specific attributes paths to display in the master view (tableView), as we may want to display only a few of those (and the whole attributes values in the detail view). If not precised, the master view will display a column for each attribute (the elements CP class ivars are introspected recursively – so we get a column for each nested CP object’s attributes).
endPoint1 = [CP2JavaWSEndPoint createForURL:"http://host/appName/endpointName"];
var masterDetailView = [CP2JavaWSMasterDetailView createForEndPoint:endPoint1 elementsClassName:"MyCustomClass" idAttName:"customerId" masterAttributes:["customerId", "name", "age"] criterias:nil rect:CGRectMake(x, y, w, h)];

Depending on the attribute type (string/integer, boolean, date) the detail view adds a CPTextField, CPCheckBox, etc. To use combo lists for some attributes values editing,  a next update will allow to specify RemoteValuesListDescriptors, that will store the endpoint (if different) and remote services (if many) that return the corresponding combo lists values.
By clicking on a row in the master view (tableView), the detail view fields are automatically filled. The detail view contains a Modify button, that automatically calls the generic RemoteDAOService to update the object.
We can pass a custom detail view if needed (that will have to implement some delegate methods to fill the editing fields, and use the provided DetailViewDelegate for changes submission).

Note : the Objective-J/preprocess.js (or Frameworks/Objective-J/Objective-J.js) has to be modified using the provided file changes in order to manage ivar types (required for the new MasterDetail view).


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s