Ok, I got this to work... Say I want to reference page.css relative to
the current Page I do the following:
In the markup:
<link wicket:id="pageCSS" rel="Stylesheet" type="text/css"
href="page.css"/>
In the Java file:
WebMarkupContainer pageCSS = new WebMarkupContainer("pageCSS");
add(pageCSS);
StaticResourceReference pageResource = new
StaticResourceReference(getClass(), "page.css");
pageResource.bind(getApplication());
pageCSS.add(new AttributeModifier("href", false, new
Model("Main/resources/wallpapers/page.css")));
As you can see, this is rather hackish.
I'm looking for improvement in two areas:
1) I need something like urlFor() which returns the path of the CSS
files relative to the current Page. Right now I manually hard-code the
paths which is error-prone.
2) Ideally I shouldn't have to manually add the CSS files as resources
into Wicket. We need something similar to autolinking which
automatically resolves the page-relative path as well as binding those
resources with the application.
If you don't want to add this into AutoLinking, at least make some
methods available which will do this easily. For example, I should be
able to do the above operation using two short steps:
In the markup:
<link wicket:id="pageCSS" rel="Stylesheet" type="text/css"
href="page.css"/>
In the Java file:
WebMarkupContainer pageCSS = new WebMarkupContainer("pageCSS");
add(pageCSS);
pageCSS.add(new AttributeModifier("href", false, new
Model(AutoLink.getResource("page.css").getPath()));
where AutoLink.getResource() is a static method which binds the
resource to the application and returns the ResourceReference to it
(relative to the current page). I believe getPath() will then return the
correct value; but I'm not 100% sure.
Juergen, what do you think?
Gili
Gili wrote:
I think you're making the assumption that the CSS file is found
outside the Wicket servlet. I'm making the assumption that it is found
within the Wicket servlet. That is, I want to reference the CSS file
like a Page-specific resource, not like an external file that anyone can
access. See what I mean?
Gili
Juergen Donnerstag wrote:
why is the link broken than?
WebmarkupContainer: <link wicket:id="myCss" type=".../css"
href=xxx.css"/>
No need to inject css statements. Just switch visibility on or off.
There shouldn't be a need for registering the css file. The autolink
resolver does nothing but prepending the package name.
Juergen
On 8/8/05, Gili <[EMAIL PROTECTED]> wrote:
The fully qualified class name is
"desktopbeautifier.web.main.Page"
Gili
Juergen Donnerstag wrote:
what is your page's package name? I'd assume it is web.main.page and
desktopbeautifier be your web app?
Juergen
On 8/8/05, Gili <[EMAIL PROTECTED]> wrote:
On further investigation, I don't see how autolinking works
at all for CSS.
Given:
<wicket:link autolink="true">
<link rel="Stylesheet" type="text/css" href="page.css"/>
</wicket:link>
Wicket translates this into:
<wicket:link autolink="true">
<link href="desktopbeautifier/web/main/page.css" type="text/css"
rel="Stylesheet"/>
</wicket:link>
but on further investigation
"desktopbeautifier/web/main/page.css" is a
broken link. I placed "page.css" in the same package as the page that
uses it so why doesn't it work? Is Wicket supposed to place the file
under /resources perhaps? Any help would be appreciated :)
Gili
Gili wrote:
urlFor() in my mind means "given a URL path relative to the current
component, return a URL path relative to the servlet context" and
to me
Page.urlFor() seems to fail that. I don't see the usefulness of
defining
urlFor() to return a path relative to the servlet context because (as
you mentioned) for Wicket the servlet context is the same across all
components. So I guess what I'm saying is, I'd like for us to define
urlFor() -- or another method, I don't care -- according to the
definition I gave above.
I'm having a little problem understanding what you meant in the
previous email. Did you mean the current behavior of urlFor() is
correct
or wrong?
Thanks,
Gili
what is the current page?
the context of youre page is always the same over all pages.
/webcontext/
(if you have youre wicket servlet in webcontext/app (not
webcontext/app/ )
but urls should be full if possible in my eyes.
johan
Gili wrote:
I thought urlFor() would do the job too, but instead of returning
an URL relative to the current Page, it returns an URL relative to
the application. I assume this isn't a bug (otherwise other stuff
would be broken) but it sure is confusing to me. I'd expect
Page.urlFor(String path) to return a path relative to the
current page.
Gili
Juergen Donnerstag wrote:
the reason why autolinks by design ignores all tags with
wicket:id is
because we assume the user wants to handle this tag himself. And I
think this assumption is true. Think about all the different
kind of
Links. So, exposing the functionality which handles href
attrbutes IMO
is the better way to go. Having said that, doesn't
urlFor(String) in
combination with a AttributModifier do the job?
Juergen
On 8/8/05, Gili <[EMAIL PROTECTED]> wrote:
Hi,
Autolink will not (by design) process any tags with
<wicket:id>. The
problem is that when I'm trying to set CSS into a Page I have to
manually rewrite the href attribute so it is relative to the
page. If
you take a look at the autolink implementation you can see this
isn't a
trivial process. It certainly isn't as simple as invoking
urlFor(oldHref)...
Would it be possible to modify autolinking so it processes
tags with
<wicket:id> as well? Or is there a way to expose the autolink
functionality in the form of a method I could invoke --
similar to
urlFor() -- which will fix the resource paths?
Thanks,
Gili
--
http://www.desktopbeautifier.com/
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference &
EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle
Practices
Agile & Plan-Driven Development * Managing Projects & Teams *
Testing & QA
Security * Process Improvement & Measurement *
http://www.sqe.com/bsce5sf
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle
Practices
Agile & Plan-Driven Development * Managing Projects & Teams *
Testing & QA
Security * Process Improvement & Measurement *
http://www.sqe.com/bsce5sf
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle
Practices
Agile & Plan-Driven Development * Managing Projects & Teams *
Testing
& QA
Security * Process Improvement & Measurement *
http://www.sqe.com/bsce5sf
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop
--
http://www.desktopbeautifier.com/
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle
Practices
Agile & Plan-Driven Development * Managing Projects & Teams *
Testing & QA
Security * Process Improvement & Measurement *
http://www.sqe.com/bsce5sf
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle
Practices
Agile & Plan-Driven Development * Managing Projects & Teams *
Testing & QA
Security * Process Improvement & Measurement *
http://www.sqe.com/bsce5sf
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop
--
http://www.desktopbeautifier.com/
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle
Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing
& QA
Security * Process Improvement & Measurement *
http://www.sqe.com/bsce5sf
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle
Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing
& QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop
--
http://www.desktopbeautifier.com/
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop