I don't think you can do it quite in the manner that you're attempting,
but you can achieve this behavior by doing the following:

- in your action class, populate a request attribute when this page
refresh occurs 
- forward back to your jsp as normal
- in your jsp, check for the existence of this request attribute.
- if it exists, call a javascript function that sets the
window.location.hash value to your anchor name.

HTH,
- Scott

-----Original Message-----
From: Brian Bezanson [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 11, 2005 4:42 PM
To: user@struts.apache.org
Subject: Struts ActionForward to HTML <A NAME="xxx"> anchor

I'd like to know if it is possible to get a ActionForward to scroll my
target page to an anchor on the page created with the <a
name="xxx"></a>.

Problem Description
------------------------------
I have a page in struts (rather large form) where I have a drop-down
menu near the bottom with some choices. (AKA html:select and
html:optionsCollection)

When a user selects from that menu, I have a javascript.submit() that
occurs where my page action retrieves data based on the menu change and
populates another text block on the page below the pop-up. On the page
being 'refreshed' it has set the scroll position to the top of the page
-- which is the normal behavior.

I'd like to return to a named anchor on the page by the drop-down menu.
My Action.java code returns a "return
(mapping.findForward("myMessage"));"

In my struts-config.xml I also have the following: "<forward
name="myMessage" path="/Main/SomePage.jsp#name_reference"/>"

In the JSP page (SomePage.jsp) I have:

<html:link linkName="name_reference"></html:link>

But of course when I try and execute things, I get a 404 error::

        HTTP Status 404 - /Main/SomePage.jsp#name_reference
        
        type Status report
        
        message /Main/SomePage.jsp#name_reference
        
        description The requested resource
(/Main/SomePage.jsp#name_reference) is not available.
        Apache Tomcat/5.0.28

Removing the #name_reference from the struts-config.xml file gets things
working again -- just no scrolling to my anchor point.

Thanks in advance,

Brian

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