Dear Wiki user, You have subscribed to a wiki page or wiki category on "Tapestry Wiki" for change notification.
The following page has been changed by ErikVullings: http://wiki.apache.org/tapestry/InjectASOIntoService ------------------------------------------------------------------------------ - = How to inject an Application State Object (ASO) into a Tapestry service = + =How to inject an Application State Object (ASO) into a Tapestry service= - Instead of injecting an ASO directly into a Tapestry service, we need to inject an Application``State``Manager and use the Application``State``Manager to retrieve the desired ASO. Suppose you would like to inject the ASO message into the service asoService. The following piece of hivemodule.xml shows how it could be done. - - {{{ - hivemodule.xml: - - <contribution configuration-id="tapestry.state.ApplicationObjects"> - <state-object name="message" scope="application"> - <create-instance class="man.aso.HelloMessage"/> - </state-object> - </contribution> - - <!-- Inject ApplicationStateManger into service asoSerive --> - <service-point id="asoService" interface="org.apache.tapestry.engine.IEngineService"> - <invoke-factory> - <construct class="service.ASOService"> - <set-object property="exceptionReporter" value="infrastructure:requestExceptionReporter"/> - <set-object property="response" value="infrastructure:response"/> - <set-object property="linkFactory" value="infrastructure:linkFactory"/> - <set-service property="appStateManager" - service-id="tapestry.state.ApplicationStateManager"/> - </construct> - </invoke-factory> - </service-point> - - - }}} - - In the .jave file of the Tapestry service asoService, add the setter/getter method for property app``State``Manager : - {{{ - private ApplicationStateManager appStateManager; - public ApplicationStateManager getAppStateManager() { - return appStateManager; - } - - public void setAppStateManager(ApplicationStateManager appStateManager) { - this.appStateManager = appStateManager; - } - }}} - - - To access the ASO message in the asoService : - {{{ - HelloMessage message = (HelloMessage) getAppStateManager().get("message"); - }}} - --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
