What you /might/ be able to do (to avoid the java code), is to use var
here... I haven't played with the var prefix yet, so this is a "try
and see" idea. :) But. Something like:
<t:loop source="strings" value="var:string" index="var:index">
<t:if test="var:index">,</t:if>
<a href="#" t:type="pagelink" page="nada" context="var:string">$
{var:string}</a>
</t:loop>
If that works, you could even write your own DelimittedLoop component
and not have to duplicate the logic elsewhere.
Robert
On Jan 12, 2008, at 1/125:06 PM , Chris Lewis wrote:
That would work of course, but I'd like to do something like this:
<t:loop source="strings" value="var:string" index="prop:index"
delimit=", ">
<a href="#" t:type="pagelink" page="nada" context="var:string">$
{var:string}</a>
</t:loop>
And then each element would be separated by my delimiter without any
extra java code.
Robert Zeigler wrote:
How about testing the value of index?
Something like:
.java:
private int index;
public int getIndex() { return index; }
public void setIndex(int i) index = i; }
public boolean isFirst() { return index==0; }
.tml:
<t:loop source="strings" value="var:string" index="prop:index">
<t:if test="prop:first" negate="true">
,
</t:if>
<a href="#" t:type="pagelink" page="nada" context="var:string">$
{var:string}</a>
</t:loop>
Robert
On Jan 12, 2008, at 1/124:41 PM , Chris Lewis wrote:
Sorry, I missed the "check if first" part. How can you do such a
check in Loop? The "If" can test, but what can you test in a Loop?
nothing that I know of will tell you where in the iteration you are.
chris
Davor Hrg wrote:
just reverse where you write the ","
instead of checking if last and putting comma behind
check if first and put comma in front
Davor Hrg
On Jan 12, 2008 11:04 PM, Chris Lewis <[EMAIL PROTECTED]>
wrote:
So this ticket has been implemented in svn:
https://issues.apache.org/jira/browse/TAPESTRY-2028
And now I need whitespace... so how can I get it back? Is there
or isn't
there a way to disable this? Im using loop to output links
(pagelinks),
and i have whitespace behind in the body so there is separation.
Unfortunately, it's getting stripped. Is there a workaround?
On a related note, is there a way to know if im on the last
iteration of
the loop, so i could for example, follow all but the last with a
","?
This may be outside the scope of loop as currently implemented,
but i
can see it being useful.
chris
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]