On Wed, Mar 26, 2008 at 3:28 PM, Matthew Young <[EMAIL PROTECTED]> wrote:
> >link has overridable String getAnchor()
>
>  It's actually 'Component getAnchor()' and I don't understand where to get
>  this anchor component.  There is little javadoc in getAnchor() but
>  setAnchor(Component c) has more details but I don't understand it at all.
>
>  My page is like this:
>
>  === top of page ===
>  ...
>  <a href="#setup">Go To Setup</a>
>  ... very long stuffs follow
>  .
>  .
>  .
>  bottom of page
>  <a name="setup">Setup Form</a>
>  <form>....
>     ....
>     <a wicket:id="resetKey">Give me another key</a>
>     ....
>  </form>
>  I want response to onClick of "resetKey", jump back to #setup.  I don't
>  understand how to use Link#getAnchor(), Link#setAnchor(Component c) do
>  this.  Please help.

if you put a wicket:id on the [a name="setup"] and make it a
webmarkupcontainer you can return from link.getanchor()

anyways, im just looking at the source the same as you and i see a
couple of other ways to do it. eg you can override geturl() and append
the anchor there yourself. i recommend attaching wicket sources to
your ide.

>  >>  1) on fail form validation, response jump to the form?
>  >
>  >this is a bit tricky. perhaps you can subclass the feedbackpanel and
>  >if there are messages have it spit out some javascript to scroll the
>  >page.
>
>  Javascript is fine.  But I am not using FeedbackPanel. I am pulling the
>  error message out from FormComponents and show them along side it.  Can I
>  just query the session to see if it has any error?

yes

> If so, where and how to
>  insert his code and do the "spit out some javascript"? And what is the
>  javascript? "location.hash='setup'"?

i dont know what the exact javascript is, but you can output it in
renderhead(iheaderresponse r) { if (!form.isvalid()) {
r.renderonloadjavascript("gotohash");}}

-igor


>
>
>  On Wed, Mar 26, 2008 at 11:26 AM, Igor Vaynberg <[EMAIL PROTECTED]>
>  wrote:
>
>
>
>  > On Wed, Mar 26, 2008 at 11:13 AM, Matthew Young <[EMAIL PROTECTED]> wrote:
>  > > My form is at the bottom of a long page.  I have <a name="myform"/>
>  > before
>  > >  the form.  Is there a way to:
>  > >
>  > >  1) on fail form validation, response jump to the form?
>  >
>  > this is a bit tricky. perhaps you can subclass the feedbackpanel and
>  > if there are messages have it spit out some javascript to scroll the
>  > page.
>  >
>  > if you dont want javascript then you will need an extra redirect in
>  > which case you will need to do:
>  >
>  > string url=urlfor(mypage.this); url+="#anchor";
>  > requestcycle().setrequesttarget(new redirectrequesttarget(url));
>  >
>  > but you may or may not lose some feedback messages, not sure.
>  >
>  > >  2) Same for [EMAIL PROTECTED](): response jump to the form?
>  >
>  > link has overridable String getAnchor()
>  >
>  > -igor
>  >
>  > >
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: [EMAIL PROTECTED]
>  > For additional commands, e-mail: [EMAIL PROTECTED]
>  >
>  >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to