Hi, Don't loop your components, loop your data. If it is the name of the component that is your data, then loop over the names and give those as parameter to your boxes. Normally it would be orders or products or users or what not that are looped through.
You don't have to give unique identifiers to your components if you don't want to, so you can just have components without any parameters. (Obviously :)) Take a look at http://tapestry.apache.org/tapestry5/tutorial1/hilo.html it shows how you can make a loop that loops 10 times and creates new actionlink every time. (Creating guessable links part) Source is the list that you loop, and value is the variable that contains one list item at every iteration of the loop. (So your component can be given one object at a time as parameter from the list.) Tapestry takes care of your component instantiation and instrumentation if you just follow the normal project layout. (So that T5 knows which classes are components / pages. You can of course use non-standard packages and instruct T5 to treat any class as component.) Hopefully this clarifies it a bit. - Ville 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] > > > -- View this message in context: http://old.nabble.com/collection-of-components-within-a-page-%28Tapestry-5.1%29-tp26623064p26629581.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]
