Re: packaging images/css in a jar?
I faced this exact problem (images in src/main/resources/images). This is what I chose to do (interested in cleaner way though): 1) In MyPage.java: URL noProgramImageURL = getClass().getClassLoader().getResource(images/transparentPixel.png); File noProgramImageFile = new File(noProgramImageURL.toURI()); Image programImage = new Image(programImage, new FileResource(noProgramImageFile)); 2) The FileResource.java class is available at http://www.nabble.com/forum/ViewPost.jtp?post=17359927 mfs wrote: src/main/resources?..lets say if its a maven structure.. mfs wrote: Guys, Wondering as to where would i be packaging my images/css in case of a jar ? Farhan. -- View this message in context: http://www.nabble.com/packaging-images-css-in-a-jar--tp13652419p17425997.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]
Re: packaging images/css in a jar?
Thanks Eelco..so that means the image cant just be anywhere in the classpath, it has to be either 1) In the same directory as the page-component or 2) In the webapp folder in case of a war and can be accesed via ContextImage... Secondly can you give me an example of how would i use a dummy class to refer/access an image resources in the same directory.. Thanks in advance Farhan. Eelco Hillenius wrote: Anyways actually i dont have a webapp directory and dont want to have that in my jar project...just want the .class files and the images (and may be css)..both residing it a different folders structure... basically below is the resulting jar structure i have and would want to keep my-custom-component - [package/classes] : org/xyz/utils (contains the page components and other classes) - [images/css] : images/myimage.jpg, css/style.css The only way to do that is to create an images package, put some dummy class in there, and use that as the reference when you these resources. Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/packaging-images-css-in-a-jar--tf4772567.html#a13676050 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: packaging images/css in a jar?
Thanks Eelco..so that means the image cant just be anywhere in the classpath, it has to be either 1) In the same directory as the page-component or 2) In the webapp folder in case of a war and can be accesed via ContextImage... It can be arbitrary as long as you have a class relative to it you reference (and ../ is not allowed, so only deeper). Secondly can you give me an example of how would i use a dummy class to refer/access an image resources in the same directory.. new ResourceReference(Foo.class, some/subdir/relative/to/foo/Bar.css) Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: packaging images/css in a jar?
src/main/resources?..lets say if its a maven structure.. mfs wrote: Guys, Wondering as to where would i be packaging my images/css in case of a jar ? Farhan. -- View this message in context: http://www.nabble.com/packaging-images-css-in-a-jar--tf4772567.html#a13652470 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: packaging images/css in a jar?
On Nov 8, 2007 10:02 AM, mfs [EMAIL PROTECTED] wrote: Guys, Wondering as to where would i be packaging my images/css in case of a jar ? Typically relative to where you use it. Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: packaging images/css in a jar?
but i am wondering as to how would i make it work wicket such that image gets fetched from the classpath and not relative to the application root.. So basically here is my scenario, i have jar bundled with the page components and in them i want to refer to the images (bundled within the jar only). This jar will eventually be bundled within a war application which will be using these components. Farhan. Eelco Hillenius wrote: On Nov 8, 2007 10:02 AM, mfs [EMAIL PROTECTED] wrote: Guys, Wondering as to where would i be packaging my images/css in case of a jar ? Typically relative to where you use it. Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/packaging-images-css-in-a-jar--tf4772567.html#a13652829 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: packaging images/css in a jar?
src/main/resources?..lets say if its a maven structure.. No, just in the classpath. Look at wicket-examples/ images example for instance. Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: packaging images/css in a jar?
but i am wondering as to how would i make it work wicket such that image gets fetched from the classpath and not relative to the application root.. So basically here is my scenario, i have jar bundled with the page components and in them i want to refer to the images (bundled within the jar only). This jar will eventually be bundled within a war application which will be using these components. Wicket reads packaged resources from the classpath, including individual jars. For instance, look at the date picker in wicket-datetime. That has a whole bunch of CSS/ JavaScript and even image dependencies that all get served from the jar. Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: packaging images/css in a jar?
On Nov 8, 2007 11:16 AM, mfs [EMAIL PROTECTED] wrote: Actually it does work when the image is in the same directory as that of the page (same with the example u pointed out)..how would i refer to an image which is altogether is a different structure... lets say my page is at org.xyz.util [page.html] and from within it i want to refer to an image which is in the images directory... using add(new Image(taxCientLogo, new Model(images/company-logo.jpg))); add(new Image(taxCientLogo, new Model(/images/company-logo.jpg))); For images residing in your web app directory, you would use for instance new ContextImage(img, new Model(images/company-logo.jpg)); or simply img src=images/company-logo.jpg / Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: packaging images/css in a jar?
Actually it does work when the image is in the same directory as that of the page (same with the example u pointed out)..how would i refer to an image which is altogether is a different structure... lets say my page is at org.xyz.util [page.html] and from within it i want to refer to an image which is in the images directory... using add(new Image(taxCientLogo, new Model(images/company-logo.jpg))); add(new Image(taxCientLogo, new Model(/images/company-logo.jpg))); makes it look inside util and appends the above path.. Eelco Hillenius wrote: but i am wondering as to how would i make it work wicket such that image gets fetched from the classpath and not relative to the application root.. So basically here is my scenario, i have jar bundled with the page components and in them i want to refer to the images (bundled within the jar only). This jar will eventually be bundled within a war application which will be using these components. Wicket reads packaged resources from the classpath, including individual jars. For instance, look at the date picker in wicket-datetime. That has a whole bunch of CSS/ JavaScript and even image dependencies that all get served from the jar. Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/packaging-images-css-in-a-jar--tf4772567.html#a13653772 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: packaging images/css in a jar?
Anyways actually i dont have a webapp directory and dont want to have that in my jar project...just want the .class files and the images (and may be css)..both residing it a different folders structure... basically below is the resulting jar structure i have and would want to keep my-custom-component - [package/classes] : org/xyz/utils (contains the page components and other classes) - [images/css] : images/myimage.jpg, css/style.css The only way to do that is to create an images package, put some dummy class in there, and use that as the reference when you these resources. Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]