facebook

How to Adjust JET Customization

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #316622 Reply

    Peter
    Member

    Hi,

    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 🙂

    #316866 Reply

    jayperkins
    Member

    In 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

    #316887 Reply

    Peter
    Member

    thanks for your help… but there is nothing attached?

    #316896 Reply

    jkennedy
    Member

    I 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.
    #316904 Reply

    Peter
    Member

    Thanks guys!

    #317014 Reply

    thank you for that helpful link huh…

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: How to Adjust JET Customization

You must be logged in to post in the forum log in