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/16 19:58:44 UTC

Browser not jumping to Wicket Anchor

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

 

 

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;

  }

  

}

 


Re: Browser not jumping to Wicket Anchor

Posted by Gwyn Evans <gw...@gmail.com>.
Google suggests with the hash - e.g.
http://www.devguru.com/technologies/ecmascript/QuickRef/location_hash.html -
although if it doesn't work I'd go back to basics with a QuickStart and
check it works with just minimal pages, then see about adding your other
page elements.

/Gwyn

On Wed, Jun 18, 2008 at 2:22 AM, Michael Mehrle <mi...@ask.com>
wrote:

> Oh, and for the anchor string - do I include the hash as well? I added
> the call below without the hash and it's not jumping to that anchor.
> Frustrating...
>
> Michael
>
> -----Original Message-----
> From: Michael Mehrle [mailto:michael.mehrle@ask.com]
> Sent: Tuesday, June 17, 2008 6:19 PM
> To: users@wicket.apache.org
> Subject: RE: Browser not jumping to Wicket Anchor
>
> Just curious - what does 'location.hash' stand for? In any case, is this
> supposed to cause the page to jump to the anchor?
>
> Michael
>
> -----Original Message-----
> From: Gwyn Evans [mailto:gwyn.evans@gmail.com]
> Sent: Monday, June 16, 2008 2:51 PM
> To: users@wicket.apache.org
> Subject: Re: Browser not jumping to Wicket Anchor
>
> Not an issue I've come across but also not an area I've explored... A
> quick
> search through the mailing list did suggest one possible approach as
> below,
> but I've no idea how viable it might be!
>
> public Page extends WebPage implements IHeadContributor {
>    ........
>    @Override
>    public void renderHead(IHeaderResponse r) {
>           r.renderOnLoadJavascript("location.hash='YOUR-ANCHOR'");
>    }
> }
>
> /Gwyn
>
> On Mon, Jun 16, 2008 at 10:33 PM, Michael Mehrle
> <mi...@ask.com>
> wrote:
>
> > Yes - they do match - you're right, always check the basics first. The
> > problem is that even if I bookmark the anchored page (with the anchor
> > tagged on), and load the page it won't jump there. So, I don't think
> > it's the way I create the anchor (because the URL looks correct) -
> it's
> > all the other wicket AJAX stuff that somehow prevents the anchor from
> > being recognized on page load. Is there a work around for this?
> >
> > Thanks,
> >
> > Michael
> >
> > -----Original Message-----
> > From: Gwyn Evans [mailto:gwyn.evans@gmail.com]
> > Sent: Monday, June 16, 2008 1:02 PM
> > To: users@wicket.apache.org
> > Subject: Re: Browser not jumping to Wicket Anchor
> >
> > Just looking at the HTML, do the anchor & the destination match
> > correctly?
> > Is the destination url just a normal page, or a form of some sort?
> >
> > /Gwyn
> >
> > On Mon, Jun 16, 2008 at 6:58 PM, Michael Mehrle
> <mi...@ask.com>
> > wrote:
> >
> > > 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
> > >
> > >
> > >
> > >
> > >
> > > 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;
> > >
> > >  }
> > >
> > >
> > >
> > > }
> > >
> > >
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > 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: Browser not jumping to Wicket Anchor

Posted by Michael Mehrle <mi...@ask.com>.
Oh, and for the anchor string - do I include the hash as well? I added
the call below without the hash and it's not jumping to that anchor.
Frustrating...

Michael

-----Original Message-----
From: Michael Mehrle [mailto:michael.mehrle@ask.com] 
Sent: Tuesday, June 17, 2008 6:19 PM
To: users@wicket.apache.org
Subject: RE: Browser not jumping to Wicket Anchor

Just curious - what does 'location.hash' stand for? In any case, is this
supposed to cause the page to jump to the anchor?

Michael

-----Original Message-----
From: Gwyn Evans [mailto:gwyn.evans@gmail.com] 
Sent: Monday, June 16, 2008 2:51 PM
To: users@wicket.apache.org
Subject: Re: Browser not jumping to Wicket Anchor

Not an issue I've come across but also not an area I've explored... A
quick
search through the mailing list did suggest one possible approach as
below,
but I've no idea how viable it might be!

public Page extends WebPage implements IHeadContributor {
    ........
    @Override
    public void renderHead(IHeaderResponse r) {
           r.renderOnLoadJavascript("location.hash='YOUR-ANCHOR'");
    }
}

/Gwyn

On Mon, Jun 16, 2008 at 10:33 PM, Michael Mehrle
<mi...@ask.com>
wrote:

> Yes - they do match - you're right, always check the basics first. The
> problem is that even if I bookmark the anchored page (with the anchor
> tagged on), and load the page it won't jump there. So, I don't think
> it's the way I create the anchor (because the URL looks correct) -
it's
> all the other wicket AJAX stuff that somehow prevents the anchor from
> being recognized on page load. Is there a work around for this?
>
> Thanks,
>
> Michael
>
> -----Original Message-----
> From: Gwyn Evans [mailto:gwyn.evans@gmail.com]
> Sent: Monday, June 16, 2008 1:02 PM
> To: users@wicket.apache.org
> Subject: Re: Browser not jumping to Wicket Anchor
>
> Just looking at the HTML, do the anchor & the destination match
> correctly?
> Is the destination url just a normal page, or a form of some sort?
>
> /Gwyn
>
> On Mon, Jun 16, 2008 at 6:58 PM, Michael Mehrle
<mi...@ask.com>
> wrote:
>
> > 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
> >
> >
> >
> >
> >
> > 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;
> >
> >  }
> >
> >
> >
> > }
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> 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: Browser not jumping to Wicket Anchor

