Re: reading a file in web root in a Tapestry fashion

2006-12-21 Thread Ron Piterman
http://hivemind.apache.org/hivemind/BuilderFactory.html#Autowiring Cyrille37 wrote: > Ron Piterman a écrit : >> yes, thats it - BTW, you don't need an explicit set-service. >> just exposte a setter in your implementation class, and hivemind will >> autowire it: >> >> public void setServletContex

Re: reading a file in web root in a Tapestry fashion

2006-12-21 Thread Ron Piterman
for example, you can not expect hivemind to inject IEngineService automatically since there are many services implementing this interface (PageService, ExternalService, DirectService and so on) Otherwise it works fine. Cheers, Ron Jiří Mareš wrote: > Hi, > > the rules are quite simple, there

Re: reading a file in web root in a Tapestry fashion

2006-12-21 Thread Jiří Mareš
Hi, the rules are quite simple, there have to be only one service of the type ... otherwise you have to specify what service do you want to ... Jirka Cyrille37 napsal(a): > > Ron Piterman a écrit : >> yes, thats it - BTW, you don't need an explicit set-service. >> just exposte a setter in you

Re: reading a file in web root in a Tapestry fashion

2006-12-21 Thread Cyrille37
Ron Piterman a écrit : yes, thats it - BTW, you don't need an explicit set-service. just exposte a setter in your implementation class, and hivemind will autowire it: public void setServletContext( ServletContext ctx) {...} heuu... I do not really understand. Do you mean Hivemind will do tha

Re: reading a file in web root in a Tapestry fashion

2006-12-21 Thread Ron Piterman
yes, thats it - BTW, you don't need an explicit set-service. just exposte a setter in your implementation class, and hivemind will autowire it: public void setServletContext( ServletContext ctx) {...} Cheers, Ron Cyrille37 wrote: > Ron Piterman a écrit : >> On which class do you need to access

Re: reading a file in web root in a Tapestry fashion

2006-12-21 Thread Cyrille37
Ron Piterman a écrit : On which class do you need to access the resource? I've resolved the case with Hivemind. I pass to the ObjectFactory the ServletContext to get a root path and the relative filename. interface="games.hangman.service.HangmanFactory">

Re: reading a file in web root in a Tapestry fashion

2006-12-21 Thread Ron Piterman
On which class do you need to access the resource? Cheers, Ron Cyrille37 wrote: > Hello, > Sure it is a beginner question, but I'm a beginner :o) > > I would like to read a file which is located in the web root folder, and > put it in a String. > I had a look around the Internet and found some

Re: reading a file in web root in a Tapestry fashion

2006-12-21 Thread Marilen Corciovei
This only works from inside a Tapestry page because this is linked to the servlet context which knows about the real path. To a standard class you need to pass the information somehow. Without injection it can be: getPage().getRequestCycle().getRequestContext().getServlet().getServletContext().ge

Re: reading a file in web root in a Tapestry fashion

2006-12-21 Thread Cyrille37
Marilen Corciovei a écrit : Hello, @InjectObject("service:tapestry.globals.ServletContext") public abstract ServletContext getServletContext(); I could not use an abstract class. How will I instantiate it ? I would not like to instantiate it with an IoC but like a normal Java Object. Cyrill

Re: reading a file in web root in a Tapestry fashion

2006-12-21 Thread Cyrille37
Marilen Corciovei a écrit : Hello, @InjectObject("service:tapestry.globals.ServletContext") public abstract ServletContext getServletContext(); Yes, that's it. Thanks Len. And Please, how to without annotation ? I'm looking in Tapestry Javadoc for some static method and I could not find one.

Re: reading a file in web root in a Tapestry fashion

2006-12-21 Thread Marilen Corciovei
Hello, @InjectObject("service:tapestry.globals.ServletContext") public abstract ServletContext getServletContext(); ... String imageDir = getServletContext().getRealPath("images"); ... Len www.len.ro On Thu, 2006-12-21 at 10:02 +0100, Cyrille37 wrote: > Hello, > Sure it is a beginner question

Re: reading a file in web root in a Tapestry fashion

2006-12-21 Thread Cyrille37
More generally, I would like to know how to access Application environment for a service class. So, Is there somewhere in Tapestry a Static method that could return some global Application information ? For example, from a Service (Business) Class I would like to: - get the Application Web Root