Not having to create getters & setters (or abstract getters in T4) just so that @Loop (and @For) values and indexes can become accessible is a fairly often request/question...
Creating a custom binding prefix (perhaps named temp) that attaches objects to the currect requestcycle and reads from them looks like an elegant solution - of course, the temp binding would also need to support object navigation if it's going to be of any value, so perhaps it could reuse parts of the prop binding? On 10/14/07, Howard Lewis Ship <[EMAIL PROTECTED]> wrote: > > You can define a variable as a field of your component class. > > However, it won't be visible without your providing a getter and setter. > > Example: > > <t:loop source="database.users" value="user"> > <p>${user.name}</p> > </t:loop> > > Java code: > > public class MyPage { > > @Inject > private UserDatabase _database; > > private User _user; > > public UserDatabase getDatabase() { return _database; } > > public void setUser(User user) { _user = user; } > > public User getUser() { return _user; > } > > JSPs are based on a pretty ugly concept: code generation, as in it takes > your JSP and your snippets and generates and compiles a Java class from > them. Ugly because a stray "{" in your snippet throws a monkey wrench into > the works. Tapestry gets a big performance advantage over JSPs because of > how stupied the JSP code generation tends to be. > > Anyway, Tapestry parameters are private fields, to be visible outside the > component's code they must be exposed as properties: read-only or > read/write > (or even write-only) by providing the correct accessors. > > My comments was that the Loop component has the values you are looking for > ... but it's not sharing. Add an issue and we'll see about getting that > into 5.0.6 or 5.0.7. > > On 10/14/07, Mohammad Shamsi <[EMAIL PROTECTED]> wrote: > > > > hi Howard, > > > > i have no experience in Tapestry, i just test it for replacing my > > company > > framework. > > i use for 6 years struts, webworks and my own framework that based on > both > > struts and webworks. > > > > in pages that made from JSP and JSTL , we can simply define a variable > in > > page, this variable bind on specified scope (page, session, ...). I > guess > > that if you define a new prefix for inline variables (on space > variables) > > , > > we can easily use it in components and page templates if need. > > > > in a simple implement each page or component can have a map for holding > > on > > space variables an values. (Map<String /*variable name*/, Object > > /*variable > > values*/> ) > > > > am i right ? i don't know :( > > > > On 10/14/07, Howard Lewis Ship <[EMAIL PROTECTED]> wrote: > > > > > > If we made the getIndex() and getValue() methods of Loop public, then > > you > > > could: > > > > > > > > > <span t:id="loop" source="1..5"> > > > ${loop.currValue}<br/> > > > </span> > > > > > > But then you must define your loop in your Java class and expose it as > a > > > property: > > > > > > @Component > > > private Loop _loop; > > > > > > public Loop getLoop() { return _loop; } > > > > > > > > > .... however that won't work currently, because those methods are not > > > visible. If you add an issue, it's a few second's work to make them > > > public. > > > > > > On 10/14/07, Nick Westgate <[EMAIL PROTECTED]> wrote: > > > > > > > > I can see what you mean, though it is quite common to use the index > > > inside > > > > the page class too. T5 keeps things simple to cover the most common > > > cases. > > > > > > > > You can create your own components if you don't like the default > ones. > > > > It would be interesting to see an alternative if you write one. > > > > > > > > Cheers, > > > > Nick. > > > > > > > > > > > > Mohammad Shamsi wrote: > > > > > dear Nick, > > > > > > > > > > i want index just for iteration, i don't need it in may page > class, > > i > > > > think > > > > > that its better to define in Loop component class, > > > > > > > > > > suppose that i want to use Loop, 5 times in a singe page, then i > > most > > > > define > > > > > 5 index value, and five item object ??? > > > > > > > > > > > > > > > > > > > > On 10/14/07, Nick Westgate <[EMAIL PROTECTED]> wrote: > > > > >> The value and index have to go somewhere. Why not in your page > > class? > > > > >> > > > > >> Cheers, > > > > >> Nick. > > > > >> > > > > >> > > > > >> Mohammad Shamsi wrote: > > > > >>> hi all, > > > > >>> > > > > >>> please take a look at my page bellow, > > > > >>> > > > > >>> <!-- do i have to define item object in page class ?? i > > want > > > > to > > > > >> use > > > > >>> it just here in page ??? --> > > > > >>> <t:loop source="items" value="item" > > > > > >>> > > > > >>> <tr> > > > > >>> <!-- i want to put an index here for each row in > table > > > --> > > > > >>> <td> ??? </td> > > > > >>> <td>${item.firstName}</td> > > > > >>> <td>${item.lastName}</td> > > > > >>> <td>${item.phone}</td> > > > > >>> </tr> > > > > >>> </t:loop> > > > > >>> > > > > >>> 1 - i just want to use item object here, for iteration, i don't > > > want > > > > to > > > > >>> define it at my page class, can i ? > > > > >>> > > > > >>> 2 - i need an index var for each row, but it seems that for use > > > index > > > > >>> attribute in loop component, i have to define a property at my > > page > > > > >> class > > > > >>> first, :(( > > > > >>> > > > > >> > > --------------------------------------------------------------------- > > > > >> 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 > > > Partner and Senior Architect at Feature50 > > > > > > Creator Apache Tapestry and Apache HiveMind > > > > > > > > > > > -- > > sincerely yours > > M. H. Shamsi > > > > > > -- > Howard M. Lewis Ship > Partner and Senior Architect at Feature50 > > Creator Apache Tapestry and Apache HiveMind > -- Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr Tapestry / Tacos developer Open Source / JEE Consulting