On 7/28/06, Marty Phee <[EMAIL PROTECTED]> wrote:

Thanks.  I'll move over to that list, but I'm looking for the
application path.  Not the context path.


By "application path" do you mean the directory path to where the
application is deployed from on disk?  You are correct in noticing that this
is not exposed to the application via JSF APIs ... in part because there
might not actually be such a thing (for example, if the app server runs your
application from an unpacked WAR fie, or puts all the resources into a
database or somethng like thiat).  The best you can do is infer it from a
call like this:

   FacesContext fcontext = FacesContext.getCurrentInstance();
   ServletContext scontext = (ServletContext) fcontext.getExternalContext
().getContext();
   String path = scontext.getRealPath("/index.html"); // Or some resource
known to exist
   ... check path for being null ...
   ... strinp off the last segment to get the directory path ...

Craig


Craig McClanahan wrote:
> On 7/28/06, Marty Phee <[EMAIL PROTECTED]> wrote:
>>
>> How do I get the application path.
>>
>> I can see it in the debugger through the ApplicationContextFacade, but
>> not sure how to access it.
>>
>> I need the path of the application to pass on to a report generator.
>
>
> Shale has migrated to its own top level project with it's own mailing
> lists
> ... you'll want to refer to <http://shale.apache.org/mail-lists.html>
for
> subscription information.
>
> But, to answer this particular question, the context path of an
> application
> is available from the ExternalContext associated with the current
> request.
> In a view controller (or other class that extends AbstractFacesBean),
you
> can call:
>
>    String contextPath = getExternalContext().getContextPath();
>
> or, in any sort of backing bean, you can use the more verbose approach:
>
>    FacesContext context = FacesContext.getCurrentInstance();
>    String contextPath = context.getExternalContext().getContextPath();
>
>
>
> Thanks,
>>
>> Marty
>
>
> Craig
>


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


Reply via email to