Back Forum Reply New

Using counter inside webflow

Hi to all,

I would like to use an Integer value in my webflow to keep track of the page being shown. When the next-transition is executed, this value needs to be increased by 1. When the previous-transition is executed, the value needs to be decreased by 1. Can someone give me some clues on how to solve this. I'll paste some invented code to illustrate my needs.
Thanks allready.

init:

Code:
lt;var name=quot;pagequot; value=quot;0quot; /gt;
process:

Code:
lt;set attribute=quot;pagequot; value=quot;${page + 1}quot; /gt;Why not create a Counter bean with methods like increment() and decrement(). That would make it a bit more OO. You can setup the bean with a lt;vargt;:

lt;var name=quot;counterquot; class=quot;my.Counterquot;/gt;

And then use a simple evaluate-action to call the method:

lt;evaluate-action expression=quot;flowScope.counter.increment()quot;/gt;

Erwin

Thanks, I can make it work using a bean providing the functionality you suggested. However, it would be nice to know how it can be done using a primitive type.

Thanks.
¥
Back Forum Reply New