Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    HowTo create an inherited class with the add-operation of the DataSource

    Hello,

    I've got an entity catalog which extends category. Now I've got a ListGrid showing all categories (including also the catalogs). When creating a new category I want to ask the user if it should be a catalog. How can I tell smartgtw server, to create a catalog entity instead of a category entity.

    btw., I use the Hibernate bean-binding and the add-operation is triggered by a databound component.

    #2
    In general, use a DMI to inject your own business logic to be performed instead of or in addition to the default persistence operation. See the QuickStart Guide for details.

    Comment


      #3
      Can you be a bit more specific please. What should be changed at the DSRequest so that another class is created by Hibernate? Do I have to override the HibernateDatasource? I could't find any parameter for declaring the class which is to be created.

      Comment


        #4
        This is all explained in copious detail in the QuickStart Guide. Read the whole of the Server Framework chapter, and be sure not to skim.

        Comment


          #5
          the only way I can see to accomplish the behaviour is to use 2 different datasources: one for the catalog and one for the category. But a DataboundComponent is bound only to one Datasource. I couldn't find any hint in the Quickstart Guide or JavaDoc how to modify the DSRequest to create an object of en extended class. Of cause I can write my own Datasource for this. But I would like to use the HibernateDatasource like in the example:

          Code:
          public DSResponse add(DSRequest dsRequest) throws Exception {
          // TODO set the Type of the Class to use
          return dsRequest.execute();
          }
          Last edited by andy.2003; 24 Sep 2012, 11:22.

          Comment


            #6
            If you're going to persist to two entities in general, yes you need two DataSources.

            One of the DMI samples in the QuickStart shows how you can create a DSRequest that targets a second DataSource. No subclasses or anything of the kind involved.

            Comment


              #7
              Thank you for pointing me on the fact that I need two seperated Datasources to achieve this behaviour. I thought there were any possibility to do this with just one Datasource (the one of the base class).

              Comment

              Working...
              X