Tutorials > Content management > Create a content-managed resource > Creating the new resource

< Previous | Next >


Create new ejbCreate and ejbPostCreate methods

The ejbCreate() method is used to insert a row into the database table and must be added to the ExtendedCatalogDescriptionBean.


Procedure

  1. In the Java EE Hierarchy view, expand WebSphereCommerceServerExtensionsData.

  2. Expand Deployment Descriptor: WebSphereCommerceServerExtensionsData > Entity Beans > ExtendedCatalogDescription, and open the ExtendedCatalogDescriptionBean class.

  3. Create a new ejbCreate(EntityBeanCreationData data) method, by adding the following code into the class:

    public com.mycompany.catalog.objects.ExtendedCatalogDescriptionKey ejbCreate(EntityBeanCreationData data)
       throws javax.ejb.CreateException {
    
      _initLinks();
           
      ExtendedCatalogDescriptionEntityBeanCreationData
    extendedCatalogData = (ExtendedCatalogDescriptionEntityBeanCreationData) data;
      setCatalog_id(extendedCatalogData.getCatalog_id());
      setLanguage_id(extendedCatalogData.getLanguage_id());
      setLastModified(extendedCatalogData.getLastModified());
      setFrontImg(extendedCatalogData.getFrontImg());
      setBackImg(extendedCatalogData.getBackImg());
      setSideImg(extendedCatalogData.getSideImg());
      setTopImg(extendedCatalogData.getTopImg());
          
    
          return null;
    }
    
    

  4. Press Ctrl+Shift+O to organize imports. The class EntityBeanCreationData should now be found.

  5. Save the code changes. The following warning might be displayed in the Ttask view: This class should implement a matching ejbPostCreate method for this method. You create the ejbPostCreate method later in this tutorial.

  6. You must add the new ejbCreate(EntityBeanCreationData data ) method to the home interface. This makes the method available in the generated access bean. In the Outline view, right-click the ejbCreate(EntityBeanCreationData data) method and select Enterprise Bean > Promote to Home Interface. Next we will create a new ejbPostCreate(EntityBeanCreationData data) method so that it has the same parameters as the ejbCreate(EntityBeanCreationData data) method. Every ejbCreate(arg1, arg2…) method must have a corresponding ejbPostCreate(arg1, arg2…) method according to the EJB specification requirements. Create a new ejbPostCreate(EntityBeanCreationData data) method so that it has the same parameters as the ejbCreate(EntityBeanCreationData data) method:

  7. In the ExtendedCatalogDescriptionBean class, create a new ejbPostCreate(EntityBeanCreationData data) method, by adding the following code into the class:

    public void ejbPostCreate (EntityBeanCreationData data)
       throws javax.ejb.CreateException
    {}
    

  8. Press Ctrl+Shift+O to organize imports. The class EntityBeanCreationData should now be found.

  9. Save the code changes. The warning about a missing matching ejbPostCreate method is resolved.

< Previous | Next >


+

Search Tips   |   Advanced Search