2011/1/25 Luu Thang <[email protected]> > *@Gilberto:* Thanks for your example. But it's seem difficult with me. > > There is no difficulty on that example. I've not used any layer of complexity. What I did was follow the docs of both framework(cayenne and click) to setup one web app: Click--> you can use the start up guide, no problem here Cayenne: 1) -use the modeler to build the data model: http://code.google.com/p/construtor/source/browse/trunk/cip/helpdesk/src/main/resources/HelpDeskDataMap.map.xml http://code.google.com/p/construtor/source/browse/trunk/cip/helpdesk/src/main/resources/cayenne-HelpDeskDomain.xml
-generate the classes: http://code.google.com/p/construtor/source/browse/trunk/cip/helpdesk/src/main/#main%2Fjava%2Fhelpdesk%2Fmodel 2-config the CayenneFilter in the web.xml file: <quote> <filter> <filter-name>DataContextFilter</filter-name> <filter-class>org.apache.cayenne.configuration.web.CayenneFilter</filter-class> <init-param> <param-name>configuration-location</param-name> <param-value>cayenne-HelpDeskDomain.xml</param-value> </init-param> </filter> <filter-mapping> <filter-name>DataContextFilter</filter-name> <servlet-name>click-servlet</servlet-name> </filter-mapping> </quote> 3-use it in the page click controller: http://code.google.com/p/construtor/source/browse/trunk/cip/helpdesk/src/main/java/helpdesk/web/page/ViewEquipmentType.java <quote> private ObjectContext context = DataContext.getThreadObjectContext(); . . . private List getAll() { System.out.println("\n getAll() method \n"); SelectQuery query = new SelectQuery(EquipmentType.class); List equipmentTypes = context.performQuery(query); return equipmentTypes; } </quote> > *The question is:* > *Could you show me how do I lookup the datasource (in DatabaseInitListener > class) and how do I query all News (in NewsService.java) ?* > > Initially you need to know how to setup everything and after that you can go into more elaborate codes. It is just my understanding and I hope it can help a little. Regards, Gilberto
