jqueryajaxdojowebsphere-commercewcs

WCS AJAX refresh using dojo and controller


I am working on Aurora Store, I have created a refresh controller to refresh an area.

But the controller works only first time, means when the page loaded first time and thebutton is clicked on which I have written the refresh controller only then area gets refresh after that area doesn't get refreshed, what am I missing?

code for reference:

Sample Application for refreshing a section of a page with person details on click of a button

1. Defined the context in a JavaScript file. The context will handle and allow refreshing the area, Set controller's URL in a jsp file

 wc.render.declareContext("MyAreaContext",null,""),
  SBControllersDeclarationJS.setControllerURL('CustomController','<c:out value="${AjaxCustomInformationViewURL}"/>');

2. Put this div before the area which needs to be refreshed

  <div dojotype="wc.widget.RefreshArea" widgetid="RefreshAreaDisplay" 
                controllerid="CustomController" id="RefreshCustomAreaDisplay" role="wairole:region" 
                waistate:live="polite" waistate:atomic="false" waistate:relevant="all">  

within this div following is the content

  ${person.email1}

        ${person.firstName} ${person.lastName}

        ${person.addressLine[0]}

        ${person.country}
                   </div>

3. Event(button click) which triggers update Context

<a role="button"
                       id="WC_Custom_links_1" tabindex="0"
                       href="JavaScript:CustomHelper.updateInfo();      wc.render.updateContext('CustomAreaContext');">

Function "updateInfo" is working fine each time clicked but refresh is not working after first time.

4. Struts-config-ext.xml

 <forward className="com.ibm.commerce.struts.ECActionForward" name="CurrentCustomView/47401" path="/ShoppingArea/CustomInfo.jsp"/> 

5.URL construction

 <wcf:url var="AjaxCustomInformationViewURL" value="CurrentCustomView" type="Ajax">
                  <wcf:param name="langId" value="${langId}" />                        
                  <wcf:param name="storeId" value="${WCParam.storeId}" />
                <wcf:param name="catalogId" value="${WCParam.catalogId}" />
               <wcf:param name="orderId" value="${currentOrderId}" />
           </wcf:url>

6. Controller definition : URL to be called, here kept it as null because this will be updated in the client jsp

         <script type="text/javascript">
                wc.render.declareRefreshController({
                id: "CustomController",
               renderContext: wc.render.getContextById("CustomAreaContext"),
               url: "",
             formId: ""
             ,modelChangedHandler: function(message, widget) {

               var controller = this;
                var renderContext = this.renderContext;
                widget.refresh(renderContext.properties);
              cursor_clear();  


             }
           ,renderContextChangedHandler: function(message, widget) {

          var controller = this;
          var renderContext = this.renderContext;
          widget.refresh(renderContext.properties);
           cursor_clear();  

         }
       ,postRefreshHandler: function(widget) {
        var controller = this;
        var renderContext = this.renderContext;
        cursor_clear();

       }
      });
   </script>

7. CustomInfo.jsp

  <wcf:rest var="person" url="store/{storeId}/person/@self"
            scope="request">
            <wcf:var name="storeId" value="${WCParam.storeId}" encode="true" />
</wcf:rest>

        ${person.email1}

        ${person.firstName} ${person.lastName}

Solution

  • Issue resolved. I was parsing the widget with wrong name.