You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Wilhelmsen Tor Iver <To...@arrive.no> on 2009/04/20 14:37:46 UTC

Breadcrumbs and "raw" URLs

We have an issue where we are using a CMS that provides an API for
getting article components in a peculiar way: Links are sent over as a
raw HTML "element" followed by a "link element" followed by the rest of
the HTML. So a link like <a href="http://foo/fie"> is sent as 
1. HTML: <a href="
2. Link: EXTERNAL, http://foo/fie
3. HTML: ">

Now, some of these links are article ids that we want to turn into
wicket-extensions breadcrumb links in a BreadCrumbBar. Using the
BreadCrumbLink does not work since we don't actually have a HTML
template element to apply the Link to. 

Is there a way to use urlFor() or the like to create links that updates
the breadcrumb model with our BreadCrumbPanel subclass for the linked
id, i.e. IBreadCrumbModel.setActive(new ArticlePanel(...))?

Med vennlig hilsen

TOR IVER WILHELMSEN
Senior systemutvikler
Arrive AS
T (+47) 48 16 06 18
E-post: toriverw@arrive.no
http://www.arrive.no
http://servicedesk.arrive.no



Re: Breadcrumbs and "raw" URLs

Posted by Wilhelmsen Tor Iver <To...@arrive.no>.
> Is there a way to use urlFor() or the like to create links 
> that updates the breadcrumb model with our BreadCrumbPanel 
> subclass for the linked id, i.e. 
> IBreadCrumbModel.setActive(new ArticlePanel(...))?

*crickets*

Anyway, I finally found the likely answer in the form of an extended
PageRequestTarget.

However, it seems the call to urlFor() returns a link that does not
invoke the code as expected; it just re-renders the same page and panel
instead of invoking my object. Am I doing something wrong regarding the
urlFor call? Does the request target object need to be registered
somewhere?

	// ...

		CharSequence urlFor = RequestCycle.get().urlFor(new
ChangeArticleRequestTarget(getPage(), token.getLinkData()));


	public static class ChangeArticleRequestTarget extends
PageRequestTarget {

		private String articleId;
		
		public ChangeArticleRequestTarget(Page page, String
articleId) {
			super(page);
			this.articleId = articleId;
		}

		@Override
		public void respond(RequestCycle requestCycle) {
			Page page = getPage();
			BreadCrumbBar bar = (BreadCrumbBar)
page.get("breadCrumbBar");
			try {
				ArticlePanel newPanel = new
ArticlePanel("articlePanel", bar, new
Model<Integer>(Integer.valueOf(articleId)));
				page.replace(newPanel);
				bar.setActive(newPanel);
				page.dirty();
			}
			catch (NumberFormatException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			super.respond(requestCycle);
		}
		
		
		
	}

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org