1

我在 Aurora Store 上工作,我创建了一个刷新控制器来刷新一个区域。

但是控制器仅在第一次工作,这意味着当第一次加载页面并单击按钮时,我已经编写了刷新控制器,然后区域在该区域未刷新后才刷新,我错过了什么?

参考代码:

示例应用程序,用于在单击按钮时刷新包含人员详细信息的页面部分

1. 在 JavaScript 文件中定义上下文。上下文将处理并允许刷新区域,在 jsp 文件中设置控制器的 URL

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

2.把这个div放在需要刷新的区域之前

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

在这个 div 以下是内容

  ${person.email1}

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

        ${person.addressLine[0]}

        ${person.country}
                   </div>

3. 触发更新上下文的事件(按钮点击)

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

每次单击功能“updateInfo”都可以正常工作,但第一次刷新后无法正常工作。

4.struts-config-ext.xml

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

5.URL建设

 <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.控制器定义:要调用的URL,这里保持为null,因为这将在客户端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}
4

1 回答 1

0

问题解决了。我正在解析名称错误的小部件。

于 2017-03-27T04:15:06.700 回答