You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Zart Colwing <za...@wanadoo.fr> on 2008/08/15 18:07:23 UTC

Re: Struts2 tags loops


Filipe David Manana-2 wrote:
> 
> Nop. Neither way works.
> 
> <s:iterate value="pageCount">
>   <s:property />
> </s:iterate>
> 
> This has a single iteration, and the value outputted is the value of
> the variable (10 for example).
> 

You can achieve what you expect with the following code in your JSP:

<s:bean name="org.apache.struts2.util.Counter" var="counter">
  <s:param name="last" value="%{pageCount}" />
</s:bean>
<s:iterator value="#counter">
  <s:property />
</s:iterator>

--- OR --- you can publish a Counter directly from your java code
public class TestIterator2 extends ActionSupport {
	Counter counter;
	public Counter getCounter() {
		return counter;
	}
	@Override
	public String execute() throws Exception {
		counter = new Counter();
		counter.setFirst(0);
		counter.setLast(40);
		return SUCCESS;
	}
}

that can be iterated from your JSP like this:
<s:iterator value="counter">
	<s:property />
</s:iterator>

ZartC
-- 
View this message in context: http://www.nabble.com/Struts2-tags-loops-tp15216947p19001293.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org