You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Michael Mehrle <mi...@ask.com> on 2008/06/10 20:40:07 UTC

Anchors in Wicket?

How do create a link that jumps to some anchor in a page? Is there a way
to define this in Wicket or do I have to do this manually somehow?

 

Michael


RE: Anchors in Wicket?

Posted by Michael Mehrle <mi...@ask.com>.
Hey, thanks a lot Thijs! I'll give this a shot.

-----Original Message-----
From: Thijs [mailto:vonk.thijs@gmail.com] 
Sent: Wednesday, June 11, 2008 1:38 PM
To: users@wicket.apache.org
Subject: Re: Anchors in Wicket?


  This is a bookmarkable link (the only place I use it with) but you get 
the idea :)

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.model.IModel;

public class AnchoredBookmarkablePageLink extends BookmarkablePageLink {

  private static final long serialVersionUID = 1L;
 
  private IModel stringAnchor;
 
  public AnchoredBookmarkablePageLink(String id, Class pageClass, IModel 
anchor) {
    super(id, pageClass);
    this.stringAnchor = anchor;
  }
 
  public AnchoredBookmarkablePageLink(String id, Class pageClass, 
PageParameters params, IModel anchor) {
    super(id, pageClass, params);
    this.stringAnchor = anchor;
  }
 
  @Override
  protected CharSequence appendAnchor(ComponentTag tag, CharSequence url) {
    url = url + "#" + stringAnchor.getObject().toString();
    return url;
  }
  
}

Thijs

Michael Mehrle wrote:
> Mind sharing that? ;-)
>
> -----Original Message-----
> From: Thijs [mailto:vonk.thijs@gmail.com] 
> Sent: Tuesday, June 10, 2008 11:23 PM
> To: users@wicket.apache.org
> Subject: Re: Anchors in Wicket?
>
> The component is any wicket component in the same page or next page if 
> you know that component.
>
> What you are doing, an anchor in a different page, I've solved by 
> writing my own subclass of link where I append the '#rsvp' myself.
>
> Michael Mehrle schreef:
>> I don't get it - what is the 'component' in the setAnchor() method? If
> I
>> set an anchor in a completely different page like this:
>>
>> <a href="#rsvp" />
>>
>> What do I set as the 'component' in the link's setAnchor?
>>
>> Thanks,
>>
>> Michael
>>
>> -----Original Message-----
>> From: Thijs Vonk [mailto:vonk.thijs@gmail.com] 
>> Sent: Tuesday, June 10, 2008 12:39 PM
>> To: users@wicket.apache.org
>> Subject: Re: Anchors in Wicket?
>>
>> Michael Mehrle wrote:
>>   
>>> How do create a link that jumps to some anchor in a page? Is there a
>>>     
>> way
>>   
>>> to define this in Wicket or do I have to do this manually somehow?
>>>
>>>  
>>>
>>> Michael
>>>
>>>
>>>   
>>>     
>> yes. use link.setAnchor(Component)
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>   
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


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


RE: Anchors in Wicket?

Posted by Michael Mehrle <mi...@ask.com>.
I created an Link to another page's anchor similar to the code shown below. The anchor actually gets tagged on to the bookmarkable URL. However, for some reason the browser does not jump to my anchor.

Not sure what's going on - is there a particular way I have to create an anchor in Wicket so that the URL causes the browser to scroll further down in the page?

Thanks,

Michael

-----Original Message-----
From: Thijs [mailto:vonk.thijs@gmail.com] 
Sent: Wednesday, June 11, 2008 1:38 PM
To: users@wicket.apache.org
Subject: Re: Anchors in Wicket?


  This is a bookmarkable link (the only place I use it with) but you get 
the idea :)

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.model.IModel;

public class AnchoredBookmarkablePageLink extends BookmarkablePageLink {

  private static final long serialVersionUID = 1L;
 
  private IModel stringAnchor;
 
  public AnchoredBookmarkablePageLink(String id, Class pageClass, IModel 
anchor) {
    super(id, pageClass);
    this.stringAnchor = anchor;
  }
 
