try this:
1. create an anonymous subclass of Link (which is the intended use for Link). 2. override getURL()
3. return the path from your shared resource via SharedResource.getPath()
Gili wrote:
I chated with Juergen a few mins ago about problems I've been having with our current Link OO model and I've got to go to sleep now (it's 3:30am local time) so I wanted to summarize some of the things we discussed:
- I define a link as something a user clicks on to navigate from one page to another. Notice the definition of Page here is client-specific, not server-specific. HTML, after all, is a client-side markup. For example, a user can click on an image, PDF file, etc and navigate away from the current Page. Our current implementation only allows links to wicket.Page which is boils down to a Java file with an associated markup. This mismatches with the client interpretation of what a Page or a Link is. On on this below...
- I expect *all* links to extend wicket.markup.html.link.Link, but ExternalLink does not. This is confusing and results from the discussion of "what is a link" above. From a OO point of view: ExternalLink *is a* link and should extend it. The problem is that our current definition of wicket.markup.html.link.Link is too Page-centric which makes it impossible for ExternalLink to extend it. I am advocating making wicket.markup.html.link.Link more generic, having ExternalLink extend it and have PageLink and BookmarkablePageLink remain Page-specific.
- The problem, as I see it, is that our current definition of Link is too restrictive. Links can only point to Pages. But what are Pages? Pages must have markups. Well, in real life, not all HTML links point to entities with markups. Images don't have markups.
What I propose is the following:
1) Add ImageResource.getURL() which will return the application-relative URL to the image resource.
2) Make wicket.markup.html.link.Link more generic. A link is simply an entity that points to a URL. Assuming this class is concrete, this allows us to kill ExternalLink and developers can simply instantiate Links directly. PageLink and BookmarkablePageLink can still extend this class and translate links to Pages to links to URLs.
So linking to images would involve:
Link myLink = new Link(myImageResource.getURL())
and everyone is happy. What do you guys think?
Gili
------------------------------------------------------- This SF.net email is sponsored by Demarc: A global provider of Threat Management Solutions. Download our HomeAdmin security software for free today! http://www.demarc.com/info/Sentarus/hamr30 _______________________________________________ Wicket-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-develop
------------------------------------------------------- This SF.net email is sponsored by Demarc: A global provider of Threat Management Solutions. Download our HomeAdmin security software for free today! http://www.demarc.com/info/Sentarus/hamr30 _______________________________________________ Wicket-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-develop
