• Rating control broken on Domino 9...

    By Serdar Basegmez 1 decade ago

     

    Since Dojo has changed implementation in 1.8.x, Rating control is broken on Domino 9. 
    
     
    
    The new implementation is calling onchange method (where we submit the new value to the server) on initialization. I will probably change Rating widget entirely as soon as possible.
    
     
    
    For a temporary fix, you need to make a couple of changes in xiRating custom control.
    
     
    
    Open the source pane for xiRating and replace the following div with the new panel object...
    
     
    
    <xp:div id="ratingEditable" styleClass="involveRatingStarWrapper">
    
    .....
    
    .....
    
    </xp:div><!-- end-ratingEditable -->
    
     
    
    will become
    
     
    
    <xp:panel id="ratingEditable" styleClass="involveRatingStarWrapper">
    
    <xp:this.rendered><![CDATA[#{javascript:invTools.isRatingEnabled(compositeData)}]]></xp:this.rendered>
    
    <xp:div id="rateThis" dojoType="dojox.form.CustomRating">
    
    <xp:this.dojoAttributes>
    
    <xp:dojoAttribute name="numStars"
    
    value="#{javascript:compositeData.starCount || invTools.defaults.starCount}">
    
    </xp:dojoAttribute>
    
    <span style="color:#696969;">&lt;!-- &lt;xp:dojoAttribute name=&quot;onchange&quot; value=&quot;setRating(&#39;#{compositeData.ccId}&#39;, &#39;#{id:ratingPanel}&#39;, this.value)&quot;&gt;&lt;/xp:dojoAttribute&gt;--&gt;</span></div>
    
    &lt;xp:dojoAttribute name=&quot;value&quot; value=&quot;#{javascript:Math.round(invTools.getTotalRating(compositeData.ccId))}&quot;&gt;&lt;/xp:dojoAttribute&gt;
    
    &lt;/xp:this.dojoAttributes&gt;
    
    &lt;/xp:div&gt;
    
    &lt;xe:jsonRpcService id=&quot;ratingRpcService1&quot; serviceName=&quot;rating#{compositeData.ccId}&quot; state=&quot;true&quot;&gt;
    
    &lt;xe:this.methods&gt;
    
    &lt;xe:remoteMethod name=&quot;setRating&quot; script=&quot;return invTools.setRating(compositeData,rating);&quot;&gt;
    
    &lt;xe:this.arguments&gt;
    
    &lt;xe:remoteMethodArg name=&quot;rating&quot; type=&quot;number&quot;&gt;&lt;/xe:remoteMethodArg&gt;
    
    &lt;/xe:this.arguments&gt;
    
    &lt;/xe:remoteMethod&gt;
    
    &lt;/xe:this.methods&gt;
    
    &lt;/xe:jsonRpcService&gt;
    
    &lt;xp:eventHandler event=&quot;onClientLoad&quot;
    
    submit=&quot;false&quot;&gt;
    
    &lt;xp:this.script&gt;&lt;![CDATA[
    
    dojo.connect(dijit.byId(&quot;#{id:rateThis}&quot;), &quot;onChange&quot;, function(newValue){
    
    setRating(&#39;#{javascript:compositeData.ccId}&#39;, &#39;#{id:ratingPanel}&#39;, newValue);
    
    });]]&gt;&lt;/xp:this.script&gt;
    
    &lt;/xp:eventHandler&gt;
    
    &lt;/xp:panel&gt;&lt;!-- end-ratingEditable --&gt;
    
    &nbsp;
    
    As you see we removed declared onchange event for the rating widget. Instead, we are connecting this event AFTER page has been loaded.
    
    &nbsp;
    

    Since I will already convert this control to an extension soon, I didn't uploaded the fix yet. I hope this helps...

    • By Serdar Basegmez 9 years ago

      Format broken in transfer. Pasting again

      Since Dojo has changed implementation in 1.8.x, Rating control is broken on Domino 9.

      The new implementation is calling onchange method (where we submit the new value to the server) on initialization. I will probably change Rating widget entirely as soon as possible.

      For a temporary fix, you need to make a couple of changes in xiRating custom control. Open the source pane for xiRating and replace the following div with the new panel object…

      <xp:div id="ratingEditable" styleClass="involveRatingStarWrapper">
      
      .....
      
      .....
      
      </xp:div><!-- end-ratingEditable -->
      

      will become

      <xp:panel id="ratingEditable" styleClass="involveRatingStarWrapper">
          <xp:this.rendered><![CDATA[#{javascript:invTools.isRatingEnabled(compositeData)}]]></xp:this.rendered>
          <xp:div id="rateThis" dojoType="dojox.form.CustomRating">
              <xp:this.dojoAttributes>
              <xp:dojoAttribute 
                  name="numStars"
                  value="#{javascript:compositeData.starCount || invTools.defaults.starCount}"></xp:dojoAttribute>
              <xp:dojoAttribute 
                  name="value"
                  value="#{javascript:Math.round(invTools.getTotalRating(compositeData.ccId))}"></xp:dojoAttribute>
              </xp:this.dojoAttributes>
          </xp:div>
      
          <xe:jsonRpcService id="ratingRpcService1" serviceName="rating#{compositeData.ccId}" state="true">
              <xe:this.methods>
                  <xe:remoteMethod name="setRating" script="return invTools.setRating(compositeData,rating);">
                      <xe:this.arguments>
                          <xe:remoteMethodArg name="rating" type="number"></xe:remoteMethodArg>
                      </xe:this.arguments>
                  </xe:remoteMethod>
              </xe:this.methods>
          </xe:jsonRpcService>
      
          <xp:eventHandler 
              event="onClientLoad"
              submit="false">
              <xp:this.script><![CDATA[
                  dojo.connect(dijit.byId("#{id:rateThis}"), "onChange", function(newValue){
                      setRating("#{javascript:compositeData.ccId}", "#{id:ratingPanel}", newValue);
                  });
              ]]></xp:this.script>
          </xp:eventHandler>
      </xp:panel><!-- end-ratingEditable -->
      

      As you see we removed declared onchange event for the rating widget. Instead, we are connecting this event AFTER page has been loaded.