Great catch.  Simpler is always better.

On Thu, Mar 27, 2008 at 4:10 PM, Jonathan Barker
<[EMAIL PROTECTED]> wrote:
> Subtle logic error.
>
>
>  outputlist.add(list.subList(counter,
>  Math.min(counter+maxListsize,outputlist.size())));
>
>  Should be
>
>
>  outputlist.add(list.subList(counter,
>  Math.min(counter+maxListsize, list.size())));
>
>  Gotta love those!
>
>
>
>
>  > -----Original Message-----
>  > From: Britske [mailto:[EMAIL PROTECTED]
>  > Sent: Thursday, March 27, 2008 2:25 PM
>  > To: users@tapestry.apache.org
>  > Subject: T5: nested loops don't work (can't figure this one out)
>  >
>  >
>  > Hi,
>  >
>  > I'm breaking my head on this one.
>  > I have  2 nested loops where the value of the outer loop is used as the
>  > source of the inner loop.
>  >
>  > The problem is that getCurPhotoAsThumb() is never called (as noticed by
>  > debugging) thus nothing is rendered.
>  > I've made sure that getCurThumbSublist() has at least 1 element.
>  >
>  > Anyone?
>  >
>  > I've supplied the relative template and class-parts:
>  >
>  > TEMPLATE>
>  > ---------------------
>  > <t:loop source="listOfThumbSubLists" value="curThumbSublist">
>  >   <div id="${currentThumbContainerId}" class="thumbcontainer">
>  >        <t:loop source="curThumbSublist" value="curPhotoAsThumb">
>  >            ${curPhotoAsThumb.url}
>  >               </t:loop>
>  >    </div>
>  >  </t:loop>
>  >
>  >
>  > CLASS>
>  > ---------------
>  > private int maxListsize = 6;
>  > private List<Photo> curThumbSublist;
>  > private Photo curPhotoAsThumb;
>  > private int curListCounter = 0;
>  >
>  >       public List<Photo> getCurThumbSublist()
>  >       {
>  >               return curThumbSublist;
>  >       }
>  >
>  >       public void setCurThumbSublist(List<Photo> curThumbSublist)
>  >       {
>  >               this.curThumbSublist = curThumbSublist;
>  >               curListCounter++;
>  >       }
>  >
>  >       public String getCurrentThumbContainerId()
>  >       {
>  >               return "thumb_"+curListCounter;
>  >       }
>  >
>  >       public List<List<Photo>> getListOfThumbSubLists(){
>  >               curListCounter= 0;
>  >               List<List<Photo>> outputlist = new ArrayList<List<Photo>>();
>  >
>  >               Set<Photo> set = this.getPage().getPhotos();
>  >               List<Photo> list = new ArrayList<Photo>();
>  >               for(Photo p: set){
>  >                       list.add(p);
>  >                       System.out.println(p.getUrl());
>  >               }
>  >               int counter = 0;
>  >               boolean stop = false;
>  >               while(!stop){
>  >                       outputlist.add(list.subList(counter,
>  > Math.min(counter+maxListsize,outputlist.size())));
>  >                       if(list.size()<=counter+maxListsize){
>  >                               stop = true;
>  >                       }
>  >                       counter += maxListsize;
>  >               }
>  >               return outputlist;
>  >       }
>  >
>  >       public Photo getCurPhotoAsThumb()
>  >       {
>  >               return curPhotoAsThumb;
>  >       }
>  >
>  >       public void setCurPhotoAsThumb(Photo curPhotoAsThumb)
>  >       {
>  >               this.curPhotoAsThumb = curPhotoAsThumb;
>  >       }
>  > --
>  > View this message in context: http://www.nabble.com/T5%3A-nested-loops-
>  > don%27t-work-%28can%27t-figure-this-one-out%29-tp16330163p16330163.html
>  > Sent from the Tapestry - User mailing list archive at Nabble.com.
>  >
>  >
>  > ---------------------------------------------------------------------
>  > 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]
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to