Posted by Michael Mehrle <mi...@ask.com>.
Just curious - what does 'location.hash' stand for? In any case, is this
supposed to cause the page to jump to the anchor?

Michael

-----Original Message-----
From: Gwyn Evans [mailto:gwyn.evans@gmail.com] 
Sent: Monday, June 16, 2008 2:51 PM
To: users@wicket.apache.org
Subject: Re: Browser not jumping to Wicket Anchor

Not an issue I've come across but also not an area I've explored... A
quick
search through the mailing list did suggest one possible approach as
below,
but I've no idea how viable it might be!

public Page extends WebPage implements IHeadContributor {
    ........
    @Override
    public void renderHead(IHeaderResponse r) {
           r.renderOnLoadJavascript("location.hash='YOUR-ANCHOR'");
    }
}

/Gwyn

On Mon, Jun 16, 2008 at 10:33 PM, Michael Mehrle
<mi...@ask.com>
wrote:

> Yes - they do match - you're right, always check the basics first. The
> problem is that even if I bookmark the anchored page (with the anchor
> tagged on), and load the page it won't jump there. So, I don't think
> it's the way I create the anchor (because the URL looks correct) -
it's
> all the other wicket AJAX stuff that somehow prevents the anchor from
> being recognized on page load. Is there a work around for this?
>
> Thanks,
>
> Michael
>
> -----Original Message-----
> From: Gwyn Evans [mailto:gwyn.evans@gmail.com]
> Sent: Monday, June 16, 2008 1:02 PM
> To: users@wicket.apache.org
> Subject: Re: Browser not jumping to Wicket Anchor
>
> Just looking at the HTML, do the anchor & the destination match
> correctly?
> Is the destination url just a normal page, or a form of some sort?
>
> /Gwyn
>
> On Mon, Jun 16, 2008 at 6:58 PM, Michael Mehrle
<mi...@ask.com>
> wrote:
>
> > 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
> >
> >
> >
> >
> >
> > 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;
> >
> >  }
> >
> >
> >
> > }
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> 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: Browser not jumping to Wicket Anchor

Posted by Gwyn Evans <gw...@gmail.com>.
Not an issue I've come across but also not an area I've explored... A quick
search through the mailing list did suggest one possible approach as below,
but I've no idea how viable it might be!

public Page extends WebPage implements IHeadContributor {
    ........
    @Override
    public void renderHead(IHeaderResponse r) {
           r.renderOnLoadJavascript("location.hash='YOUR-ANCHOR'");
    }
}

/Gwyn

On Mon, Jun 16, 2008 at 10:33 PM, Michael Mehrle <mi...@ask.com>
wrote:

> Yes - they do match - you're right, always check the basics first. The
> problem is that even if I bookmark the anchored page (with the anchor
> tagged on), and load the page it won't jump there. So, I don't think
> it's the way I create the anchor (because the URL looks correct) - it's
> all the other wicket AJAX stuff that somehow prevents the anchor from
> being recognized on page load. Is there a work around for this?
>
> Thanks,
>
> Michael
>
> -----Original Message-----
> From: Gwyn Evans [mailto:gwyn.evans@gmail.com]
> Sent: Monday, June 16, 2008 1:02 PM
> To: users@wicket.apache.org
> Subject: Re: Browser not jumping to Wicket Anchor
>
> Just looking at the HTML, do the anchor & the destination match
> correctly?
> Is the destination url just a normal page, or a form of some sort?
>
> /Gwyn
>
> On Mon, Jun 16, 2008 at 6:58 PM, Michael Mehrle <mi...@ask.com>
> wrote:
>
> > 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
> >
> >
> >
> >
> >
> > 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;
> >
> >  }
> >
> >
> >
> > }
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: Browser not jumping to Wicket Anchor

Posted by Michael Mehrle <mi...@ask.com>.
Yes - they do match - you're right, always check the basics first. The
problem is that even if I bookmark the anchored page (with the anchor
tagged on), and load the page it won't jump there. So, I don't think
it's the way I create the anchor (because the URL looks correct) - it's
all the other wicket AJAX stuff that somehow prevents the anchor from
being recognized on page load. Is there a work around for this?

Thanks,

Michael

-----Original Message-----
From: Gwyn Evans [mailto:gwyn.evans@gmail.com] 
Sent: Monday, June 16, 2008 1:02 PM
To: users@wicket.apache.org
Subject: Re: Browser not jumping to Wicket Anchor

Just looking at the HTML, do the anchor & the destination match
correctly?
Is the destination url just a normal page, or a form of some sort?

/Gwyn

On Mon, Jun 16, 2008 at 6:58 PM, Michael Mehrle <mi...@ask.com>
wrote:

> 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
>
>
>
>
>
> 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;
>
>  }
>
>
>
> }
>
>
>
>

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


Re: Browser not jumping to Wicket Anchor

Posted by Gwyn Evans <gw...@gmail.com>.
Just looking at the HTML, do the anchor & the destination match correctly?
Is the destination url just a normal page, or a form of some sort?

/Gwyn

On Mon, Jun 16, 2008 at 6:58 PM, Michael Mehrle <mi...@ask.com>
wrote:

> 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
>
>
>
>
>
> 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;
>
>  }
>
>
>
> }
>
>
>
>