How about using DOM and Javascript? Set something in your page (href, input
tag, etc.) with the id="" attribute, then have Javascript use
document.getElementById("someId").focus() to jump down to that part of the
page.  I tested this in Struts v1.2.4 under Tomcat 5.0.2? where it worked on
HREFs. The JSP was served by my "/hey" action mapping.  I tested it with
both /hey.do and /do/hey servlet mappings.

You could probably do this in tiles using a slightly modified tiles
template.  Your example was:

<definition name="myAnchor" extends="layout">
  <put name="title" value="Struts-Tiles anchor" />
  <put name="body" value="/itemEdit.jsp#myAnchor" />
</definition>

I recommend splitting up the body and anchor components to:

<definition name="myAnchor" extends="layout">
  <put name="title" value="Struts-Tiles anchor" />
  <put name="body" value="/itemEdit.jsp" />
  <put name="anchor" value="myAnchor" />
</definition>

Then, in your /itemEdit.jsp, you could probably do something like this:
<script language="JavaScript">
document.getElementById("<tiles:put name="anchor" />").focus();
</script>

I tested it on a dummy page, that was so long it required scrolling to get
to my link, with a visible href like so:

<a href="" id="downHere">Jump here!</a>

AND also with a non-showing href:

<a href="" id="downHere"></a>

And with the good old input tag. All three jumped the page up/down as
expected.

Regards,
David

-----Original Message-----
From: Daniel Perry [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 10, 2004 7:40 AM
To: Struts Users Mailing List
Subject: RE: [Tiles] Forwarding to an specific anchor link of a Tile


This is not a good idea...

As far as i'm aware anchors are not part of the http specification.  They
are only implemented in html.

Eg. You type /myAnchor.do#myAnchor into the url bar in your browser, the
browser actually requests /myAnchor.do - it doesnt send the anchor - it just
uses it to show the correct part of the page.

Now, if a browser sends a request for /myAnchor.do and recieves a redirect
to /myAnchor.do#myAnchor the browser will then make a further request - but
what should it request?

/myAnchor.do#myAnchor is an invalid url

If its clever it will spot this and either send:
/myAnchor.do (and handle the anchor)

or if it's not:
/myAnchor.do#myAnchor (and cause errors)
/myAnchor.do%23myAnchor (and cause errors)

I've come accross this problem in my own apps.  In testing Firefox and MOST
versions of IE can deal with it... but some versions of IE cause errors.

The only solution i came up with is to use forwards (not redirects) and use
javascript so that when a form is submitted, or a link is cliked it decides
which anchor to select before anything is submitted.

Daniel.



> -----Original Message-----
> From: David G. Friedman [mailto:[EMAIL PROTECTED]
> Sent: 10 November 2004 04:50
> To: Struts Users Mailing List
> Subject: RE: [Tiles] Forwarding to an specific anchor link of a Tile
>
>
> Daniel,
>
> An anchor is HTML, not Java/Struts so why don't you have your
> redirect go to
> /myAnchor.do#myAnchor ?
>
> Regards,
> David
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Sent: Friday, November 05, 2004 6:43 AM
> To: [EMAIL PROTECTED]
> Subject: [Tiles] Forwarding to an specific anchor link of a Tile
>
>
>
> Hi everybody,
>
> i need to forward from an Action to an specifig anchor link of a Tile.
>
> Something like:
>
> [example definition of Tiles configuration file]
> <definition name="myAnchor" extends="layout">
>     <put name="title" value="Struts-Tiles anchor" />
>     <put name="body" value="/itemEdit.jsp#myAnchor" />
> </definition>
>
> but as expected, Tiles engine can't locate the file.
>
> is it possible to forward from an Action to an specific anchor link of a
> Tile?
>
> Thanks in advance,
> Daniel
>
> ---------------------------------------------------------------------
> 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]
>
>


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