You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Jesse Barnum <js...@360works.com> on 2007/08/02 06:09:00 UTC
How to append an # anchor to an href?
I want a hyperlink to take me to a particular section of another
page. If I was doing static HTML, the link would be something like <a
href="aPage#sectionName">. I can't figure out how to do this with
wicket...
Here's my code:
add( new Link("up") {
public void onClick() {
setResponsePage( new List() );
}
} );
I see the setAnchor() method on Link, but that looks like it's more
for linking to a component on the same page. In this case, I want to
link to a certain spot on a page that has not been instantiated at
the time the first page is rendered. I guess what I'm really looking
for is something like aLink.setAnchorName("sectionName");
--Jesse Barnum, President, 360Works
http://www.360works.com
(770) 234-9293
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to append an # anchor to an href?
Posted by norckon <pd...@me.com>.
Hi,
I'm having the exact same problem; I want an #anchor added to the URL my
Link generates, but after clicking the Link, the user is redirected to the
mount URL (with version number, '/mypage.0.2'), loosing the anchor.
Since this topic is last replied to in 2007, are there any new solutions for
this problem? My application uses the ONE_PASS_RENDER strategy and
link.setRedirect(false) doesn't help.
Thanks,
Pepijn
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-append-an-anchor-to-an-href-tp1845378p3260138.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to append an # anchor to an href?
Posted by Eelco Hillenius <ee...@gmail.com>.
On 8/1/07, Jesse Barnum <js...@360works.com> wrote:
> That is definitely on the right track - overriding appendAnchor does
> successfully add the #myAnchor suffix to the Link URL. However, I am
> realizing that clicking on the link is doing an immediate redirect to
> another page.
>
> Here is the URL from page1, with the #ScreenCapture link successfully
> added:
>
> http://localhost:8080/ScriptMaster/sm?
> wicket:interface=wicket-1:1:up::ILinkListener#ScreenCapture
>
> Clicking on it takes me to that URL, but does an immediate redirect
> to this URL:
>
> http://localhost:8080/ScriptMaster/sm?wicket:interface=wicket-1:2::
>
> This discards the named anchor. Is this normal behavior? What can I
> do about this?
Hmmm, good point. You could try RequestCycle.get().setRedirect(false),
but if that would work it would be merely a hack. I guess you could
add a feature request for this... atm I don't have a good idea how to
get around this. Looks like we should append any anchor that came in
to the redirect again.
Eelco
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to append an # anchor to an href?
Posted by Jesse Barnum <js...@360works.com>.
That is definitely on the right track - overriding appendAnchor does
successfully add the #myAnchor suffix to the Link URL. However, I am
realizing that clicking on the link is doing an immediate redirect to
another page.
Here is the URL from page1, with the #ScreenCapture link successfully
added:
http://localhost:8080/ScriptMaster/sm?
wicket:interface=wicket-1:1:up::ILinkListener#ScreenCapture
Clicking on it takes me to that URL, but does an immediate redirect
to this URL:
http://localhost:8080/ScriptMaster/sm?wicket:interface=wicket-1:2::
This discards the named anchor. Is this normal behavior? What can I
do about this?
--Jesse Barnum, President, 360Works
http://www.360works.com
(770) 234-9293
On Aug 2, 2007, at 12:20 AM, Eelco Hillenius wrote:
>
>
> You can override Link#appendAnchor. Also, note that href="#myAnchor"
> automatically gets picked up and appended to the URL.
>
> Eelco
>
> ---------------------------------------------------------------------
> 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: How to append an # anchor to an href?
Posted by Eelco Hillenius <ee...@gmail.com>.
On 8/1/07, Jesse Barnum <js...@360works.com> wrote:
> I want a hyperlink to take me to a particular section of another
> page. If I was doing static HTML, the link would be something like <a
> href="aPage#sectionName">. I can't figure out how to do this with
> wicket...
>
> Here's my code:
>
> add( new Link("up") {
> public void onClick() {
> setResponsePage( new List() );
> }
> } );
>
> I see the setAnchor() method on Link, but that looks like it's more
> for linking to a component on the same page. In this case, I want to
> link to a certain spot on a page that has not been instantiated at
> the time the first page is rendered. I guess what I'm really looking
> for is something like aLink.setAnchorName("sectionName");
You can override Link#appendAnchor. Also, note that href="#myAnchor"
automatically gets picked up and appended to the URL.
Eelco
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org