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

< Previous | Next >


Update NavCatCatalogUpdateContent.jsp

This WebSphere Commerce Accelerator JSP will be modified to include new fields for the new extended catalog information. When a sales catalog is being updated, the fields will be populated with the previous information entered.


Procedure

  1. In the Enterprise Explorer view, navigate to CommerceAccelerator > WebContent > tools > catalog.

  2. Find NavCatCatalogUpdateContent.jsp in the list of JSP files, and double-click the file to open it in the editor.

  3. Add HTML form elements to capture the extended information. Insert this into the JSP file before the </TABLE> tag.

    <TR>
    <TD>
    <LABEL for="CatalogFrontImage">
    <%=UIUtil.toHTML((String)rbCategory.get("NavCatCatalogCreate_Frontimage"))%>
    </LABEL>
    </TD>
    </TR>
    
               
    <TR>
    <TD>
    <INPUT SIZE=60 MAXLENGTH=254 ONBLUR=updateLanguageInfo() ID="CatalogFrontImage" NAME=CatalogFrontImage VALUE="">
    </TD>
    </TR>
    
                
               
    <TR>
    <TD>
    <LABEL for="CatalogBackImage">
    <%=UIUtil.toHTML((String)rbCategory.get("NavCatCatalogCreate_Backimage"))%>
    </LABEL>
    </TD>
    </TR>
    
               
    <TR>
    <TD>
    <INPUT SIZE=60 MAXLENGTH=254 ONBLUR=updateLanguageInfo() ID="CatalogBackImage" NAME=CatalogBackImage VALUE="">
    </TD>
    </TR>
    
                
               
    <TR>
    <TD>
    <LABEL for="CatalogSideImage">
    <%=UIUtil.toHTML((String)rbCategory.get("NavCatCatalogCreate_Sideimage"))%>
    </LABEL>
    </TD>
    </TR>
    
               
    <TR>
    <TD>
    <INPUT SIZE=60 MAXLENGTH=254 ONBLUR=updateLanguageInfo() ID="CatalogSideImage" NAME=CatalogSideImage VALUE="">
    </TD>
    </TR>
    
                
               
    <TR>
    <TD>
    <LABEL for="CatalogTopImage">
    <%=UIUtil.toHTML((String)rbCategory.get("NavCatCatalogCreate_Topimage"))%>
    </LABEL>
    </TD>
    </TR>
               
    <TR>
    <TD>
    <INPUT SIZE=60 MAXLENGTH=254 ONBLUR=updateLanguageInfo() ID="CatalogTopImage" NAME=CatalogTopImage VALUE="">
    </TD>
    </TR>
    

  4. Add the page following page import to the JSP file:

    <%@ page import = "com.mycompany.catalog.objects.ExtendedCatalogDescriptionAccessBean"%>
    

  5. Modify some existing JavaScript functions. Add the code in italics to the following functions:

    //////////////////////////////////////////////////////////////////////////////////////
          // descriptionObject(languageId) 
          //
          // @param languageId - the language of this description object
          //
          // - this defines the description object for the specified language
          //////////////////////////////////////////////////////////////////////////////////////
          function descriptionObject(languageId) 
          {
                this.languageId = languageId;
                this.name             = "";
                this.shortDescription = "";
                this.longDescription  = "";
                this.thumbnail        = "";
                this.fullimage        = "";
                this.frontimage         = "";
                this.backimage          = "";
                this.sideimage          = "";
                this.topimage           = "";       
          }
    
         //////////////////////////////////////////////////////////////////////////////////////
          // selectLanguage() 
          //
          // - this function saves the values when a language is selected
          //////////////////////////////////////////////////////////////////////////////////////
          function selectLanguage()
          {
                var i = languageSelect.selectedIndex;
                if (i == 0)
                {
                      CatalogCode.disabled = false;
                      CatalogDesc.disabled = false;
                }
                else
                {
                      CatalogCode.disabled = true;
                      CatalogDesc.disabled = true;
                }
                CategoryName.value      = vLanguages[i].name;
                CategoryShortDesc.value = vLanguages[i].shortDescription;
                CategoryLongDesc.value  = vLanguages[i].longDescription;
                CategoryThumbNail.value = vLanguages[i].thumbnail;
                CategoryFullImage.value = vLanguages[i].fullimage;
                
                CatalogFrontImage.value = vLanguages[i].frontimage;
                CatalogBackImage.value  = vLanguages[i].backimage;
                CatalogSideImage.value  = vLanguages[i].sideimage;
                CatalogTopImage.value   = vLanguages[i].topimage;           
          }
          //////////////////////////////////////////////////////////////////////////////////////
          // updateLanguageInfo() 
          //
          // - this function updates the information upon language change
          //////////////////////////////////////////////////////////////////////////////////////
          function updateLanguageInfo()
          {
                var i = languageSelect.selectedIndex;
                vLanguages[i].name             = CategoryName.value;
                vLanguages[i].shortDescription = CategoryShortDesc.value;
                vLanguages[i].longDescription  = CategoryLongDesc.value;
                vLanguages[i].thumbnail        = CategoryThumbNail.value;
                vLanguages[i].fullimage        = CategoryFullImage.value;
                
                vLanguages[i].frontimage       = CatalogFrontImage.value;
                vLanguages[i].backimage        = CatalogBackImage.value;
                vLanguages[i].sideimage        = CatalogSideImage.value;
                vLanguages[i].topimage         = CatalogTopImage.value;
          )
    

  6. Modify the JSP scriptlet to preload the extended description information. Look for the following code, and add the content in italics:

    <%
          for (int i=0; i<iLanguages.length; i++) 
          {
                LanguageDescriptionDataBean bnLanguage = new LanguageDescriptionDataBean();
                bnLanguage.setDataBeanKeyDescriptionLanguageId(iLanguages[i].toString());
                bnLanguage.setDataBeanKeyLanguageId(cmdContext.getLanguageId().toString());
                DataBeanManager.activate(bnLanguage, cmdContext);
                vLanguages.addElement(bnLanguage.getDescription());
     
                try 
                {
                      CatalogDescriptionAccessBean abCatalogDsc = abCatalog.getDescription(iLanguages[i]);
     
                      // Retrieve the Extended Catalog Description.
                      ExtendedCatalogDescriptionAccessBean abExtCatalogDsc = new ExtendedCatalogDescriptionAccessBean();
                      abExtCatalogDsc.setInitKey_catalog_id(new Long(strCatalogId));
                      abExtCatalogDsc.setInitKey_language_id(cmdContext.getLanguageId());
                      abExtCatalogDsc.refreshCopyHelper();
                      
    %>
                      vLanguages[<%=i%>] = new descriptionObject("<%=iLanguages[i]%>") ;
                      vLanguages[<%=i%>].name             = "<%=UIUtil.toJavaScript(abCatalogDsc.getName())%>";
                      vLanguages[<%=i%>].shortDescription = "<%=UIUtil.toJavaScript(abCatalogDsc.getShortDescription())%>";
                      vLanguages[<%=i%>].longDescription  = "<%=UIUtil.toJavaScript(abCatalogDsc.getLongDescription())%>";
                      vLanguages[<%=i%>].thumbnail        = "<%=UIUtil.toJavaScript(abCatalogDsc.getThumbNail())%>";
                      vLanguages[<%=i%>].fullimage        = "<%=UIUtil.toJavaScript(abCatalogDsc.getFullIImage())%>";
     
                      vLanguages[<%=i%>].frontimage       = "<%=UIUtil.toJavaScript(abExtCatalogDsc.getFrontImg())%>";
                      vLanguages[<%=i%>].backimage        = "<%=UIUtil.toJavaScript(abExtCatalogDsc.getBackImg())%>";
                      vLanguages[<%=i%>].sideimage        = "<%=UIUtil.toJavaScript(abExtCatalogDsc.getSideImg())%>";
                      vLanguages[<%=i%>].topimage         = "<%=UIUtil.toJavaScript(abExtCatalogDsc.getTopImg())%>";
          
    <%
                } 
                catch (Exception e) 
                {
    %>
                      vLanguages[<%=i%>] = new descriptionObject("<%=iLanguages[i]%>") ;
    <%
                }
          }
    %>
    

  7. Save the file.

< Previous | Next >


+

Search Tips   |   Advanced Search