You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Galen Meurer <si...@galenmeurer.com> on 2004/08/21 03:31:16 UTC

how does one get an IResourceLocation relative to the java class?

What is the proper way to get an IResourceLocation for the Java class, as
opposed to for the HTML or the specification that uses the class? More
specifically, how does one get a reference to a script that lives with the
java where the jwc/html does not?

I have a Java class that is used as the base class for many JWCs that are
not all in the same directory. This class produces java script, customized
by properities, but it should be the same script template for all the JWC
using it. As such, I need to find the script, but as the JWC are in various
locations and I don't want a bunch of copies of that script, so I have put
the script with the class.

I have tried:

        IResourceLocation classLocation =
getLocation().getResourceLocation();
        IResourceLocation specificationLocation =
getSpecification().getLocation().getResourceLocation();

The former returns the location of the HTML of the page. The latter the
location of the JWC of the component. But, I want the location of the class
itself.

The way I'm doing it now is:

    IResourceLocation classpathResolver = new
ClasspathResourceLocation(resourceResolver,
"/com/path/to/my/java/components/");
    IResourceLocation scriptLocation =
classpathResolver.getRelativeLocation("TheSharedComponent.script");

But using a concrete class this way this feels dirty and given the usual
comprehensiveness of Tapestry interfaces, I imagine there must be a better
way.

Thanks Very Much,
Galen;


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org