Have you tried using a StateObjectFactory? -----Original Message----- From: Blackwings [mailto:[EMAIL PROTECTED] Sent: Thursday, July 20, 2006 9:07 AM To: Tapestry users Subject: Re: ASO and hivemind.xml
The situation is : I create class that extends ApplicationServlet and I specify it as the tapestry main servlet in web.xml. In this class I call a class that initialise some "application objects" such as list of element common to everybody from the database. My class also set a bean member and implement the get/set method. I also specified this class as an ASO as you told me to do Geoff and I put the inject tag in my Home.page. At the loading of the application, my "application object" is loaded normally and contains all the list. When I call the Home.page, the inject seems to work and the pageBeginRender is called normally. I call getMyASO() I declared abstract, but when I try to get the "application object" it is null!! I think Tapestry recreate an instance of MyASO instead of directly get the first loaded : web.xml ... <servlet> <servlet-name>dm</servlet-name> <display-name>DM Initialization servlet</display-name> <servlet-class>dgt.dm.controller.DossierManagerApplication </servlet-class> <load-on-startup>0</load-on-startup> </servlet> ... hivemodule.xml <?xml version="1.0" encoding="UTF-8"?> <module id="dgt.dm.controller" version="06.02.01" package="dgt.dm.controller "> <contribution configuration-id="tapestry.state.ApplicationObjects"> <state-object name="dossierManagerApplication" scope="application"> <create-instance class="dgt.dm.controller.DossierManagerApplication"/> </state-object> </contribution> </module> DossierManagerApplication.java public class DossierManagerApplication extends ApplicationServlet { private ApplicationSettings appSettings = null; public ApplicationSettings getAppSettings() { return appSettings; } public void setAppSettings(ApplicationSettings appSettings) { this.appSettings = appSettings; } private InitServlet is = null; public void init(ServletConfig arg0) throws ServletException { super.init(arg0); String webRootPath = getServletContext().getRealPath("/"); is = new InitServlet(); is.init(webRootPath); appSettings = is.getAppSettings(); // NOT NULL WHEN I DEBUG } ... HomePage.page ... <page-specification class="dgt.dm.pages.HomePage"> <inject property="dossierManagerApplication" type="state" object="dossierManagerApplication"/> </page-specification> HomePage.java public abstract DossierManagerApplication getDossierManagerApplication(); public abstract void setDossierManagerApplication(DossierManagerApplication dossierManagerApplication); public void pageBeginRender(PageEvent event) { DossierManagerApplication dossierManagerApplication = getDossierManagerApplication(); ApplicationSettings appSettings = dossierManagerApplication.getAppSettings(); // IS NULL setRequesters(appSettings.getRequesters()); setLanguages(appSettings.getLanguages()); } Thanks for help... BW 2006/7/20, Blackwings <[EMAIL PROTECTED]>: > > Thanks a lot, but I have a question again: To what, the id in the module > tag, refer? Is it the name of my context? is it app? is it the package where > something (what?) is store? Same question for the version. > > Thanks anyway > > BW > > 2006/7/20, Geoff Callender <[EMAIL PROTECTED]>: > > > BW, > > > > No need to touch hivemind.xml. Add a file called hivemodule.xml to > > WEB-INF, with content similar to this: > > > > <?xml version="1.0"?> > > > > <module id="jumpstart" version=" 1.0.0" package="jumpstart.web"> > > > > <!-- ServiceLocator and Visit --> > > > > <contribution configuration-id=" > > tapestry.state.ApplicationObjects"> > > <state-object name="serviceLocator" scope="application"> > > > > <create-instance class=" > > jumpstart.web.base.ServiceLocator"/> > > </state-object> > > </contribution> > > > > <contribution configuration-id=" > > tapestry.state.ApplicationObjects"> > > <state-object name="visit" scope="session"> > > <create-instance class="jumpstart.web.base.Visit"/> > > > > </state-object> > > </contribution> > > > > </module> > > > > In that example, ServiceLocator performs a similar function to the > > typical Global. Visit is just like the old Visit. Note that the > > scope of ServiceLocator is "application" and the scope of Visit is > > "session". > > > > Here's an example of them being referenced in a page: > > > > @InjectState("serviceLocator") > > public abstract ServiceLocator getServiceLocator(); > > > > @InjectState("visit") > > // Can't call it getVisit() because it conflicts with a > > deprecated > > IPage method > > public abstract Visit getMyVisit(); > > > > Hope this helps. > > > > Geoff > > http://tapestry.apache.org/tapestry4.1/QuickStart/contributed.html > > > > > > On 20/07/2006, at 7:58 PM, Blackwings wrote: > > > > > Hi, > > > > > > I found in the document what is the line to add into hivemind.xml > > > file to > > > create an ASO since getGlobal is deprecated. But I didn't find a > > > standard" > > > hivemind.xml file and I have no idea what is mandatory to put in. I > > > just > > > want to declare my ASO object to be able to inject it in my page. > > > > > > So, where can I find a standard hivemind.xml or what do I have to > > > put in to > > > still have my application working normally? > > > > > > Thanks > > > > > > BW > > > > > > --------------------------------------------------------------------- > > 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]