tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dimitris Zenios <dimitris.zen...@gmail.com>
Subject Re: Loop and iterator
Date Wed, 29 Jan 2014 19:58:08 GMT
I am not sure whether i will be able to cast to collection.Maybe tapestry
is doing some magic with BindParameter.


On Wed, Jan 29, 2014 at 9:47 PM, Ville Virtanen <
ville.virtanen@orientimport.fi> wrote:

> OK, got it. I thought the source param was collection.
>
> You always could (pseudocode)
>
> if (values instanceof Collection<?>) {
>   return ((Collection<?>) source).size();
> } else {
>   it = source.iterator();
>   while (it.hasNext()) {
>     it.next();
>     sum++;
>   }
>   return sum;
> }
>
> Ville
>
> -----Alkuperäinen viesti-----
> Lähettäjä: Dimitris Zenios [mailto:dimitris.zenios@gmail.com]
> Lähetetty: 29. tammikuuta 2014 21:38
> Vastaanottaja: Tapestry development
> Aihe: Re: Loop and iterator
>
> Yes but i cannot access the Iterator since is a private variable.Also the
> source parameter is declared as Iterable.I am not sure whether i am able to
> cast iterable to to List in order to get size.I think no
>
>
> On Wed, Jan 29, 2014 at 9:32 PM, Ville Virtanen <
> ville.virtanen@orientimport.fi> wrote:
>
> > Take a look at
> >
> > @BindParameter
> >
> > http://tapestry.apache.org/component-mixins.html --> Look for "Binding
> > the parameter of the core component"
> >
> > You can access all component parameters in the mixin
> >
> > Ville Virtanen
> >
> >
> > -----Alkuperäinen viesti-----
> > Lähettäjä: Dimitris Zenios [mailto:dimitris.zenios@gmail.com]
> > Lähetetty: 29. tammikuuta 2014 21:22
> > Vastaanottaja: Tapestry development
> > Aihe: Re: Loop and iterator
> >
> > 1.Passing the collection to the mixin and the component is one
> > solution but i doesn'`t feel nice.I never had to pass the same
> > parameter twice 2.Regarding render variables i don't see where these
> > will help in my situation 3.Dom rewriting ( Javascript ? )
> >
> > On Wed, Jan 29, 2014 at 9:10 PM, Ville Virtanen <
> > ville.virtanen@orientimport.fi> wrote:
> >
> > > Hi,
> > >
> > > you can pass mixins parameters, so you could pass the original
> > > collection you're iterating over with the loop to the mixin also,
> > > and compare if the
> > > collection.size() == index
> > >
> > > http://tapestry.apache.org/component-mixins.html Look for "Mixin
> > > Parameters".
> > >
> > > Ville
> > >
> > > -----Alkuperäinen viesti-----
> > > Lähettäjä: Thiago H de Paula Figueiredo [mailto:thiagohp@gmail.com]
> > > Lähetetty: 29. tammikuuta 2014 21:02
> > > Vastaanottaja: Tapestry development
> > > Aihe: Re: Loop and iterator
> > >
> > > On Wed, 29 Jan 2014 16:17:49 -0200, Dimitris Zenios <
> > > dimitris.zenios@gmail.com> wrote:
> > >
> > > > I have a list of 8 elements.I want to loop over the elements and
> > > > every
> > > > 3 elements or at beginning of list to Start with a <div> and end
> > > > with a </div>.
> > > >
> > > > Resulting output should be
> > > > <div>
> > > > <item>
> > > > <item>
> > > > <item?
> > > > </div>
> > > > <div>
> > > > <item>
> > > > <item>
> > > > <item>
> > > > </div>
> > > > <div>
> > > > <item>
> > > > <item>
> > > > </div
> > > >
> > > > So i though i will create a mixin that attaches to the loop and
> > > > adds those divs.I managed to almost make it work except one last
> > > > case.After the last element i want to close my previous div even
> > > > if the index is not % 3.In order to know that loop is in the last
> > > > element i need the iterator of the loop.
> > >
> > > I'd use pure DOM rewriting instead. tapestry-xpath is extremely
> > > helpful for these situations. Don't expect the Tapestry team to
> > > expose implementation details: they don't like it.
> > >
> > > --
> > > Thiago H. de Paula Figueiredo
> > > Tapestry, Java and Hibernate consultant and developer
> > > http://machina.com.br
> > >
> > > --------------------------------------------------------------------
> > > - To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: dev-help@tapestry.apache.org
> > >
> > >
> > >
> > > --------------------------------------------------------------------
> > > - To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: dev-help@tapestry.apache.org
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: dev-help@tapestry.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: dev-help@tapestry.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message