  public AnchoredBookmarkablePageLink(String id, Class pageClass, 
PageParameters params, IModel anchor) {
    super(id, pageClass, params);
    this.stringAnchor = anchor;
  }
 
  @Override
  protected CharSequence appendAnchor(ComponentTag tag, CharSequence url) {
    url = url + "#" + stringAnchor.getObject().toString();
    return url;
  }
  
}

Thijs

Michael Mehrle wrote:
> Mind sharing that? ;-)
>
> -----Original Message-----
> From: Thijs [mailto:vonk.thijs@gmail.com] 
> Sent: Tuesday, June 10, 2008 11:23 PM
> To: users@wicket.apache.org
> Subject: Re: Anchors in Wicket?
>
> The component is any wicket component in the same page or next page if 
> you know that component.
>
> What you are doing, an anchor in a different page, I've solved by 
> writing my own subclass of link where I append the '#rsvp' myself.
>
> Michael Mehrle schreef:
>> I don't get it - what is the 'component' in the setAnchor() method? If
> I
>> set an anchor in a completely different page like this:
>>
>> <a href="#rsvp" />
>>
>> What do I set as the 'component' in the link's setAnchor?
>>
>> Thanks,
>>
>> Michael
>>
>> -----Original Message-----
>> From: Thijs Vonk [mailto:vonk.thijs@gmail.com] 
>> Sent: Tuesday, June 10, 2008 12:39 PM
>> To: users@wicket.apache.org
>> Subject: Re: Anchors in Wicket?
>>
>> Michael Mehrle wrote:
>>   
>>> How do create a link that jumps to some anchor in a page? Is there a
>>>     
>> way
>>   
>>> to define this in Wicket or do I have to do this manually somehow?
>>>
>>>  
>>>
>>> Michael
>>>
>>>
>>>   
>>>     
>> yes. use link.setAnchor(Component)
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>   
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


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


Re: Anchors in Wicket?

Posted by Thijs <vo...@gmail.com>.
  This is a bookmarkable link (the only place I use it with) but you get 
the idea :)

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.model.IModel;

public class AnchoredBookmarkablePageLink extends BookmarkablePageLink {

  private static final long serialVersionUID = 1L;
 
  private IModel stringAnchor;
 
  public AnchoredBookmarkablePageLink(String id, Class pageClass, IModel 
anchor) {
    super(id, pageClass);
    this.stringAnchor = anchor;
  }
 
  public AnchoredBookmarkablePageLink(String id, Class pageClass, 
PageParameters params, IModel anchor) {
    super(id, pageClass, params);
    this.stringAnchor = anchor;
  }
 
  @Override
  protected CharSequence appendAnchor(ComponentTag tag, CharSequence url) {
    url = url + "#" + stringAnchor.getObject().toString();
    return url;
  }
  
}

Thijs

Michael Mehrle wrote:
> Mind sharing that? ;-)
>
> -----Original Message-----
> From: Thijs [mailto:vonk.thijs@gmail.com] 
> Sent: Tuesday, June 10, 2008 11:23 PM
> To: users@wicket.apache.org
> Subject: Re: Anchors in Wicket?
>
> The component is any wicket component in the same page or next page if 
> you know that component.
>
> What you are doing, an anchor in a different page, I've solved by 
> writing my own subclass of link where I append the '#rsvp' myself.
>
> Michael Mehrle schreef:
>> I don't get it - what is the 'component' in the setAnchor() method? If
> I
>> set an anchor in a completely different page like this:
>>
>> <a href="#rsvp" />
>>
>> What do I set as the 'component' in the link's setAnchor?
>>
>> Thanks,
>>
>> Michael
>>
>> -----Original Message-----
>> From: Thijs Vonk [mailto:vonk.thijs@gmail.com] 
>> Sent: Tuesday, June 10, 2008 12:39 PM
>> To: users@wicket.apache.org
>> Subject: Re: Anchors in Wicket?
>>
>> Michael Mehrle wrote:
>>   
>>> How do create a link that jumps to some anchor in a page? Is there a
>>>     
>> way
>>   
>>> to define this in Wicket or do I have to do this manually somehow?
>>>
>>>  
>>>
>>> Michael
>>>
>>>
>>>   
>>>     
>> yes. use link.setAnchor(Component)
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>   
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


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


