You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by George Christman <gc...@cardaddy.com> on 2012/10/23 16:02:55 UTC

chenillekit velocity template injectable service not working.

Hello, I'm trying to get the Tapestry Chenillekit velocity template service
working, however I haven't had any success in configuring it with my
project. I can't seem to get Tapestry to bring in my dependencies despite
adding them to the pom, nor can I get the @Velocity to work. This is what I
have thus far. 

I'm using T5.3.6

        <dependency>
            <groupId>org.chenillekit</groupId>
            <artifactId>chenillekit-template</artifactId>
            <version>1.3.3</version>
        </dependency>

    public static void contributeVelocityService(MappedConfiguration<String,
Resource> configuration) {
        Resource velocityConfig = new
ClasspathResource("/velocity.properties");
        configuration.add("velocity.configuration", null);
    }

  @Inject
    @Velocity
    private TemplateService _templateService;

    public void emailBodyTemplate() {
        OutputStream emailBodyStream = new EmailBodyStream();
        Map parameterMap = new HashMap();
        parameterMap.put("user_name", "Athur Dent");
        parameterMap.put("login_tries", getLoginTries());
        parameterMap.put("block_date", new Date());
        parameterMap.put("sysadm_email",
"Zaphod.Beeblebrox@beteigeuze.behind.the.moon");
        _templateService.mergeDataWithResource(new
URIResource("./templates/email_body.ftl"),
                emailBodyStream, parameterMap)

        Email email = createEmail(emailBodyStream);
        email.send();
    }

documentation can be found here, 
http://chenillekit.codehaus.org/chenillekit-template/howto_velocityservice.html

Any ideas what I'm doing wrong?



--
View this message in context: http://tapestry.1045711.n5.nabble.com/chenillekit-velocity-template-injectable-service-not-working-tp5717168.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: chenillekit velocity template injectable service not working.

Posted by George Christman <gc...@cardaddy.com>.
Thanks Alex for all your help.

On Tue, Oct 23, 2012 at 3:25 PM, Alex Kotchnev-2 [via Tapestry] <
ml-node+s1045711n5717184h41@n5.nabble.com> wrote:

> George,
>   I haven't worked with the velocity service configuration (and I haven't
> looked at the source for that specifically).
>
>   My assumption is that if you don't contribute anything to the velocity
> service configuration, that would be equivalent to having a null
> configuration, but doing it the way you do looks OK.
>
> Cheers,
>
> Alex K
>
> On Tue, Oct 23, 2012 at 2:30 PM, George Christman
> <[hidden email] <http://user/SendEmail.jtp?type=node&node=5717184&i=0>>wrote:
>
>
> > Well Alex, it was my own fault. I was relying on my IDE to import my
> import
> > statements automatically on a key command and it wasn't doing so with
> > org.chenillekit, thus that was the issue.
> >
> > Also, would this be a correct configuration since the docs say the
> config
> > could be left null?
> >
> >     public static void
> > contributeVelocityService(MappedConfiguration<String,
> > Resource> configuration) {
> >         configuration.add("velocity.configuration", null);
> >     }
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://tapestry.1045711.n5.nabble.com/chenillekit-velocity-template-injectable-service-not-working-tp5717168p5717183.html
>
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5717184&i=1>
> > For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5717184&i=2>
> >
> >
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://tapestry.1045711.n5.nabble.com/chenillekit-velocity-template-injectable-service-not-working-tp5717168p5717184.html
>  To unsubscribe from chenillekit velocity template injectable service not
> working., click here<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5717168&code=Z2NocmlzdG1hbkBjYXJkYWRkeS5jb218NTcxNzE2OHwxNjMyOTYxMjA3>
> .
> NAML<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York




--
View this message in context: http://tapestry.1045711.n5.nabble.com/chenillekit-velocity-template-injectable-service-not-working-tp5717168p5717185.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: chenillekit velocity template injectable service not working.

Posted by Alex Kotchnev <ak...@gmail.com>.
George,
  I haven't worked with the velocity service configuration (and I haven't
looked at the source for that specifically).

  My assumption is that if you don't contribute anything to the velocity
service configuration, that would be equivalent to having a null
configuration, but doing it the way you do looks OK.

Cheers,

Alex K

On Tue, Oct 23, 2012 at 2:30 PM, George Christman
<gc...@cardaddy.com>wrote:

> Well Alex, it was my own fault. I was relying on my IDE to import my import
> statements automatically on a key command and it wasn't doing so with
> org.chenillekit, thus that was the issue.
>
> Also, would this be a correct configuration since the docs say the config
> could be left null?
>
>     public static void
> contributeVelocityService(MappedConfiguration<String,
> Resource> configuration) {
>         configuration.add("velocity.configuration", null);
>     }
>
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/chenillekit-velocity-template-injectable-service-not-working-tp5717168p5717183.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: chenillekit velocity template injectable service not working.

Posted by George Christman <gc...@cardaddy.com>.
Well Alex, it was my own fault. I was relying on my IDE to import my import
statements automatically on a key command and it wasn't doing so with
org.chenillekit, thus that was the issue. 

Also, would this be a correct configuration since the docs say the config
could be left null?

    public static void contributeVelocityService(MappedConfiguration<String,
Resource> configuration) {
        configuration.add("velocity.configuration", null);
    }




--
View this message in context: http://tapestry.1045711.n5.nabble.com/chenillekit-velocity-template-injectable-service-not-working-tp5717168p5717183.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: chenillekit velocity template injectable service not working.

Posted by Alex Kotchnev <ak...@gmail.com>.
I do see the Velocity annotation in the jar ( inside the
 org.chenillekit.template.services package). I assume that you have an
