- This topic has 5 replies, 4 voices, and was last updated 13 years, 7 months ago by jimmywestin982.
-
AuthorPosts
-
PeterMemberHi,
I would like to change the JET customization for CRUD services to return the object that the CRUD operation was performed on.
e.g.
change from:
public void saveAddress(Address address) { Address existingAddress = addressDAO.findAddressByPrimaryKey(address.getId()); if (existingAddress != null) { if (existingAddress != address) { ... ... } address = addressDAO.store(existingAddress); } else { address = addressDAO.store(address); } addressDAO.flush(); }
to:
public Address saveAddress(Address address) { Address existingAddress = addressDAO.findAddressByPrimaryKey(address.getId()); if (existingAddress != null) { if (existingAddress != address) { ... ... } address = addressDAO.store(existingAddress); } else { address = addressDAO.store(address); } addressDAO.flush(); return address; }
I really appreciate any help with this 🙂
jayperkinsMemberIn order to accomplish this, you will need to customize a couple of different things.
The operation methods that are generated are created by the scaffolding engine. The scaffolding engine creates models based on xml in the com.skyway.scaffolding.crud.spring plugin.xml file. We need to tell the scaffolding engine to add an output model to the saveDataTypeOperation model that will be created. We also need to update the saveCrudServiceImplementation.jet file so that the save method actually returns the data type.
I am attaching a customization project that contains the changes. There are two files that have changed:
1) plugin.xml – contains code to add a model output to the save operation – necessary otherwise you will get a compile error about not being able to return a value from a method that returns void
2) crudCommon/templates/crud/method/saveCrudServiceImplementation.jet – this generates the save method for the service and was changed to return the data type being saved
PeterMemberthanks for your help… but there is nothing attached?
jkennedyMemberI know that Jay sent along the file via email but I wanted to post it here for others who may want to see an example of how to customize the code generation in this way.
Attachments:
You must be logged in to view attached files.
PeterMemberThanks guys!
jimmywestin982Memberthank you for that helpful link huh…
-
AuthorPosts