dev@jsftemplating.java.net

Re: JSFTemplating: How to getRealPath?

From: Ken Paulsen <Ken.Paulsen_at_Sun.COM>
Date: Mon, 10 Sep 2007 15:12:35 -0700

You can do:

    handlerContext.getFacesContext();

A HandlerContext instance is passed into your handler.

If you are in code that doesn't have a reference to anything, you can
get a reference to the FacesContext staticly:

    FacesContext.getCurrentInstance();

Good luck!

Ken

Karam.Badesha_at_Sun.COM wrote:
> And how is facesContext defined/extended/used in the java/handler code
> (since its an abstract class)?
>
> -Karam
>
> Ken Paulsen wrote:
>
>>
>> Hi Karam,
>>
>> The ExternalContext in JSF does not provide access to this method.
>> You will either need to cast to the ServletContext ((ServletContext)
>> ExternalContext.getContext()), or you will need to use reflection.
>>
>> JSFTempating's FileUtil class provides a method that uses reflection
>> to do this. Since you are already using JSFTemplating, you can do this:
>>
>>
>> FileUtil.getRealPath(facesContext.getExternalContext().getContext(),
>> "path");
>>
>> I hope this helps!
>>
>> Ken
>>
>> Karam.Badesha_at_Sun.COM wrote:
>
>