import statement (e.g. import org.chenillekit.template.services.Velocity)
at the top of your VelocityTemplateServiceImpl ?

The other difference in my case is that for services, I use constructor
injection ( I obviously use freemarker, but it should work just as well in
your case) , e.g. :

class FooService {

private final TemplateService templateService;

public FooService (@FreeMarker TemplateService templateService,
   this.templateService = templateService;
}
}
Cheers,

Alex

On Tue, Oct 23, 2012 at 1:47 PM, George Christman
<gc...@cardaddy.com>wrote:

> Alex, when I look into my dependencies package, I see
> chenillekit-template-1.3.3.jar. I have added the contributeVelocityService
> method to my app module, but when I try importing TemplateService or using
> the annotation @Velocity, I get the following compiling errors
>
> can not find symbol
> symbol: class Velocity
> location: class VelocityTemplateServiceImpl
>
> can not find symbol
> symbol: class TemplateService
> location: class VelocityTemplateServiceImpl
>
> Not sure why it's not finding the the classes.
>
> My class using the velocity sample.
>
> public class VelocityTemplateServiceImpl implements VelocityTemplateService
> {
>
>     @Inject
>     @Velocity
>     private TemplateService _templateService;
>
>     public void emailBodyTemplate() {
>         OutputStream emailBodyStream = new EmailBodyStream();
>         Map parameterMap = new HashMap();
>         parameterMap.put("user_name", "Athur Dent");
>         parameterMap.put("login_tries", getLoginTries());
>         parameterMap.put("block_date", new Date());
>         parameterMap.put("sysadm_email",
> "Zaphod.Beeblebrox@beteigeuze.behind.the.moon");
>         _templateService.mergeDataWithResource(new
> URIResource("./templates/email_body.ftl"),
>                 emailBodyStream, parameterMap)
>
>         Email email = createEmail(emailBodyStream);
>         email.send();
>     }
> }
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/chenillekit-velocity-template-injectable-service-not-working-tp5717168p5717178.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: chenillekit velocity template injectable service not working.

Posted by George Christman <gc...@cardaddy.com>.
Alex, when I look into my dependencies package, I see
chenillekit-template-1.3.3.jar. I have added the contributeVelocityService
method to my app module, but when I try importing TemplateService or using
the annotation @Velocity, I get the following compiling errors

can not find symbol
symbol: class Velocity
location: class VelocityTemplateServiceImpl

can not find symbol
symbol: class TemplateService
location: class VelocityTemplateServiceImpl

Not sure why it's not finding the the classes. 

My class using the velocity sample. 

public class VelocityTemplateServiceImpl implements VelocityTemplateService
{

    @Inject
    @Velocity
    private TemplateService _templateService;

    public void emailBodyTemplate() {
        OutputStream emailBodyStream = new EmailBodyStream();
        Map parameterMap = new HashMap();
        parameterMap.put("user_name", "Athur Dent");
        parameterMap.put("login_tries", getLoginTries());
        parameterMap.put("block_date", new Date());
        parameterMap.put("sysadm_email",
"Zaphod.Beeblebrox@beteigeuze.behind.the.moon");
        _templateService.mergeDataWithResource(new
URIResource("./templates/email_body.ftl"),
                emailBodyStream, parameterMap)

        Email email = createEmail(emailBodyStream);
        email.send();
    }
}



--
View this message in context: http://tapestry.1045711.n5.nabble.com/chenillekit-velocity-template-injectable-service-not-working-tp5717168p5717178.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: chenillekit velocity template injectable service not working.

Posted by Alex Kotchnev <ak...@gmail.com>.
George,
   what is the error ? Does it not find the dependency when you build ?

   I do use chenillekit-template (1.3.3) w/ Tapestry 5.3.4 and have no
issues with it..

Cheers,

Alex K

On Tue, Oct 23, 2012 at 10:02 AM, George Christman
<gc...@cardaddy.com>wrote:

> Hello, I'm trying to get the Tapestry Chenillekit velocity template service
> working, however I haven't had any success in configuring it with my
> project. I can't seem to get Tapestry to bring in my dependencies despite
> adding them to the pom, nor can I get the @Velocity to work. This is what I
> have thus far.
>
> I'm using T5.3.6
>
>         <dependency>
>             <groupId>org.chenillekit</groupId>
>             <artifactId>chenillekit-template</artifactId>
>             <version>1.3.3</version>
>         </dependency>
>
>     public static void
> contributeVelocityService(MappedConfiguration<String,
> Resource> configuration) {
>         Resource velocityConfig = new
> ClasspathResource("/velocity.properties");
>         configuration.add("velocity.configuration", null);
>     }
>
>   @Inject
>     @Velocity
>     private TemplateService _templateService;
>
>     public void emailBodyTemplate() {
>         OutputStream emailBodyStream = new EmailBodyStream();
>         Map parameterMap = new HashMap();
>         parameterMap.put("user_name", "Athur Dent");
>         parameterMap.put("login_tries", getLoginTries());
>         parameterMap.put("block_date", new Date());
>         parameterMap.put("sysadm_email",
> "Zaphod.Beeblebrox@beteigeuze.behind.the.moon");
>         _templateService.mergeDataWithResource(new
> URIResource("./templates/email_body.ftl"),
>                 emailBodyStream, parameterMap)
>
>         Email email = createEmail(emailBodyStream);
>         email.send();
>     }
>
> documentation can be found here,
>
> http://chenillekit.codehaus.org/chenillekit-template/howto_velocityservice.html
>
> Any ideas what I'm doing wrong?
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/chenillekit-velocity-template-injectable-service-not-working-tp5717168.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>