|
View:
New views
10 Messages
—
Rating Filter:
Alert me
|
|
|
Using methods other thang getters and listenersHi to All,
After working for a while with T4, I now decided to start migrating to T5. But since the begining of that project I'm missing one of the T4 features that I really appreciate. Which the possibility to invoke in the HTML (now TML), some of the java methods other than the getters and listeners.
Particulary, let say I have in my java page a List from which I want to retrieve one element whose index I know. In T4 I'd invoke myList.getItem(index). I've tried ${myList.getItem(index)}, b ut didn't work. I'd appreciate if someone can tell me what I miss or the way to do what I want.
Thanks for your reply.
|
|
|
Re: Using methods other thang getters and listenersHi margi,
This is a known issue, marked to be solved to 5.1 version. see https://issues.apache.org/jira/browse/TAPESTRY-1624 I believe this feature was removed because of the bottleneck created by the use of OGNL to evaluate those expressions. Tapestry uses a very own solution that right now is not as flexible as OGNL's, but it's way faster. If you don't mind to lose some seconds in your requests, you can use the solution proposed by t5components. You can find it here: http://code.google.com/p/tapestry5-components/ http://87.193.218.134:8080/t5c-demo/ognlbindingpage Cheers, On Mon, Jul 21, 2008 at 11:22 AM, margi <ghouessinon@...> wrote: > > Hi to All, > After working for a while with T4, I now decided to start migrating to T5. > But since the begining of that project I'm missing one of the T4 features > that I really appreciate. Which the possibility to invoke in the HTML (now > TML), some of the java methods other than the getters and listeners. > Particulary, let say I have in my java page a List from which I want to > retrieve one element whose index I know. In T4 I'd invoke > myList.getItem(index). I've tried ${myList.getItem(index)}, b ut didn't > work. I'd appreciate if someone can tell me what I miss or the way to do > what I want. > Thanks for your reply. > -- > View this message in context: http://www.nabble.com/Using-methods-other-thang-getters-and-listeners-tp18569645p18569645.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > -- Atenciosamente, Marcelo Lotif Programador Java e Tapestry FIEC - Federação das Indústrias do Estado do Ceará (85) 3477-5910 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Using methods other thang getters and listenersEm Mon, 21 Jul 2008 11:22:31 -0300, margi <ghouessinon@...> escreveu:
> retrieve one element whose index I know. In T4 I'd invoke > myList.getItem(index). I've tried ${myList.getItem(index)}, b ut didn't > work. I'd appreciate if someone can tell me what I miss or the way to do Try creating a getter in your page class: public Item getItem() { return myList.getItem(index); } This has the upside of making the template simpler and your application more testable, as you almost don't have logic in templates, having them in Java code instead. I used T4 before and I really don't miss OGNL in T5. But it is also a matter of personal choice, obviously. Thiago --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Using methods other thang getters and listenersThat's what I did finally! You're right about the fact that we're not supposed to have logic in template, but personnaly I think there as some logics that don't worth a Getter. Imagine if my list contains 10 elements through which I have to iterate, I'd be oblige to write 10 getters, I really think that it's cumbersome. I might be wrong on this point if there is an elegant solution to that problem.
> retrieve one element whose index I know. In T4 I'd invoke > myList.getItem(index). I've tried ${myList.getItem(index)}, b ut didn't > work. I'd appreciate if someone can tell me what I miss or the way to do Try creating a getter in your page class: public Item getItem() { return myList.getItem(index); } This has the upside of making the template simpler and your application more testable, as you almost don't have logic in templates, having them in Java code instead. I used T4 before and I really don't miss OGNL in T5. But it is also a matter of personal choice, obviously. Thiago --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org For additional commands, e-mail: users-help@tapestry.apache.org |
|
|
Re: Using methods other thang getters and listenersThiago, you are completely right, but I think sometimes we cannot
avoid to make simple tests or pass some arguments to a method... I try not to use it too much, but sometimes it makes my life easier. This is actually a major issue for me. On Mon, Jul 21, 2008 at 12:49 PM, margi <ghouessinon@...> wrote: > > That's what I did finally! You're right about the fact that we're not > supposed to have logic in template, but personnaly I think there as some > logics that don't worth a Getter. Imagine if my list contains 10 elements > through which I have to iterate, I'd be oblige to write 10 getters, I really > think that it's cumbersome. I might be wrong on this point if there is an > elegant solution to that problem. > >> retrieve one element whose index I know. In T4 I'd invoke >> myList.getItem(index). I've tried ${myList.getItem(index)}, b ut didn't >> work. I'd appreciate if someone can tell me what I miss or the way to do > > Try creating a getter in your page class: > > public Item getItem() { > return myList.getItem(index); > } > > This has the upside of making the template simpler and your application > more testable, as you almost don't have logic in templates, having them in > Java code instead. > I used T4 before and I really don't miss OGNL in T5. But it is also a > matter of personal choice, obviously. > > Thiago > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > > > > -- > View this message in context: http://www.nabble.com/Using-methods-other-thang-getters-and-listeners-tp18569645p18571557.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > -- Atenciosamente, Marcelo Lotif Programador Java e Tapestry FIEC - Federação das Indústrias do Estado do Ceará (85) 3477-5910 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Using methods other thang getters and listeners>
> Imagine if my list contains 10 elements > through which I have to iterate, I'd be oblige to write 10 getters, > I would say that a design that is pulling items from a list like this is questionable. I would be curious to hear of a real world example where this is the best solution. Josh On Mon, Jul 21, 2008 at 8:49 AM, margi <ghouessinon@...> wrote: > > That's what I did finally! You're right about the fact that we're not > supposed to have logic in template, but personnaly I think there as some > logics that don't worth a Getter. Imagine if my list contains 10 elements > through which I have to iterate, I'd be oblige to write 10 getters, I > really > think that it's cumbersome. I might be wrong on this point if there is an > elegant solution to that problem. > > > retrieve one element whose index I know. In T4 I'd invoke > > myList.getItem(index). I've tried ${myList.getItem(index)}, b ut didn't > > work. I'd appreciate if someone can tell me what I miss or the way to do > > Try creating a getter in your page class: > > public Item getItem() { > return myList.getItem(index); > } > > This has the upside of making the template simpler and your application > more testable, as you almost don't have logic in templates, having them in > Java code instead. > I used T4 before and I really don't miss OGNL in T5. But it is also a > matter of personal choice, obviously. > > Thiago > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > > > > -- > View this message in context: > http://www.nabble.com/Using-methods-other-thang-getters-and-listeners-tp18569645p18571557.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > -- -- TheDailyTube.com. Sign up and get the best new videos on the internet delivered fresh to your inbox. |
|
|
Re: Using methods other thang getters and listenersEm Mon, 21 Jul 2008 12:49:43 -0300, margi <ghouessinon@...> escreveu:
> That's what I did finally! You're right about the fact that we're not > supposed to have logic in template, but personnaly I think there as some > logics that don't worth a Getter. Imagine if my list contains 10 elements > through which I have to iterate, I'd be oblige to write 10 getters, I > really think that it's cumbersome. As 99.999999% of all things, my approach has pros and cons and we should choose the right one according to the context :) Thiago --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Using methods other thang getters and listenersHi,
On 2008-07-21 17:49, margi wrote: > That's what I did finally! You're right about the fact that we're not > supposed to have logic in template, but personnaly I think there as some > logics that don't worth a Getter. Imagine if my list contains 10 elements > through which I have to iterate, I'd be oblige to write 10 getters, I really > think that it's cumbersome. I might be wrong on this point if there is an > elegant solution to that problem. Java: @Property private Item item; public List<Item> getItems() { return ...; } Template: <t:loop t:source="items" t:value="item"> <!-- do whatever you want with ${item} --> </t:loop> That's how you'd iterate through a list. -Filip --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Using methods other thang getters and listenersYes, and perhaps adding a SetupRender render phase method to setup a
temporary list with the values to iterate over. On Mon, Jul 21, 2008 at 10:42 AM, Filip S. Adamsen <fsa@...> wrote: > Hi, > > On 2008-07-21 17:49, margi wrote: >> >> That's what I did finally! You're right about the fact that we're not >> supposed to have logic in template, but personnaly I think there as some >> logics that don't worth a Getter. Imagine if my list contains 10 elements >> through which I have to iterate, I'd be oblige to write 10 getters, I >> really >> think that it's cumbersome. I might be wrong on this point if there is an >> elegant solution to that problem. > > Java: > > @Property > private Item item; > > public List<Item> getItems() { > return ...; > } > > Template: > > <t:loop t:source="items" t:value="item"> > <!-- do whatever you want with ${item} --> > </t:loop> > > > That's how you'd iterate through a list. > > -Filip > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > -- Howard M. Lewis Ship Creator Apache Tapestry and Apache HiveMind --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Using methods other thang getters and listenersThat, or just add @Cached to getItems.
-Filip On 2008-07-21 20:48, Howard Lewis Ship wrote: > Yes, and perhaps adding a SetupRender render phase method to setup a > temporary list with the values to iterate over. > > On Mon, Jul 21, 2008 at 10:42 AM, Filip S. Adamsen <fsa@...> wrote: >> Hi, >> >> On 2008-07-21 17:49, margi wrote: >>> That's what I did finally! You're right about the fact that we're not >>> supposed to have logic in template, but personnaly I think there as some >>> logics that don't worth a Getter. Imagine if my list contains 10 elements >>> through which I have to iterate, I'd be oblige to write 10 getters, I >>> really >>> think that it's cumbersome. I might be wrong on this point if there is an >>> elegant solution to that problem. >> Java: >> >> @Property >> private Item item; >> >> public List<Item> getItems() { >> return ...; >> } >> >> Template: >> >> <t:loop t:source="items" t:value="item"> >> <!-- do whatever you want with ${item} --> >> </t:loop> >> >> >> That's how you'd iterate through a list. >> >> -Filip >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@... >> For additional commands, e-mail: users-help@... >> >> > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
| Free Forum Powered by Nabble | Forum Help |