IOC helps your code being more modular and less dependable,

you make your DAO class so it receives Session via constructor,
you can use your DAO class in any project easily.

in a tapestry app you add your DAO as service,
an later on inject it where needed. IOC gives
your DAO class the Session and gives your DAO
to who requires it. So yes ... use IOC ....
why would you code more plumbing code when IOC can do it for
you, and it does it very well.

I hope I'm making sense ...  :)

Davor Hrg




On 10/13/07, MavenMan <[EMAIL PROTECTED]> wrote:
>
>
> thanks . you are a capable man ! I have it resolved .
> but I still want to ask a basic question:Is using ioc to manage my DAO
> class
> a best and only approach ?
>
>
>
>
>
> Davor Hrg wrote:
> >
> > you must not put your dao objects into pages or components packages...
> >
> > http://wiki.apache.org/tapestry/Tapestry5HowToNotMakeCustomComponent
> > last section
> >
> > move your DAO into another package, yourApp.entities or sth..
> >
> > Davor Hrg
> >
> > On 10/12/07, MavenMan <[EMAIL PROTECTED]> wrote:
> >>
> >>
> >> I just code:
> >>
> >> binder.bind(CompanyDAO.class,CompanyDaoImpl.class);
> >>
> >> @Inject
> >> private CompanyDAO dao
> >>
> >> then call dao.method ,but
> >>
> >> org.apache.tapestry.internal.services.TransformationException: Error
> >> obtaining injected value for field com.myspacce.pages.Start.dao: No
> >> service
> >> implements the interface com.myspacce.pages.CompanyDAO.
> >>
> >> need I add annotation to  CompanyDaoImpl or CompanyDAO ?
> >>
> >> Best Regards !
> >>
> >> Josh Canfield-2 wrote:
> >> >
> >> >>
> >> >>        @Inject
> >> >>        @Service("CompanyDAO")
> >> >>        private CompanyDAO dao;
> >> >>
> >> >
> >> >
> >> > This should just be:
> >> > @Inject
> >> > private CompanyDAO dao;
> >> >
> >> > Josh
> >> >
> >> > On 10/11/07, MavenMan <[EMAIL PROTECTED]> wrote:
> >> >>
> >> >>
> >> >> now I want to know how to inject service to page class .
> >> >> after I add this in AppModule :
> >> >> binder.bind(CompanyDAO.class,CompanyDaoImpl.class)
> >> >> and add
> >> >>        @Inject
> >> >>        @Service("CompanyDAO")
> >> >>        private CompanyDAO dao;
> >> >>
> >> >> in page class.
> >> >>
> >> >> but it seem to be wrong !
> >> >>
> >> >> can you help me ?
> >> >> thanks
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> kristian.marinkovic wrote:
> >> >> >
> >> >> > do you have the hibernate libraries in your classpath?
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> > lasitha <[EMAIL PROTECTED]>
> >> >> > 11.10.2007 09:14
> >> >> > Bitte antworten an
> >> >> > "Tapestry users" <users@tapestry.apache.org>
> >> >> >
> >> >> >
> >> >> > An
> >> >> > "Tapestry users" <users@tapestry.apache.org>
> >> >> > Kopie
> >> >> >
> >> >> > Thema
> >> >> > Re: how to use ioc of t5 ?
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> > In my setup i've got all my hibernated classes in the 'entities'
> >> >> > package - which is automatically picked up tapestry-hibernate - so
> >> >> > i've not had to make a contribution like this.  I'm afraid i don't
> >> >> > have time to play with it right now either..., sorry.
> >> >> >
> >> >> > As an experiment, you might try moving (some of) your hibernated
> >> >> > classes from 'domain' into 'entities' and commenting out the
> >> >> > contribution code, just so we know whether your exception is
> related
> >> >> > to contributing a package or something else.
> >> >> >
> >> >> > Also, is there more to that exception stack?  It doesn't seem to
> >> >> > mention a cause...
> >> >> >
> >> >> > Lastly, i have a vague recollection of a past thread in this list
> >> >> > about contributing packages to tapestry-hibernate... did you
> happen
> >> to
> >> >> > run across anything in the archives?
> >> >> >
> >> >> > Cheers,
> >> >> > lasitha.
> >> >> >
> >> >> >
> >> >> > On 10/11/07, MavenMan <[EMAIL PROTECTED]> wrote:
> >> >> >>
> >> >> >> thanks.
> >> >> >>
> >> >> >> I hava add this to AppModule:
> >> >> >>
> >> >> >>  public static void
> >> >> >>     contributeHibernateSessionSource(Configuration<String>
> >> >> > configuration)
> >> >> >>         {
> >> >> >>             configuration.add("com.myspacce.domain");
> >> >> >>         }
> >> >> >>
> >> >> >> Company.java is in  com/myspacce/domain:
> >> >> >>
> >> >> >> import javax.persistence.*;
> >> >> >> @Entity
> >> >> >> @Table(name="company")
> >> >> >> public class Company {
> >> >> >>         @Id
> >> >> >>         @GeneratedValue
> >> >> >>
> >> >> >>         private int id;
> >> >> >>         private String name;
> >> >> >>
> >> >> >>         public Company()
> >> >> >>         {
> >> >> >>         }
> >> >> >>         public int getId()
> >> >> >>         {
> >> >> >>                 return id;
> >> >> >>         }
> >> >> >>         public void setId(int id)
> >> >> >>         {
> >> >> >>                 this.id=id;
> >> >> >>         }
> >> >> >>         public String getName()
> >> >> >>         {
> >> >> >>                 return name;
> >> >> >>         }
> >> >> >>         public void setName(String name)
> >> >> >>         {
> >> >> >>                 this.name=name;
> >> >> >>         }
> >> >> >>
> >> >> >> I have the tapestry-hibernate module in my classpath.
> >> >> >>
> >> >> >> error is :
> >> >> >>
> >> >> >> Error invoking service builder method
> >> >> >>
> >> >> > org.apache.tapestry.hibernate.HibernateModule.build
> >> >> (HibernateSessionSource,
> >> >> >> ThreadCleanupHub) (at HibernateModule.java:62) (for service
> >> >> >> 'HibernateSessionManager'): Exception constructing service
> >> >> >> 'HibernateSessionSource': Error invoking constructor
> >> >> >> org.apache.tapestry.internal.hibernate.HibernateSessionSourceImpl
> >> (Log,
> >> >> >> Collection, ClassNameLocator) (at HibernateSessionSourceImpl.java
> >> :35)
> >> >> > (for
> >> >> >> service 'HibernateSessionSource'):
> >> >> >> org/hibernate/cfg/annotations/ResultsetMappingSecondPass
> >> >> >>
> >> >> >>
> >> >> >> thanks
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> lasitha wrote:
> >> >> >> >
> >> >> >> > It looks like you don't have the tapestry-hibernate module in
> >> your
> >> >> >> > classpath.
> >> >> >> >
> >> >> >> > There are a couple of starters you should checkout:
> >> >> >> > http://tapestry.apache.org/tapestry5/tapestry-hibernate/
> >> >> >> >
> >> http://wiki.apache.org/tapestry/Tapestry5HowToUseTapestryHibernate
> >> >> >> >
> >> >> >> > And don't forget to search the mailing list archives:
> >> >> >> >
> >> http://wiki.apache.org/tapestry/Tapestry5HowToSearchTheMailingLists
> >> >> >> >
> >> >> >> > Let us know if those don't help,
> >> >> >> > Cheers, lasitha.
> >> >> >> >
> >> >> >> > On 10/11/07, MavenMan <[EMAIL PROTECTED]> wrote:
> >> >> >> >>
> >> >> >> >> hello all :
> >> >> >> >>
> >> >> >> >>      I write a page class :
> >> >> >> >>
> >> >> >> >> package com.myspacce.pages;
> >> >> >> >> import java.util.*;
> >> >> >> >> import org.apache.tapestry.annotations.*;
> >> >> >> >> import org.hibernate.*;
> >> >> >> >> public class Start
> >> >> >> >> {
> >> >> >> >>         public String _name;
> >> >> >> >>
> >> >> >> >>         @Inject
> >> >> >> >>         private Session _session;
> >> >> >> >>
> >> >> >> >>         public List getList()
> >> >> >> >>         {
> >> >> >> >>
> >> >> >> >>                 List list=_session.createQuery("select name
> from
> >> >> >> >> Company").list();
> >> >> >> >>                 return list;
> >> >> >> >>         }
> >> >> >> >> }
> >> >> >> >>
> >> >> >> >> run error is
> >> >> >> >> :org.apache.tapestry.internal.services.TransformationException
> :
> >> >> >> >> Error obtaining injected value for field
> >> >> >> >> com.myspacce.pages.Start._session:
> >> >> >> >> No service implements the interface org.hibernate.Session.
> >> >> >> >>
> >> >> >> >> can you help me how to implements the interface
> >> >> org.hibernate.Session
> >> >> > ?
> >> >> >> >>
> >> >> >> >> best regards
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> --
> >> >> >> >> View this message in context:
> >> >> >> >>
> >> >>
> http://www.nabble.com/how-to-use-ioc-of-t5---tf4604761.html#a13148406
> >> >> >> >> Sent from the Tapestry - User mailing list archive at
> >> Nabble.com.
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >>
> ---------------------------------------------------------------------
> >> >> >> >> 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]
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >>
> >> >> >> --
> >> >> >> View this message in context:
> >> >> >
> >> http://www.nabble.com/how-to-use-ioc-of-t5---tf4604761.html#a13149167
> >> >> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >> >> >>
> >> >> >>
> >> >> >>
> >> ---------------------------------------------------------------------
> >> >> >> 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]
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >>
> http://www.nabble.com/how-to-use-ioc-of-t5---tf4604761.html#a13150905
> >> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >>
> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > --
> >> > TheDailyTube.com. Sign up and get the best new videos on the internet
> >> > delivered fresh to your inbox.
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/how-to-use-ioc-of-t5---tf4604761.html#a13167348
> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/how-to-use-ioc-of-t5---tf4604761.html#a13188128
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to