Re: Re: [T5] Sending Email from Tapestry
Hi Michael, I have tried your suggestion. In my environment (5.0.11) it does not work. Even with explicit id Messages provided, the ioc-container throws a RuntimeException complaining that Messages is not a defined service. You must have done sth. else to make your suggestion work in your environment. Although the RuntimeException your suggestion caused, helped me a lot! It shows all ids of defined services. Amongst them is ComponentSource, which serves my needs. So YOU helped me man, maybe not in the intended way, but you did ;-) I myself (as well as obviously the ioc-container) have problems considering Messages a service. To me it only gets a meaning as part of a particular page/component. Thinking about that I was looking for methods to get a hand on that part. As it turned out in Tapestry the right term to look for is resource. And this is how i have rewritten my build method: public static KursConfirmationSender builConfirmationMailSender(ComponentSource cs ) { return new ConfirmationMaiilSenderImpl(cs.getPage(bookings/Summary).getComponentResources().getMessages()); } bookings/Summary is the logical name of the page that holds the messages needed for assembly of the email. I am thinking about implementing a page ConfirmationMail that serves the only purpose to hold the messages. May be I will do that later. So thanks to Thiago, Michael and Sven for your efforts, nillehammer - original Nachricht Betreff: Re: [T5] Sending Email from Tapestry Gesendet: Sa, 19. Apr 2008 Von: Michael Gerzabek[EMAIL PROTECTED] nille, maybe you wanna try adding the InjectService annotation. This at least works for my services. public static ConfirmationMailSender buildConfirmationMailSender( @InjectService(Messages) Messages messages) { return new ConfirmationMailSender(messages); } good morning, Michael - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: [T5] Sending Email from Tapestry
I think you may be better off using a MessagesSource service. Check out ValidationMessagesSource for some ideas. TapestryModule.java (in particular the contribute and build methods got ValidationMessagesSource): http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java?view=markup ValidationMessagesSource.java (interface): http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ValidationMessagesSource.java?view=markup ValidationMessagesSourceImpl.java: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ValidationMessagesSourceImpl.java?view=markup Peter Beshai On Sat, Apr 19, 2008 at 7:08 AM, nille hammer [EMAIL PROTECTED] wrote: Hi Michael, I have tried your suggestion. In my environment (5.0.11) it does not work. Even with explicit id Messages provided, the ioc-container throws a RuntimeException complaining that Messages is not a defined service. You must have done sth. else to make your suggestion work in your environment. Although the RuntimeException your suggestion caused, helped me a lot! It shows all ids of defined services. Amongst them is ComponentSource, which serves my needs. So YOU helped me man, maybe not in the intended way, but you did ;-) I myself (as well as obviously the ioc-container) have problems considering Messages a service. To me it only gets a meaning as part of a particular page/component. Thinking about that I was looking for methods to get a hand on that part. As it turned out in Tapestry the right term to look for is resource. And this is how i have rewritten my build method: public static KursConfirmationSender builConfirmationMailSender(ComponentSource cs ) { return new ConfirmationMaiilSenderImpl(cs.getPage(bookings/Summary).getComponentResources().getMessages()); } bookings/Summary is the logical name of the page that holds the messages needed for assembly of the email. I am thinking about implementing a page ConfirmationMail that serves the only purpose to hold the messages. May be I will do that later. So thanks to Thiago, Michael and Sven for your efforts, nillehammer - original Nachricht Betreff: Re: [T5] Sending Email from Tapestry Gesendet: Sa, 19. Apr 2008 Von: Michael Gerzabek[EMAIL PROTECTED] nille, maybe you wanna try adding the InjectService annotation. This at least works for my services. public static ConfirmationMailSender buildConfirmationMailSender( @InjectService(Messages) Messages messages) { return new ConfirmationMailSender(messages); } good morning, Michael - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: [T5] Sending Email from Tapestry
Hi Thiago, thanks for the advice that makes perfect sense! What is left is my first question, where does Tapestry how to choose the right message catalogue? If I injected the ConfirmationMailSender in my BookingSummary Page would Tapestry use it´s message catalogue? So would I have to put the localized messages into BookingSummary.properties? Thanks and regards, nillehammer - original Nachricht Betreff: Re: [T5] Sending Email from Tapestry Gesendet: Fr, 18. Apr 2008 Von: Thiago HP[EMAIL PROTECTED] On 4/18/08, nille hammer [EMAIL PROTECTED] wrote: And secondly as far as I understand only services can be parameters to build methods. Am I wrong or do I have to make my Booking class a service? I suggest you a slightly different approach: create a ConfirmationMailSender service. It will have a send(Booking booking) method that will send the confirmation message for a given booking. public static ConfirmationMailSender buildConfirmationMailSender(Messages messages) { return new ConfirmationMailSender(messages); } -- Thiago - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- original Nachricht Ende - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: [T5] Sending Email from Tapestry
On 4/18/08, nille hammer [EMAIL PROTECTED] wrote: Hi Thiago, Hi, Nille! thanks for the advice that makes perfect sense! What is left is my first question, where does Tapestry how to choose the right message catalogue? If I injected the ConfirmationMailSender in my BookingSummary Page would Tapestry use it´s message catalogue? So would I have to put the localized messages into BookingSummary.properties? I suggest you to put your localized messages in app.properties, being app the name of the Tapestry servlet filter in you web.xml (answer for your first question). But you could also put them in BookingSummary.properties, but then they would only be used in that page, not in the rest of your application (answer for your second e third questions). Tapestry, the web framework, always looks first in the page-specific properties file first and then in the global one after. All I'm saying here is valid for Tapestry web applications. I'm not sure (and I can't find out now, unfortunately) what would be the name of the properties file in a non-web application using Tapestry-IoC. -- Thiago - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: Re: [T5] Sending Email from Tapestry
Hi Thiago, I am aware of the difference between App.properties and page specific properties. As my App.properties tends to grow significantly, I try to keep everything local unless it is needed by at least two components/pages. BTW, using Messages as a parameter to a build method in AppModule. does not work. The ioc-container throws a RuntimeException: No service implements the interface org.apache.tapestry.ioc.Messages. So I tried ComponentResources. That is an interface (Messages is not) and provides a method getMessages(). That led to the same result. I also added Annotation @Inject, no success. Until now I haven´t managed to get a hand on my ConfirmationMailSender via the ioc-Container. What I´m doing now ist calling new ConfirmationMailSender(this.messages) from within the page that uses it. That might not be ideal, but it works pretty well. So any one who knows how to provide a message catalogue to a service builder method, please do not hesitate to enlight me. Thanks and good night, nillehammer - original Nachricht Betreff: Re: Re: [T5] Sending Email from Tapestry Gesendet: Fr, 18. Apr 2008 Von: Thiago HP[EMAIL PROTECTED] On 4/18/08, nille hammer [EMAIL PROTECTED] wrote: Hi Thiago, Hi, Nille! thanks for the advice that makes perfect sense! What is left is my first question, where does Tapestry how to choose the right message catalogue? If I injected the ConfirmationMailSender in my BookingSummary Page would Tapestry use it´s message catalogue? So would I have to put the localized messages into BookingSummary.properties? I suggest you to put your localized messages in app.properties, being app the name of the Tapestry servlet filter in you web.xml (answer for your first question). But you could also put them in BookingSummary.properties, but then they would only be used in that page, not in the rest of your application (answer for your second e third questions). Tapestry, the web framework, always looks first in the page-specific properties file first and then in the global one after. All I'm saying here is valid for Tapestry web applications. I'm not sure (and I can't find out now, unfortunately) what would be the name of the properties file in a non-web application using Tapestry-IoC. -- Thiago - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- original Nachricht Ende - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: Re: Re: [T5] Sending Email from Tapestry
Me again, That is an interface (Messages is not) Huuh!! Bad, faux pas! I have to correct myself in fact Messages IS an interface. But no matter it does not work. Bye - original Nachricht Betreff: Re: Re: Re: [T5] Sending Email from Tapestry Gesendet: Sa, 19. Apr 2008 Von: nille hammer[EMAIL PROTECTED] Hi Thiago, I am aware of the difference between App.properties and page specific properties. As my App.properties tends to grow significantly, I try to keep everything local unless it is needed by at least two components/pages. BTW, using Messages as a parameter to a build method in AppModule. does not work. The ioc-container throws a RuntimeException: No service implements the interface org.apache.tapestry.ioc.Messages. So I tried ComponentResources. That is an interface (Messages is not) and provides a method getMessages(). That led to the same result. I also added Annotation @Inject, no success. Until now I haven´t managed to get a hand on my ConfirmationMailSender via the ioc-Container. What I´m doing now ist calling new ConfirmationMailSender(this.messages) from within the page that uses it. That might not be ideal, but it works pretty well. So any one who knows how to provide a message catalogue to a service builder method, please do not hesitate to enlight me. Thanks and good night, nillehammer - original Nachricht Betreff: Re: Re: [T5] Sending Email from Tapestry Gesendet: Fr, 18. Apr 2008 Von: Thiago HP[EMAIL PROTECTED] On 4/18/08, nille hammer [EMAIL PROTECTED] wrote: Hi Thiago, Hi, Nille! thanks for the advice that makes perfect sense! What is left is my first question, where does Tapestry how to choose the right message catalogue? If I injected the ConfirmationMailSender in my BookingSummary Page would Tapestry use it´s message catalogue? So would I have to put the localized messages into BookingSummary.properties? I suggest you to put your localized messages in app.properties, being app the name of the Tapestry servlet filter in you web.xml (answer for your first question). But you could also put them in BookingSummary.properties, but then they would only be used in that page, not in the rest of your application (answer for your second e third questions). Tapestry, the web framework, always looks first in the page-specific properties file first and then in the global one after. All I'm saying here is valid for Tapestry web applications. I'm not sure (and I can't find out now, unfortunately) what would be the name of the properties file in a non-web application using Tapestry-IoC. -- Thiago - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- original Nachricht Ende - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- original Nachricht Ende - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]