RE: T5: nested loops don't work (can't figure this one out)

2008-03-28 Thread Britske

Arghh. Thanks a lot! I missed that. I figured it couldn't be a Tapestry
thing. 

I traced back why I thought that the resulting sublist had an element (while
in fact it didn't): apparently a sublist is nothing but a wrapper around the
source-list (which I didn't know_, which is why burried in the debug
parameters the sublist still shows to have an element. Anyhow, 

Thanks again. 


Jonathan Barker 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 ListPhoto curThumbSublist;
 private Photo curPhotoAsThumb;
 private int curListCounter = 0;
 
  public ListPhoto getCurThumbSublist()
  {
  return curThumbSublist;
  }
 
  public void setCurThumbSublist(ListPhoto curThumbSublist)
  {
  this.curThumbSublist = curThumbSublist;
  curListCounter++;
  }
 
  public String getCurrentThumbContainerId()
  {
  return thumb_+curListCounter;
  }
 
  public ListListPhoto getListOfThumbSubLists(){
  curListCounter= 0;
  ListListPhoto outputlist = new ArrayListListPhoto();
 
  SetPhoto set = this.getPage().getPhotos();
  ListPhoto list = new ArrayListPhoto();
  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]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/T5%3A-nested-loops-don%27t-work-%28can%27t-figure-this-one-out%29-tp16330163p16347650.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]



T5: nested loops don't work (can't figure this one out)

2008-03-27 Thread Britske

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 ListPhoto curThumbSublist;
private Photo curPhotoAsThumb;
private int curListCounter = 0;

public ListPhoto getCurThumbSublist()
{
return curThumbSublist;
}

public void setCurThumbSublist(ListPhoto curThumbSublist)
{
this.curThumbSublist = curThumbSublist;
curListCounter++;
}

public String getCurrentThumbContainerId()
{
return thumb_+curListCounter;
}

public ListListPhoto getListOfThumbSubLists(){
curListCounter= 0;
ListListPhoto outputlist = new ArrayListListPhoto();

SetPhoto set = this.getPage().getPhotos();
ListPhoto list = new ArrayListPhoto();
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]



Re: T5: nested loops don't work (can't figure this one out)

2008-03-27 Thread Howard Lewis Ship
That should work just fine.  Nothing jumps out at me as being wrong.

In fact, I just tried a simplified test case and it worked fine:

 public Object[][] getData() {
return new Object[][] {
{ fred, flintstone },
{ barney, rubble }
};
}

@Property
private Object[] column;

  ul
t:loop source=data value=column
li
ROW:
ul
t:loop source=column value=var:temp
li${var:temp}/li
/t:loop
/ul
/li
/t:loop
/ul

Which rendered as:

 ul

li
ROW:
ul

lifred/li

liflintstone/li

/ul
/li


li
ROW:
ul

libarney/li

lirubble/li

/ul
/li

/ul


On Thu, Mar 27, 2008 at 11:24 AM, Britske [EMAIL PROTECTED] wrote:

  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 ListPhoto curThumbSublist;
  private Photo curPhotoAsThumb;
  private int curListCounter = 0;

 public ListPhoto getCurThumbSublist()
 {
 return curThumbSublist;
 }

 public void setCurThumbSublist(ListPhoto curThumbSublist)
 {
 this.curThumbSublist = curThumbSublist;
 curListCounter++;
 }

 public String getCurrentThumbContainerId()
 {
 return thumb_+curListCounter;
 }

 public ListListPhoto getListOfThumbSubLists(){
 curListCounter= 0;
 ListListPhoto outputlist = new ArrayListListPhoto();

 SetPhoto set = this.getPage().getPhotos();
 ListPhoto list = new ArrayListPhoto();
 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]





-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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



RE: T5: nested loops don't work (can't figure this one out)

2008-03-27 Thread Jonathan Barker
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 ListPhoto curThumbSublist;
 private Photo curPhotoAsThumb;
 private int curListCounter = 0;
 
   public ListPhoto getCurThumbSublist()
   {
   return curThumbSublist;
   }
 
   public void setCurThumbSublist(ListPhoto curThumbSublist)
   {
   this.curThumbSublist = curThumbSublist;
   curListCounter++;
   }
 
   public String getCurrentThumbContainerId()
   {
   return thumb_+curListCounter;
   }
 
   public ListListPhoto getListOfThumbSubLists(){
   curListCounter= 0;
   ListListPhoto outputlist = new ArrayListListPhoto();
 
   SetPhoto set = this.getPage().getPhotos();
   ListPhoto list = new ArrayListPhoto();
   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]



Re: T5: nested loops don't work (can't figure this one out)

2008-03-27 Thread Howard Lewis Ship
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 ListPhoto curThumbSublist;
   private Photo curPhotoAsThumb;
   private int curListCounter = 0;
  
 public ListPhoto getCurThumbSublist()
 {
 return curThumbSublist;
 }
  
 public void setCurThumbSublist(ListPhoto curThumbSublist)
 {
 this.curThumbSublist = curThumbSublist;
 curListCounter++;
 }
  
 public String getCurrentThumbContainerId()
 {
 return thumb_+curListCounter;
 }
  
 public ListListPhoto getListOfThumbSubLists(){
 curListCounter= 0;
 ListListPhoto outputlist = new ArrayListListPhoto();
  
 SetPhoto set = this.getPage().getPhotos();
 ListPhoto list = new ArrayListPhoto();
 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]