You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Apache Wiki <wi...@apache.org> on 2005/08/01 16:34:02 UTC

[Struts Wiki] Update of "StrutsSolutions" by FrankZammetti

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Struts Wiki" for change notification.

The following page has been changed by FrankZammetti:
http://wiki.apache.org/struts/StrutsSolutions

------------------------------------------------------------------------------
  
  7. A plug & play solution to adding a "please wait" page to any Struts action: [StrutsPleaseWait]
  
+ 8. How do I include an anchor name when forwarding from an Action? (i.e., how can I make the page returned to the browser jump to a specific section out of an Action?)
+ 
  == DISCUSSION OF PROBLEMS (What Is The Problem?) ==
  
  4. In an application I was architect and lead developer for last year, I was asked to expose certain pieces of functionality of the system as Web Services.  This request was made AFTER the application was complete and deployed in production.  I did not want to spend a lot of time on this (in fact, COULDN'T) and wanted to change as little code as possible, ideally none.
  
  5. I've seen this question asked numerous times on the Struts User's mailing list, so I thought an entry somewhere on the Wiki might be a good idea.  The question is usually asked something like "How can I open a new window from an Action?"  It's a little vague, but it's along the lines of how can you submit a form and have the response appear in a new window.  Usually it's asked within the context of doing it variably, that is, sometimes returning in a new window, sometimes not.
+ 
+ 8. If you name an anchor in your page (<a name="something">) and you want the browser to jump to that specific anchor when it is rendered, you would generally do something like <a href="mypage.htm#something"> if you were doing it from a link.  Or, from a servlet, you might attach #something to the end of the page name when using a dispatcher to forward.  If you try to append #something to the end of a forward name from an Action though (return mapping.findForward("myForward#something");) you will find that Struts throws an exception about not being able to find the forward.  That is because it is looking for a forward that is literally "myForward#something" and won't find it.
  
  == DISCUSSION OF SOLUTIONS (What Is The Solution?) ==
  
@@ -150, +154 @@

  
  The bottom-line here is this: There is no way to direct the browser to open the response in a new window from an Action.  You either have to indicate you want this behavior when the form is submitted, or make it happen with scripting once the response is back at the browser.  At least, this is true within the confines of plain old HTML... You could always pull an applet out and do something like this!
  
+ 8. In theory at least (can someone verify this, I'm being lazy!) you could actually name your forward "myForward#something", and it should work.  However, this ties your page design a little too much to your Struts config, and that's probably not a good idea.  The better solution is to use a little snippet of Javascript on the client like so:
+ 
+ {{{
+ <head>
+ <script>
+   function jumpToAnchor() {
+     <% if (request.getAttribute("hash") != null) { %>
+       location.hash = "<%=request.getAttribute("hash")%>";
+     <% } %>
+   }
+ </script>
+ </head>
+ <body onLoad="jumpToAnchor();">
+ }}}
+ 
+ Then, all you need to do is add an attribute named "hash" to the request right before you return the forward from your Action.  The value of the attribute is simply the name of the anchor you wish to jump to.  Voila, all set!
+ 
  = THE END =
  

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


Re: [Struts Wiki] Update of "StrutsSolutions" by FrankZammetti

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
I agree there is probably room for improvement.  Want to take it on
Michael?  :)

The nice thing about Wikis is anyone can edit them and contribute, so
while it is probably wise to discuss it here a bit and let everyone know
what you think should be changed and what you'd like to do, I for one
would be receptive.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Mon, August 1, 2005 12:01 pm, Michael Jouravlev said:
> On 8/1/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
>> I very much doubt anyone will complain if you do it (and if they do
>> someone could always just revert it!), so I for one say go for it!
>
> Struts Wiki as a whole is not structured well. I would prefer it to be
> restructured starting from the root page down.
>
> Michael.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>


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


Re: [Struts Wiki] Update of "StrutsSolutions" by FrankZammetti

Posted by Michael Jouravlev <jm...@gmail.com>.
On 8/1/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
> I very much doubt anyone will complain if you do it (and if they do
> someone could always just revert it!), so I for one say go for it!

Struts Wiki as a whole is not structured well. I would prefer it to be
restructured starting from the root page down.

Michael.

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


Re: [Struts Wiki] Update of "StrutsSolutions" by FrankZammetti

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Rick, I just noticed your comment on this page with regard to its
structure... I agree with you, it's a pretty sloppy right now (it's been
structrued a certain way from the start and no one has bothered to fix it
up)... although, it probably doesn't need to jump off to individual pages
for each item... just a more typical FAQ organization, a list of questions
and answers, with maybe a table of contents up top and jump links, would
be nice.

I very much doubt anyone will complain if you do it (and if they do
someone could always just revert it!), so I for one say go for it!

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Mon, August 1, 2005 10:34 am, Apache Wiki said:
> Dear Wiki user,
>
> You have subscribed to a wiki page or wiki category on "Struts Wiki" for
> change notification.
>
> The following page has been changed by FrankZammetti:
> http://wiki.apache.org/struts/StrutsSolutions
>
> ------------------------------------------------------------------------------
>
>   7. A plug & play solution to adding a "please wait" page to any Struts
> action: [StrutsPleaseWait]
>
> + 8. How do I include an anchor name when forwarding from an Action?
> (i.e., how can I make the page returned to the browser jump to a specific
> section out of an Action?)
> +
>   == DISCUSSION OF PROBLEMS (What Is The Problem?) ==
>
>   4. In an application I was architect and lead developer for last year, I
> was asked to expose certain pieces of functionality of the system as Web
> Services.  This request was made AFTER the application was complete and
> deployed in production.  I did not want to spend a lot of time on this
> (in fact, COULDN'T) and wanted to change as little code as possible,
> ideally none.
>
>   5. I've seen this question asked numerous times on the Struts User's
> mailing list, so I thought an entry somewhere on the Wiki might be a
> good idea.  The question is usually asked something like "How can I open
> a new window from an Action?"  It's a little vague, but it's along the
> lines of how can you submit a form and have the response appear in a new
> window.  Usually it's asked within the context of doing it variably,
> that is, sometimes returning in a new window, sometimes not.
> +
> + 8. If you name an anchor in your page (<a name="something">) and you
> want the browser to jump to that specific anchor when it is rendered, you
> would generally do something like <a href="mypage.htm#something"> if you
> were doing it from a link.  Or, from a servlet, you might attach
> #something to the end of the page name when using a dispatcher to forward.
>  If you try to append #something to the end of a forward name from an
> Action though (return mapping.findForward("myForward#something");) you
> will find that Struts throws an exception about not being able to find the
> forward.  That is because it is looking for a forward that is literally
> "myForward#something" and won't find it.
>
>   == DISCUSSION OF SOLUTIONS (What Is The Solution?) ==
>
> @@ -150, +154 @@
>
>
>   The bottom-line here is this: There is no way to direct the browser to
> open the response in a new window from an Action.  You either have to
> indicate you want this behavior when the form is submitted, or make it
> happen with scripting once the response is back at the browser.  At
> least, this is true within the confines of plain old HTML... You could
> always pull an applet out and do something like this!
>
> + 8. In theory at least (can someone verify this, I'm being lazy!) you
> could actually name your forward "myForward#something", and it should
> work.  However, this ties your page design a little too much to your
> Struts config, and that's probably not a good idea.  The better solution
> is to use a little snippet of Javascript on the client like so:
> +
> + {{{
> + <head>
> + <script>
> +   function jumpToAnchor() {
> +     <% if (request.getAttribute("hash") != null) { %>
> +       location.hash = "<%=request.getAttribute("hash")%>";
> +     <% } %>
> +   }
> + </script>
> + </head>
> + <body onLoad="jumpToAnchor();">
> + }}}
> +
> + Then, all you need to do is add an attribute named "hash" to the request
> right before you return the forward from your Action.  The value of the
> attribute is simply the name of the anchor you wish to jump to.  Voila,
> all set!
> +
>   = THE END =
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>


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