Version: SmartGWT 3.0 Power
I'm currently updating an application that was done with the LGPL version with a lot of server side Hibernate code and GWT-RPCs.
Currently all my XML datasource files are several lines long: ID=x, serverType=sql, tableName=x, and autoDeriveSchema=true. I haven't had the need for anything complex yet as I'm just starting out with the CRUD operations for the app's static data and getting used to the idea of working with datasources only.
One scenario I've come across I'm not sure what the best way is to implement: I have a screen that lets the user create a new parent object, and a ListGrid on that screen where they create child objects of the parent.
In creating a new child:
This screen does both create and update, depending on whether its been given an instance of the parent record when its called (this is where selectedParentID comes from too)
Obviously, this only works if the the parent instance already exists in the database.
In the old version of the application, the objects were all created client side and sent over GWT-RPC and the Hibernate code dealt with whether it should save or edit, and I was able to control the order in which that happened, so even if the parent object was also new, I could save the parent first, update the client-created child objects with the new ID of the parent and then save the children.
What should I be trying to do to maximise the use of SQLDataSource if I want to achieve the same thing of saving both parent and children at the same time?
I'm currently updating an application that was done with the LGPL version with a lot of server side Hibernate code and GWT-RPCs.
Currently all my XML datasource files are several lines long: ID=x, serverType=sql, tableName=x, and autoDeriveSchema=true. I haven't had the need for anything complex yet as I'm just starting out with the CRUD operations for the app's static data and getting used to the idea of working with datasources only.
One scenario I've come across I'm not sure what the best way is to implement: I have a screen that lets the user create a new parent object, and a ListGrid on that screen where they create child objects of the parent.
In creating a new child:
Code:
cmdAdd.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Record record = new Record(); record.setAttribute("name", "New child"); record.setAttribute("parent_id", selectedParentID); childGrid.startEditingNew(record); } });
Obviously, this only works if the the parent instance already exists in the database.
In the old version of the application, the objects were all created client side and sent over GWT-RPC and the Hibernate code dealt with whether it should save or edit, and I was able to control the order in which that happened, so even if the parent object was also new, I could save the parent first, update the client-created child objects with the new ID of the parent and then save the children.
What should I be trying to do to maximise the use of SQLDataSource if I want to achieve the same thing of saving both parent and children at the same time?
Comment