Struts 2 - conditional check of IteratorStatus inside an s:if tag
Mark Brownengland
Greenhorn
Joined: Apr 30, 2006
Posts: 25
posted
0
Hi,
I have the following code snippet for iterating over a list and outputting index values based upon verifying the index number equals 0:
Before creating the above, I had the following:
This correctly outputted the index number for all elements in the iterator.
For some reason, when I include an s:if tag (as per my first snippet) and attempt to test the rowStatus index i.e. rowStatus.index == 0, this fails to evaluate and thus is never evaluated as true. As an aside, if I altered the first code snippet to:
In this instance, the s:if tag evaluates the test and alternately prints out the index number.
Would appreciate advice as to why I can't use the rowstatus.index inside an s:if tag.
It depends partially on the version of S2 you're using. At some point a change was made to "eliminate" the confusing "#" character--but in my experience, not all usages are eliminated. I'm not really sure why not, and haven't yet taken the time to figure it out.
When it's used it's used to signify what I call a "stack context" variable. The value stack isn't just a stack--it's also a map. When a variable is created in the JSP page it's a stack context variable--not on the stack (unless you do an <s:push>), but along side it.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Struts 2 - conditional check of IteratorStatus inside an s:if tag