As you don't have to pre-register packaged resources anymore, you can
reference them if you know the URL, which for such resources always
has the same form:

/webapp/servletname/resources/some.package.SomeClass/theme.css

and even

/webapp/servletname/resources/some.package.SomeClass/some/sub/dir/theme.css

for *unmounted* packages. SomeClass is then used as the class relative
to the loading.

Also, you can use RequestCycle's urlFor and classes of
wicket.extensions.util.resource to do the trick without depending on
Wicket's internals too much. For instance with:

Map m = new HashMap();
RequestCycle r = RequestCycle.get();
m.put("star1", r.urlFor(new PackageResourceReference(StarPanel.class,
"star1.gif")));
add(TextTemplateHeaderContributor.forCss(SomeClass.class, "theme.css",
Model.valueOf(m)));

and in theme.css all ${star1} will be replaced by that image.

Still a lot of work though, so like Igor said, it would be nice to
have something simpler even. One of the starting points for this might
be TextTemplateHeaderContributor.forCss or CssTemplate it depends on.
CssTemplate could (optionally) parse the body of that file - it's
doing that for the var subst anyway - and replace urls and such.

Contribution is welcome :)

Btw, I'm about to move that package to core for 2.0 (so it looses the
extensions part in the package for that version).

Eelco


On 7/24/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> i guess it is not something that we support right now, but something that is
> cleary needed. we need to build a resource that can load a css file, parse
> for images, replace them, and then serve the altered content.
>
> i know almaw has been working on something like this but i dont know how far
> he got. a patch would be welcome, if not then i guess you will have to wait
> until one of the core devels has the time.
>
> even a patch to parse css and figure out where the paths are would be very
> helpful.
>
> -Igor
>
>
>
> On 7/23/06, Ryan Sonnek < [EMAIL PROTECTED]> wrote:
> >
>
> I know this is a pretty newbie question, but how can i package an image with
> my wicket app, and reference it within a static css file?  I've been
> searching through the wicket wiki, with no luck.  is there a wicket-stuff
> app or someplace i can dig through for an example?
>
>  Just to be clear, here's what i'm expecting to do with my css:
>
>  .myapplicationClass {
>    background-image:
> url('/com/codecrate/app/BackgroundImage.gif');
>  }
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
>  opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
> _______________________________________________
> Wicket-user mailing list
>  Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
>

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to