struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Piker" <scott.pi...@xede.com>
Subject RE: Struts ActionForward to HTML <A NAME="xxx"> anchor
Date Fri, 11 Mar 2005 21:56:09 GMT
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:brian.bezanson@gmail.com] 
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message