Tapestry4.0では、3.0の時のように
String path = this.getRequestCycle().getRequestContext().getServlet().getServletContext().getRealPath("/")
としても、getServletメソッドが存在しなかったり、
String path = this.getRequestCycle().getRequestContext().getRequest().getRealPath("/");
と記述しても、getRequestContextメソッドがdeprecatedになっていたりしています。
でも、パスを取得したいので、なんとかしてServletContextにアクセスする必要があるのですが、
4.0からはHiveMindのレジストリにはじめからサービスとして登録されています。
以下のようにして取得できます。
ページコンポーネントクラスに
@InjectObject("service:tapestry.globals.ServletContext") public abstract ServletContext getServletContext();
あとは、ソース内でthis.getServletContext()とすればHiveMindが
DIしてくれたServletContextにアクセスできます。
どうも、4.0からHiveMindが統合されたので、そちらの方にいろいろ
移っていった模様です。
以下のページでTapestry関連で使用できるHiveMindのサービス一覧が
見れます。
http://jakarta.apache.org/tapestry/tapestry/hivedocs/index.html
こりゃ、HiveMind理解しなきゃまずいな・・・・