1)
   <contribution configuration-id="tapestry.state.ApplicationObjects">
        <state-object name="hangmanStateObject" scope="session" >
            <invoke-factory object="service:HangmanFactory" />
        </state-object>
    </contribution>

        <service-point id="HangmanFactory"
interface="org.apache.tapestry.engine.state.StateObjectFactory">
                <invoke-factory>
                        <construct class="games.hangman.service.Hangman">
                                <set-service property="servletContext"
service-id="service:tapestry.globals.ServletContext" />
                        </construct>
                </invoke-factory>
        </service-point>

2) Create a class that implements
org.apache.tapestry.engine.state.StateObjectFactory with this signature:
        public Object createStateObject() {
                // create your Hangman here
        }

        public void setServletContext(ServletContext context) {
                this.context = context;
        }


Hope this helps,

</Firas>

-----Original Message-----
From: Cyrille37 [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 21, 2006 12:32 PM
To: Tapestry users
Subject: hivemind create-instance and additionnal parameters

Hi,

I know I'm noisy on this list with my beginner's questions. Sorry for that,
but it is not so easy to swallow all Tapestry's stuff.
by the way, here is my new question:

I would like to add a Session object. This config wroks nice.
   <contribution configuration-id="tapestry.state.ApplicationObjects">
        <state-object name="hangmanStateObject" scope="session" >
            <create-instance class="games.hangman.service.Hangman" />
        </state-object>
    </contribution>
Now I would like to pass a parameter or set a property to that object (like
i use to do with Spring).
In the object's class (games.hangman.service.Hangman) I would like to inject
the ServletContext.
With Annotation I could do like :
    @InjectObject("service:tapestry.globals.ServletContext")
    public abstract ServletContext getServletContext(); But I do not want to
use Annotation.

so  I would like to add this ServletContext in the previous
state-object/create-instance definition. I'd a look at documentation
(http://hivemind.apache.org/descriptor.html) but I did not find the right
way.

Thanks for your help.
cyrille




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to