Hi Steven, give this a try:
Box.java:
package myproject.model;
public class Box {
private String name = "noname";
public Box() {
}
public Box(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
BoxOutput.java:
package myproject.components;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
import myproject.model.Box;
public class BoxOutput {
@SuppressWarnings("unused")
@Property
@Parameter
private Box box;
}
BoxOutput.tml:
<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<div style="height: 100px; width: 100px; background: aqua; text-align:
center; margin: 10px; ">
${box.name}
</div>
</t:container>
Overview.java:
package myproject.web.pages;
import java.util.ArrayList;
import java.util.List;
import org.apache.tapestry5.annotations.Property;
import myproject.model.Box;
public class Overview {
@Property
private List<Box> boxes;
@SuppressWarnings("unused")
@Property
private Box box;
void setupRender() {
boxes = new ArrayList<Box>();
System.out.println("creating some boxes");
boxes.add(new Box("box 1"));
boxes.add(new Box("box 2"));
boxes.add(new Box("box 3"));
boxes.add(new Box("box 4"));
}
}
Overview.tml:
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"
xmlns:p="tapestry:parameter">
<t:loop source="boxes" value="box">
<t:boxoutput box="box"/>
</t:loop>
</html>
HTH,
Geoff
http://jumpstart.doublenegative.com.au
On 03/12/2009, at 8:21 PM, Steven Tönsing wrote:
> Hi,
> i'm completely new to tapestry and i got a very fundamental (for my project)
> question.
>
> So this is my sitiation :
> I'm using tapestry 5.1 and i have a collection of components (Boxes) which
> can be placed on a page (in a certain order) the only thing i whant to do now
> is to get this collection of components rendered in the markup (template) of
> the page.
>
> Pretty much like this
>
> <t:loop source="boxes" value="var:whatever">
> <t:box source="var:whatever">
> </t:loop>
>
> but this is obviously wrong. Is there a way to do so ?
>
> thanks,
> steve
>
> Structure :
>
> de.steven.tapestry.components.Box.java
> de.steven.tapestry.components.Box.tml
>
> de.steven.tapestry.pages.Overwiew.java
> de.steven.tapestry.pages.Overwiew.tml
>
> Source :
>
> de.steven.tapestry.pages.Overview.java
>
> public class Overview{
>
> private List<Box> boxes;
>
> public Overview(){
> boxes = new ArrayList<Box>();
>
> System.out.println("creating some boxes");
> boxes.add( new Box("box 1") );
> boxes.add( new Box("box 2") );
> boxes.add( new Box("box 3") );
> boxes.add( new Box("box 4") );
> }
>
> public List<Box> getBoxes() {
> return boxes;
> }
>
> public void setBoxes(List<Box> boxes) {
> this.boxes = boxes;
> }
>
> }
>
> de.steven.tapestry.compoents.Box.java
>
> public class Box {
> @Parameter
> @Property
> private String name = "noname";
>
> public Box(){
>
> }
>
> public Box(String name){
> this.name = name;
> }
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>