JavaScript WSO2 ESB Iterate Counter wso2 esb iterate counter

I'm using the iterate mediator for saving files. For this I need a counter for the iterations. I tried to create an property outside of the iteration and use the script mediator to count the iterations like follows.

  <property name="AttachmentCounter" value="0"/>
      <iterate xmlns:ns="http://org.apache.synapse/xsd" continueParent="true" expression="$body/ticket/IctAttachments/item" id="IctAttachments" sequential="true">
         <target>
            <sequence>
               <script language="js">
                 <![CDATA[var counter = mc.getProperty("AttachmentCounter");
                 counter = parseInt(counter) + 1; 
                 mc.setProperty("AttachmentCounter", counter);]]>
               </script>
               <log>
                 <property name="AttachmentCounter:" expression="get-property('AttachmentCounter')"/>
               </log>
           </sequence>
        </target>
     </iterate>

The Problem is, that I get the same number after every iteration. Whats the reason for this? Is there a mistake I don't see? Maybe there is another way I couldn't find while searching the internet.

Answer:1

Try solution suggested in this blog-post: http://bsenduran.blogspot.ru/2015/07/how-to-get-wso2-esb-iterate-mediators.html:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="count_iterate"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="it_count" value="0" scope="operation"/>
         <iterate expression="//symbols/symbol" sequential="true">
            <target>
               <sequence>
                  <property name="synapse_it_count" expression="get-property('operation', 'it_count')"/>
                  <script language="js">var cnt_str = mc.getProperty('synapse_it_count');
     var cnt = parseInt(cnt_str);
     cnt++;
     mc.setProperty('synapse_it_count', cnt.toString());</script>
                  <property name="it_count" expression="get-property('synapse_it_count')" scope="operation"/>
                  <aggregate>
                     <completeCondition>
                        <messageCount min="-1" max="-1"/>
                     </completeCondition>
                     <onComplete expression="//symbol">
                        <log level="custom">
                           <property name="number of symbols" expression="get-property('operation','it_count')"/>
                        </log>
                        <respond/>
                     </onComplete>
                  </aggregate>
               </sequence>
            </target>
         </iterate>
      </inSequence>
   </target>
   <description/>
</proxy>                  
Answer:2

Im working with jquery mobile in my project and what i trying to do instead to use the swipe effect, use two button to change to the next and to the previous data-role=page. im trying with this ...

Im working with jquery mobile in my project and what i trying to do instead to use the swipe effect, use two button to change to the next and to the previous data-role=page. im trying with this ...

  1. jquery mobile change page
  2. jquery mobile change page programmatically
  3. jquery mobile change page on button click
  4. jquery mobile change button text
  5. jquery mobile change background color
  6. jquery mobile change button color
  7. jquery mobile change theme
  8. jquery mobile change icon color
  9. jquery mobile change
  10. jquery mobile change theme dynamically
  11. jquery mobile change page with parameter
  12. jquery mobile change header color
  13. jquery mobile change selected option
  14. jquery mobile change select value
  15. jquery mobile change event
  16. jquery mobile change hash
  17. jquery mobile change css
  18. jquery mobile change data theme dynamically
  19. jquery mobile change page event
  20. jquery mobile change font size

Following is my JSON file: <?php $driver_booking = q("select * from vehicle_driver_booking where vehicle_id = ".$_REQUEST['ch']); $array = array(); ...

Following is my JSON file: <?php $driver_booking = q("select * from vehicle_driver_booking where vehicle_id = ".$_REQUEST['ch']); $array = array(); ...

I have a store which I want to hardcode some initial values into. Then when it loads from the server I want it to APPEND the results to the initial values, rather than replacing them. Is this possible?...

I have a store which I want to hardcode some initial values into. Then when it loads from the server I want it to APPEND the results to the initial values, rather than replacing them. Is this possible?...

Here's what I'm after. When user clicks 'X' to close the IE 10 browser. Do the following: Trap the onbeforeunload event in javascript Make an ajax call to a server resource (a servlet) which has some ...

Here's what I'm after. When user clicks 'X' to close the IE 10 browser. Do the following: Trap the onbeforeunload event in javascript Make an ajax call to a server resource (a servlet) which has some ...

  1. onbeforeunload server side
  2. onbeforeunload call server side