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

< Previous | Next >


Create a new data bean

A data bean is a Java bean that is used in JSP pages to retrieve information from the enterprise bean. This data bean is used to display the extended description information in a store JSP page.


Procedure

  1. In the Enterprise Explorer view, navigate to Other Projects > WebSphereCommerceServerExtensionsLogic.

  2. Right-click src and select New > Class.

  3. In the Package field, type com.mycompany.catalog.databeans

  4. In the Name field, type ExtendedCatalogDescriptionDataBean.

  5. From the Modifiers list, select public.

  6. Click the Browse button next to the Superclass field.

  7. In the Superclass Selection window, type ExtendedCatalogDescriptionAccessBean in the Choose a type field.

  8. In the Matching types box, select ExtendedCatalogDescriptionAccessBean.

  9. Click OK.

  10. Click the Add button next to the Interface box.

  11. In the Implemented Interfaces Selection window, type SmartDataBean in the Choose interfaces field.

  12. In the Implemented Interfaces Selection window, type InputDataBean in the Choose interfaces field.

  13. Click OK.

  14. Select the check box for Inherited abstract methods.

  15. Click Finish.

  16. Add some instance variables to the class.

            private CommandContext iCommandContext = null;
            protected com.ibm.commerce.datatype.TypedProperty iRequestProperties;
            protected java.lang.String iDataBeanKeyCatalogReferenceNumber;
            protected java.lang.String iDataBeanKeyLanguage_id;
    

  17. Modify some generated methods for the data bean:

    /**
             * Populates the data bean.
             * @see com.ibm.commerce.beans.SmartDataBean#populate()
             */
            public void populate() throws Exception {
                   try {
                           super.refreshCopyHelper();             
                   } 
                   catch (javax.ejb.FinderException e) {
                             throw new ECSystemException(ECMessage._ERR_CREATE_EXCEPTION, "ExtendedCatalogDescriptionDataBean", "populate");
                   }
            }
     
            /**
             * Gets the request properties.
             * @return The command context.
             */
            public TypedProperty getRequestProperties() {
                   return iRequestProperties;
            }
     
            /**
             * Sets the request properties.
             * @param aRequestProperty The request properties.
             */
            public void setRequestProperties(com.ibm.commerce.datatype.TypedProperty aRequestProperty) throws javax.ejb.CreateException, java.rmi.RemoteException, javax.naming.NamingException, javax.ejb.FinderException {
                iRequestProperties = aRequestProperty;
                try {
                    if (getDataBeanKeyCatalogReferenceNumber() == null) {               
                        setDataBeanKeyCatalogReferenceNumber(aRequestProperty.getString(com.ibm.commerce.server.ECConstants.EC_CATALOG_ID));
                    }
     
                } catch (com.ibm.commerce.exception.ParameterNotFoundException e) {
                }
                try {
                    if (getDataBeanKeyLanguage_id() == null) {
                        setDataBeanKeyLanguage_id(aRequestProperty.getString(com.ibm.commerce.server.ECConstants.EC_LANGUAGE_ID));
                    }
                } catch (com.ibm.commerce.exception.ParameterNotFoundException e) {
                }
            }       
            
            /**
             * Gets the command context.
             * @return The command context.
             */
            public com.ibm.commerce.command.CommandContext getCommandContext() {
                   return iCommandContext;
            }
            
            /**
             * Sets the command context.
             * @param aCommandContext The command context
             */
            public void setCommandContext(com.ibm.commerce.command.CommandContext aCommandContext) {
                   iCommandContext = aCommandContext;
            }
    

  18. Add some new methods to the data bean to set and get the instance variables, and set the initial keys for the access bean.

    /**
             * Sets the catalog reference number.
             * @param aCatalogReferenceNumber The catalog reference number.
             */
            public void setDataBeanKeyCatalogReferenceNumber(java.lang.String aCatalogReferenceNumber) {
                iDataBeanKeyCatalogReferenceNumber = aCatalogReferenceNumber;
                super.setInitKey_catalog_id(new Long(aCatalogReferenceNumber));
            }
            
            /**
             * Sets the language ID.
             * @param aLanguage_id The language ID.
             */
            public void setDataBeanKeyLanguage_id(java.lang.String aLanguage_id) {
                iDataBeanKeyLanguage_id = aLanguage_id;
                super.setInitKey_language_id(new Integer(aLanguage_id));
            }
            
            /**
             * Gets the catalog reference number.
             * @return The catalog reference number.
             */
            public java.lang.String getDataBeanKeyCatalogReferenceNumber() {
                return iDataBeanKeyCatalogReferenceNumber;
            }
            
            /**
             * Gets the language ID.
             * @return The language ID.
             */
            public java.lang.String getDataBeanKeyLanguage_id() {
                return iDataBeanKeyLanguage_id;
            }
    

  19. Press CTRL+SHIFT+O to organize imports and save the file.

< Previous | Next >


+

Search Tips   |   Advanced Search