RE: Anchors in Wicket?

Posted by Michael Mehrle <mi...@ask.com>.
Mind sharing that? ;-)

-----Original Message-----
From: Thijs [mailto:vonk.thijs@gmail.com] 
Sent: Tuesday, June 10, 2008 11:23 PM
To: users@wicket.apache.org
Subject: Re: Anchors in Wicket?

The component is any wicket component in the same page or next page if 
you know that component.

What you are doing, an anchor in a different page, I've solved by 
writing my own subclass of link where I append the '#rsvp' myself.

Michael Mehrle schreef:
> I don't get it - what is the 'component' in the setAnchor() method? If
I
> set an anchor in a completely different page like this:
>
> <a href="#rsvp" />
>
> What do I set as the 'component' in the link's setAnchor?
>
> Thanks,
>
> Michael
>
> -----Original Message-----
> From: Thijs Vonk [mailto:vonk.thijs@gmail.com] 
> Sent: Tuesday, June 10, 2008 12:39 PM
> To: users@wicket.apache.org
> Subject: Re: Anchors in Wicket?
>
> Michael Mehrle wrote:
>   
>> How do create a link that jumps to some anchor in a page? Is there a
>>     
> way
>   
>> to define this in Wicket or do I have to do this manually somehow?
>>
>>  
>>
>> Michael
>>
>>
>>   
>>     
> yes. use link.setAnchor(Component)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>   


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


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


Re: Anchors in Wicket?

Posted by Thijs <vo...@gmail.com>.
The component is any wicket component in the same page or next page if 
you know that component.

What you are doing, an anchor in a different page, I've solved by 
writing my own subclass of link where I append the '#rsvp' myself.

Michael Mehrle schreef:
> I don't get it - what is the 'component' in the setAnchor() method? If I
> set an anchor in a completely different page like this:
>
> <a href="#rsvp" />
>
> What do I set as the 'component' in the link's setAnchor?
>
> Thanks,
>
> Michael
>
> -----Original Message-----
> From: Thijs Vonk [mailto:vonk.thijs@gmail.com] 
> Sent: Tuesday, June 10, 2008 12:39 PM
> To: users@wicket.apache.org
> Subject: Re: Anchors in Wicket?
>
> Michael Mehrle wrote:
>   
>> How do create a link that jumps to some anchor in a page? Is there a
>>     
> way
>   
>> to define this in Wicket or do I have to do this manually somehow?
>>
>>  
>>
>> Michael
>>
>>
>>   
>>     
> yes. use link.setAnchor(Component)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>   


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


RE: Anchors in Wicket?

Posted by Michael Mehrle <mi...@ask.com>.
I don't get it - what is the 'component' in the setAnchor() method? If I
set an anchor in a completely different page like this:

<a href="#rsvp" />

What do I set as the 'component' in the link's setAnchor?

Thanks,

Michael

-----Original Message-----
From: Thijs Vonk [mailto:vonk.thijs@gmail.com] 
Sent: Tuesday, June 10, 2008 12:39 PM
To: users@wicket.apache.org
Subject: Re: Anchors in Wicket?

Michael Mehrle wrote:
> How do create a link that jumps to some anchor in a page? Is there a
way
> to define this in Wicket or do I have to do this manually somehow?
>
>  
>
> Michael
>
>
>   
yes. use link.setAnchor(Component)

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


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


Re: Anchors in Wicket?

Posted by Thijs Vonk <vo...@gmail.com>.
Michael Mehrle wrote:
> How do create a link that jumps to some anchor in a page? Is there a way
> to define this in Wicket or do I have to do this manually somehow?
>
>  
>
> Michael
>
>
>   
yes. use link.setAnchor(Component)

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