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/05/07 11:35:21 UTC

Re: Breadcrumbs and "raw" URLs

> 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