Tutorials > Content management > Create a content-managed resource > Integrate the new resource
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
- In the Enterprise Explorer view, navigate to Other Projects > WebSphereCommerceServerExtensionsLogic.
- Right-click src and select New > Class.
- In the Package field, type com.mycompany.catalog.databeans
- In the Name field, type ExtendedCatalogDescriptionDataBean.
- From the Modifiers list, select public.
- Click the Browse button next to the Superclass field.
- In the Superclass Selection window, type ExtendedCatalogDescriptionAccessBean in the Choose a type field.
- In the Matching types box, select ExtendedCatalogDescriptionAccessBean.
- Click OK.
- Click the Add button next to the Interface box.
- In the Implemented Interfaces Selection window, type SmartDataBean in the Choose interfaces field.
- In the Implemented Interfaces Selection window, type InputDataBean in the Choose interfaces field.
- Click OK.
- Select the check box for Inherited abstract methods.
- Click Finish.
- 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;
- 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; }
- 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; }
- Press CTRL+SHIFT+O to organize imports and save the file.