-
loop in struts (7 messages)
- Posted by: nima haghpanah
- Posted on: August 01 2004 02:21 EDT
I want to write a loop using struts tags to do the following:
for (int i=0;i<max;i++) {
out.println(max);
}
where max is a property of a bean named statusbean with session scope.
can anyone help?Threaded Messages (7)
- loop in struts by Kristian Senkler on August 01 2004 07:28 EDT
- loop in struts by nima haghpanah on August 01 2004 08:45 EDT
-
loop in struts by Kristian Senkler on August 01 2004 03:36 EDT
- for Loop by Kamal nath on August 30 2011 06:11 EDT
-
loop in struts by Kristian Senkler on August 01 2004 03:36 EDT
- loop in struts by nima haghpanah on August 01 2004 08:45 EDT
- loop in struts by Rene Zanner on August 02 2004 04:41 EDT
- loop in struts by nima haghpanah on August 02 2004 08:15 EDT
- Sorry! by Rene Zanner on August 03 2004 07:39 EDT
- loop in struts by nima haghpanah on August 02 2004 08:15 EDT
-
loop in struts[ Go to top ]
- Posted by: Kristian Senkler
- Posted on: August 01 2004 07:28 EDT
- in response to nima haghpanah
hi nima,
try to use the logic-taglib coming with struts. Your snipplet would then look like:
<logic:iterate id="element" name="mycollection">
Next element is <bean:write name="element" property="value"/>
</logic:iterate>
As an altenative, take a look at JSTL (http://jakarta.apache.org/taglibs/) with regard to looping capabilities like "<c:forEach>" or something.
Hope it helps,
Kristian -
loop in struts[ Go to top ]
- Posted by: nima haghpanah
- Posted on: August 01 2004 08:45 EDT
- in response to Kristian Senkler
hi Kristian,
tancks for your help.
but I wanted to know if I could do this without making a new Collection and passing it. cause my needed Collection is only a set of integers. I mean 1 2 3 4 ...
Do you thinck there is any way to do this? -
loop in struts[ Go to top ]
- Posted by: Kristian Senkler
- Posted on: August 01 2004 15:36 EDT
- in response to nima haghpanah
Yes,
if you just want to loop over some integers, you can use JSTL. Assuming you have added the JSTL-Lib to you webapp, all you have to do is something like the following in your jsp-Page:
<%@ taglib uri="/tags/c" prefix="c"%>
<c:forEach begin="1" end="100" var="cur">
<c:out value="${cur}"/>
</c:forEach>
In you processed HTML-Page, the integers from 1 to 100 will be rendered.
Hope this helps,
Kristian -
for Loop[ Go to top ]
- Posted by: Kamal nath
- Posted on: August 30 2011 06:11 EDT
- in response to Kristian Senkler
Hi I need row wise like..
In jsp it will display
<TABLE BORDER=1>
<%
for(int i=0; i<=5 ; ){
%>
<TR><TD>The cost of $shares share/s is <%=i %> #x0024s</TD>
<TD>The dividend is <%= i+1 %> #x0024s</TD>
<TD>The dividend is <%= i+2 %> #x0024s</TD>
<TD>The dividend is <%= i+3 %> #x0024s</TD></TR>
<%
i+=3;
i++;
}
%>
</TABLE>like that jsp i need struts also
<c:forEach var='desig' items='${DESIG_LIST}'>
<tr>
<td height="28" align="center" valign="middle" style="padding-left:15px;" class="titles">
<c:out value="${desig.desiName}"></c:out>
</td>
</tr>
</c:forEach>
Please help this
Thanks in advance
By
Kamalnath.B
-
loop in struts[ Go to top ]
- Posted by: Rene Zanner
- Posted on: August 02 2004 04:41 EDT
- in response to nima haghpanah
Hi,
if you want to iterate over a certain amount of iterations, you can use the start and end parameters of the Struts <logic:iterate> tag.
Please look into the manual first before asking questions!
Cheers,
René Zanner -
loop in struts[ Go to top ]
- Posted by: nima haghpanah
- Posted on: August 02 2004 08:15 EDT
- in response to Rene Zanner
Hi Rene,
tnx for your help, but, unfortunately, there is no start and end parameters acceptable in <logic:iterate> tag.
I think you should look into the manual before answering the questions. -
Sorry![ Go to top ]
- Posted by: Rene Zanner
- Posted on: August 03 2004 07:39 EDT
- in response to nima haghpanah
Shame on me - I mixed up the taglibs!
I did not want to offend you and in future will look into the docs first - sorry for trying to teach you ... :o(
I found the begin and end parameters in the JSTL <core:forEach> tag.
Cheers,
René