THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
The component listed below is a looping component; it renders its body a number of times, defined by its start
and end
parameters (which set the boundaries of the loop). The component can update a result
parameter bound to a property of its container; it will automatically count up or down depending on whether start
or end
is larger.
Code Block | ||||
---|---|---|---|---|
| ||||
package org.example.app.components; import org.apache.tapestry5.annotations.AfterRender; import org.apache.tapestry5.annotations.Parameter; import org.apache.tapestry5.annotations.SetupRender; public class Count { @Parameter (value="1") private int start; @Parameter(required = true) private int end; @Parameter private int result; private boolean increment; @SetupRender void initializeValues() { result = start; increment = start < end; } @AfterRender boolean next() { if (increment) { int newResult = value + 1; if (newResult <= end) { result = newResult; return false; } } else { int newResult= value - 1; if (newResult>= end) { result = newResult; return false; } } return true; } } |
...