You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Alfonso Quiroga <al...@gmail.com> on 2009/09/04 19:33:16 UTC

newbie question about loop

Hi! I am looping and I need the "index" position, but index starts in
0, and I want to show it in screen starting in 1, so... I have:
		<t:loop source="mySource" index="position">
                    ${position}
		</t:loop>
That works but starts in 0.... I tried ${position + 1} but didn't work
The only hack I found, is declaring a special getter of "position" in
the page, like this:
      public int getPosition() {
              return position + 1;
     }

is this the real solution? thanks!

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: newbie question about loop

Posted by Alfonso Quiroga <al...@gmail.com>.
Thiago, thanks, so I make no change to the code, but internally I'm happy ;)
And about moving logic... maybe I can...

${ getViewPosition(position) }

and in .java I do:
getViewPosition(int aNumber) {
   return aNumber + 1;
}

I mean... maybe it's better because I don't override getter of a
property (position)



On Fri, Sep 4, 2009 at 2:37 PM, Thiago H. de Paula
Figueiredo<th...@gmail.com> wrote:
> Em Fri, 04 Sep 2009 14:33:16 -0300, Alfonso Quiroga <al...@gmail.com>
> escreveu:
>>
>>      public int getPosition() {
>>              return position + 1;
>>     }
>
> This is not a hack: it's moving logic from the template to a class, and
> that's a Good Thing. :)
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: newbie question about loop

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Fri, 04 Sep 2009 14:33:16 -0300, Alfonso Quiroga  
<al...@gmail.com> escreveu:
>       public int getPosition() {
>               return position + 1;
>      }

This is not a hack: it's moving logic from the template to a class, and  
that's a Good Thing. :)

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org