Alright, I've one last question regarding this process. In my custom Resource class, I need to get the URL for a packaged resource, to insert into the returned resource value. I was intending to do this using the following:
RequestCycle.get().urlFor(MY_PACKAGED_RESOURCE); However, when I attempt to pull up the Resource, it throws a NPE, because RequestCycle.get() is null. I didn't know that resources were retrieved outside of the normal RequestCycle process. How should I retrieve the URL instead? Thanks for your help! spencer.c wrote: > > Right, this is exactly my plan...what I need to know is, where do I do the > Application.getSharedResources() code? The component will be packaged in > its own jar, and I want the component to contribute its automatically, > without the App calling it specifically. I don't see a hook for > initializing the shared resources when the jar containing the component is > first loaded, but it seems like it has to exist... > > Actually, I think I just found what I need... > > 1) In root of the component's jar, put wicket.properties file that > contains: > initializer = mypackage.componentname > 2) Have my component implement IInitializer to contribute the shared > resources. > 3) Use the ResourceReferences' getUrl method as needed > > Look right? > > Thanks! > > > > > igor.vaynberg wrote: >> >> create a CssResource and JavascriptResource that extend Resource and >> know how to stream the contents by reading parameters off url. add >> those to application.getsharedresources(). >> >> then call urlfor(resourcereference) and you should have the url that >> invoke the resource. resourceref should have the same class,string you >> used to register the resource with shared resources. >> >> so you will end up with <link type="text/css" >> href="resources/com.my.component/javascript.js?foo=bar"/> in your html >> >> -igor >> >> On Wed, Feb 27, 2008 at 10:12 AM, spencer.c <[EMAIL PROTECTED]> >> wrote: >>> >>> I am making a component which needs to add (1) some javascript which >>> references the location of some images, and (2) some style-sheet >>> information >>> which references some images. The images are going to be located in >>> the jar >>> that contains the component. >>> >>> Since I need to insert the location of the images into the .js and >>> .css, I >>> templated them using PackagedTextTemplate, to insert the appropriate >>> references at runtime. >>> >>> Now, rather than insert the style info and javascript directly into the >>> page >>> I was trying to make those dynamic resources, so that they get >>> generated >>> once and then are easily referenced, rather than being re-templatized >>> with >>> each component request. I made two classes that override WebResource >>> to >>> provide the correct content. My question is, how do I let my component >>> jar >>> register these resources and then how do I include the references in >>> the >>> component itself? I think this is probably straightforward, but >>> haven't >>> been able to find an example of this somewhere. >>> Thanks for any pointers. >>> -- >>> View this message in context: >>> http://www.nabble.com/First-Complex-Component-Question...-tp15719359p15719359.html >>> Sent from the Wicket - User mailing list archive at Nabble.com. >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> > > -- View this message in context: http://www.nabble.com/First-Complex-Component-Question...-tp15719359p15724456.html Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
