llonely skrev:
Hi all,


Hi,

I am new on Tapestry and try to become familiar with it, mostly through this
forum and the official site. I am trying to migrate a simple servlet into
tapestry.

While this is a logical approach to trying out something new, Tapestry generally works better if you rewrite your code instead of migrating - so many things are done differently in Tapestry compared to servlets.

I find myself search for days for tasks that seem simple. Currently I am
trying to achieve the following:

a) Load some init parameters, located in web.xml. I want to (pre)initialize
them once and have access to them from all pages. In a simple servlet i load
them inside servlet's init() method using ServletConfig. How can I do in on
Tapestry?

I'd suggest using symbols for that:
http://tapestry.apache.org/tapestry5/tapestry-ioc/symbols.html

b) Similarly with above, I want to load a datasource (configured on tomcat),
only once and use it on all my pages. In a simple servlet I do a Context
lookup in init() method and have the datasource object available.

You should definitely create a service for that. If you expose a getter to your datasource as part of the service interface you can use the PropertyShadowBuilder to expose the datasource as its own service, ready for easy injection into your pages:
http://tapestry.apache.org/tapestry5/tapestry-ioc/shadow.html

So to sum up the question is: how do I preload an object once, and have it
available
for all pages (not inside a session)?

Services. : )

I am using version 5.0.6

Thanks in advance

Hope this helps.

-Filip

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

Reply via email to