Re: Help with @Inject in onEvent Handler Object
Your DBConnect object is probably not in one of the tapestry controlled packages and thus inject doesn't work. You can inject the Session directly into your page, or turn your DBConnect object into a tapestry service by adding it to the services package, and changing the Session into a constructor argument. Hope this helps, Joost Ashwanth Kumar wrote: Hi, I've a problem. I'm using a page which has an actionlink like this: a t:type=actionlink t:id=alidLink Text/a And i've an @OnEvent handler in my Page Class, as follows: @OnEvent(component=alid) void function() { DBConnect db = new DBConnect(); System.out.println(db.getLine()); } Till, this i've no problem. I've an object called DBConnect which has the class as follows: public class DBConnect { @Inject Session _session; public String getLine() { * List _news = _session.createCriteria(RNews.class).list();* return _news.getText(); } } When i run the actionlink, i get an NullPointer Exception at the bolder line above (at the _session.createCriteria(RNews.class).list()).. Why does this happen? Isn't this mean, @Inject is not working, hence the _session is not initialized?? - Ashwanth Kumar - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Help with @Inject in onEvent Handler Object
Em Thu, 17 Dec 2009 10:17:15 -0200, Joost Schouten (ml) joost...@jsportal.com escreveu: Your DBConnect object is probably not in one of the tapestry controlled packages and thus inject doesn't work. You can inject the Session directly into your page, or turn your DBConnect object into a tapestry service by adding it to the services package, and changing the Session into a constructor argument. You can also declare DBConnect as a Tapestry service. Doing this, you can @Inject DBConnect and the @Inject annotation inside it will work. In your AppModule, add this method if you don't have it already: public static void bind(ServiceBinder binder) { binder.bind(DBConnect.class); } -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, software architect and developer, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Help with @Inject in onEvent Handler Object
Hey Thanks Guys! Its working cool! - Ashwanth Kumar On Thu, Dec 17, 2009 at 6:21 PM, Thiago H. de Paula Figueiredo thiag...@gmail.com wrote: Em Thu, 17 Dec 2009 10:17:15 -0200, Joost Schouten (ml) joost...@jsportal.com escreveu: Your DBConnect object is probably not in one of the tapestry controlled packages and thus inject doesn't work. You can inject the Session directly into your page, or turn your DBConnect object into a tapestry service by adding it to the services package, and changing the Session into a constructor argument. You can also declare DBConnect as a Tapestry service. Doing this, you can @Inject DBConnect and the @Inject annotation inside it will work. In your AppModule, add this method if you don't have it already: public static void bind(ServiceBinder binder) { binder.bind(DBConnect.class); } -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, software architect and developer, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org