Hi,

It is very easy to achieve this. E.g.

public class MyPanel extends Panel {

    private static final long serialVersionUID = 1L;

    public static ResourceReference JS = new
ResourceReference(MyPanel.class, "mypanel.js");
    public static ResourceReference CSS = new
ResourceReference(MyPanel.class, "main.css");

    public MyPanel(String id) {
        super(id);
        add(CSSPackageResource.getHeaderContribution(CSS));
        add(JavascriptPackageResource.getHeaderContribution(JS));
    }
}

assuming place mypanel.js and main.css on same package as MyPanel Wicket
will serve then from the classpath. This will work also for images and so
on.

By the way at CSS level you could use

div.myclass {
    background-image : url("picture.gif");
}

if picture.gif is on the same package as main.css: no need for the long
resource reference. IMHO this is one of the many nice features Wicket
provides as all you need to roll out reusable components is a jar file.
Additionally, if you use AJAX Wicket will dynamically add the CSS and JS
references to the page when the new component is loaded (if the page did not
contained those references already).

Best,

Ernesto

P.S. Other frameworks have added similar features e.g. Struts2 allows to
serve resources from withing jar files. This make easier to create and
distribute plugins.


On Thu, Feb 4, 2010 at 2:56 AM, Ashika Umanga Umagiliya <
auma...@biggjapan.com> wrote:

> Greetings,
>
> While playing around with wicket-stuffminis , I noticed that the Moontip
> load its CSS,JavaScript from the class path (wicketstuff-minis.jar)
> eg:
> http://localhost:8080/minis-examples/resources/org.wicketstuff.minis.mootipbehavior.MootipBehaviour/mootools.v1.11.js
> -which I couldnt find in the 'webapp' folder ,but in
> 'minis-1.4.2-SNAPSHOT-javadoc.jar' file.
>
> I was wondering,can I bundle my CSS,Js into JARs like this,without copying
> into  'webapp' folder?
> How does wicket process this ? Is it the path 'resources/' ?
>
> Thanks
> umanga
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to