This is one area where the portlet standard is weak. If your parent resource (in this case the javascript resource) is dynamically generated then you are expected to use the portlet APIs for generating/outputing any dependent resource references. If the parent resource is static there is no universal standard way to support. Basic options: a) if the dependent resources are accessible to all your clients (i.e. not on the wrong side of a firewall) you can use absolute URL references (as long as these are static resources or you don't need access to things like the session). b) if your portlet is running on the same server as the consumer portal you should be able to use either absolute or context path urls. c) if your portlet is running remotely and using WSRP to communicate with the consumer you must doctor your parent resource and change the dependent resource references to be encoded with the WSRP rewrite tokens as per the specification.

FYI ... all of this is equally true for inline resources (those served via serveResource) and the original JSR 168 out of protocol style resources.
   -Mike-

Eric Chow wrote:
Hello,

I begin to study Portlet 2.0 new functions. I have some question in
serveResource( ....) method ?

I read some example in using this, and it just write out the
JavaScript or Image, or some static resources to the portlet, and
these contents can be dynamic load by using the resourceURL, right ?

I have a question, if I want to use serveResource to load a
JavaScript. In that JavaScript, it also need to load some image, will
the serveResource(..) handle this automatic or I have to change the
JavaScript manually?

For example, I download a Tree JavaScript component from some free
resources, it need to load a javascript, but the javascript also need
to load some GIFs.



Best regards,
Eric

Reply via email to