开发者

Generic DataGrid for editing objects stored on a server

开发者 https://www.devze.com 2023-03-14 19:31 出处:网络
I\'ve knocked together a Java/BlazeDS server which creates a generic GridBean object. This GridBean contains:

I've knocked together a Java/BlazeDS server which creates a generic GridBean object. This GridBean contains:

  • List<ColumnDef> where a ColumnDef contains the column header, field name
  • List<Object> where my object is some java pojo containing PropertyChangeSupport

I then created a Flex app that uses a RemoteObjectServiceWrapper to call my java server, grab the GridBean, create some DataGrid columns from the columnDefs and then set the dataProvider as the list of objects. Ok so far, everything renders.

Now, what I'd really like to do is: set up some kind of event handler on the flex side so that if my item/object is edited in the datagrid, I fire a message off to java saying 'edited this field on this item'. The end goal is to have a nice generic way to render any list开发者_JAVA技巧 of objects from Java in a flex datagrid.


Effectively you're talking about ManagedObjects, which are not supported natively in BlazeDS. (It's available as an out-of-the-box feature of LCDS).

However, there are 3rd party tools which give you this functionality.

Farata systems offers Clear Builder (which I believe offers CRUD support via generated code).

There's also dpHibernate (which I should disclose I'm one of the main developers of).

Using dpHibernate, what you're after is achievable like so:

public function updateObject():void
{
     var book:Book; // loaded from the server earlier in the application
     book.title = "Clean Code";
     book.save();
}

Your entity class (in this example, Book) is only required to implement a couple of simple interface methods (which deal primarily with the concept of identity), and does not require any generated code.

There's a pretty complete working example of this update functionality available here.

0

精彩评论

暂无评论...
验证码 换一张
取 消