You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Filipe David Manana <fd...@ieee.org> on 2008/02/01 00:00:42 UTC

Struts2 tags loops

Hi,

Is there any way to iterate over an integer range with the <s:iterate/> tag?
I have an integer property (pageCount) in my action and I want to
print all the integer values between 1 and this property in my JSP.

cheers

-- 
Filipe David Manana,
fdmanana@ieee.org

Obvious facts are like secrets to those not trained to see them.

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


Re: [struts] Struts2 tags loops

Posted by Dale Newfield <Da...@Newfield.org>.
Filipe David Manana wrote:
> The <c:forEach> jstl tag, as well as all other jstl tags, is not
> allowed in struts 2.0.11, afaik.

This is in no way the case.

What is disallowed in 2.0.11 is el expressions as struts tag attributes.

-Dale

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


Re: Struts2 tags loops

Posted by Zart Colwing <za...@wanadoo.fr>.

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


Re: Struts2 tags loops

Posted by Randy Burgess <RB...@nuvox.com>.
That limitation is only for struts tags, for example <s:property
value="${somevalue}"/>, otherwise you shouldn't have problems with JSTL. I
haven't run into any on 2.0.11.

Regards,
Randy Burgess
Sr. Web Applications Developer
Nuvox Communications



> From: Filipe David Manana <fd...@ieee.org>
> Reply-To: Struts Users Mailing List <us...@struts.apache.org>
> Date: Fri, 1 Feb 2008 09:21:19 +0100
> To: Dave Newton <ne...@yahoo.com>
> Cc: Struts Users Mailing List <us...@struts.apache.org>
> Subject: Re: Struts2 tags loops
> 
> 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).
> 
> The <c:forEach> jstl tag, as well as all other jstl tags, is not
> allowed in struts 2.0.11, afaik.
> 
> 
> 
> On Feb 1, 2008 12:24 AM, Dave Newton <ne...@yahoo.com> wrote:
>> --- Filipe David Manana <fd...@ieee.org> wrote:
>>> Is there any way to iterate over an integer range with the <s:iterate/>
>>> tag? I have an integer property (pageCount) in my action and I want to
>>> print all the integer values between 1 and this property in my JSP.
>> 
>> Not that I'm aware of; easier to use <c:forEach.../> IMO.
>> 
>> Dave
>> 
>> 
> 
> 
> 
> -- 
> Filipe David Manana,
> fdmanana@ieee.org
> 
> Obvious facts are like secrets to those not trained to see them.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 



This email and any attachments ("Message") may contain legally privileged and/or confidential information.  If you are not the addressee, or if this Message has been addressed to you in error, you are not authorized to read, copy, or distribute it, and we ask that you please delete it (including all copies) and notify the sender by return email.  Delivery of this Message to any person other than the intended recipient(s) shall not be deemed a waiver of confidentiality and/or a privilege.

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


Re: Struts2 tags loops

Posted by Filipe David Manana <fd...@ieee.org>.
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).

The <c:forEach> jstl tag, as well as all other jstl tags, is not
allowed in struts 2.0.11, afaik.



On Feb 1, 2008 12:24 AM, Dave Newton <ne...@yahoo.com> wrote:
> --- Filipe David Manana <fd...@ieee.org> wrote:
> > Is there any way to iterate over an integer range with the <s:iterate/>
> > tag? I have an integer property (pageCount) in my action and I want to
> > print all the integer values between 1 and this property in my JSP.
>
> Not that I'm aware of; easier to use <c:forEach.../> IMO.
>
> Dave
>
>



-- 
Filipe David Manana,
fdmanana@ieee.org

Obvious facts are like secrets to those not trained to see them.

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


Re: Struts2 tags loops

Posted by Dave Newton <ne...@yahoo.com>.
--- Filipe David Manana <fd...@ieee.org> wrote:
> Is there any way to iterate over an integer range with the <s:iterate/>
> tag? I have an integer property (pageCount) in my action and I want to
> print all the integer values between 1 and this property in my JSP.

Not that I'm aware of; easier to use <c:forEach.../> IMO.

Dave


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