You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Milan Milanovic <mi...@yahoo.com> on 2008/07/25 17:59:38 UTC

[S2] Form doesn't redirect

Hi,

I have two forms in my .jsp page which are connected to one Action class.
They both works fine, but when user submit second form, method in action
class
is called, but no redirection to resulting .jsp page (as defined GOOD in
struts.xml) is done ?

This is my (second) form:

<s:form action="save" validate="false">
	<s:textfield id="value" tabindex="1" label="Value" name="value"/>
	<s:submit theme="ajax" tabindex="2" cssStyle="submit" cssClass="submit"
align="right" value="Save"/>
</s:form>

and this is from struts.xml:

<action name="save" class="myActionClass" method="save">
            <result>/pages/firstPage.jsp</result>
</action>

--
Thx, Milan
 
-- 
View this message in context: http://www.nabble.com/-S2--Form-doesn%27t-redirect-tp18654630p18654630.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] Form doesn't redirect

Posted by Dave Newton <ne...@yahoo.com>.
--- On Wed, 7/30/08, Nick Scavelli <ni...@gmail.com> wrote:
> I'm replying to this because it's somewhat related
> to an issue I'm having.

Not really :p

> Let's say I have the following control in my jsp:
> <sx:submit type="button" method="search" value="Search"
>            targets="resultsDiv" indicator="indicator"/>
> 
> But let's say my session has timed out, and I need to redirect to the 
> login page.  In my circumstance the div is replaced by the login jsp,
> which just looks strange.  What are the best practices with dealing with
> these situations using Ajax.

I'm not sure what the *best* practice is, but one solution is to write an interceptor that checks if a request is an XHR. If it is, and the session is gone (or whatever other criteria is necessary), send back a 302 and the name of a global result (that's what we've done here, anyway). Even though it's an XHR the browser will redirect before the request gets back to your code--in essence making the request non-back-channel anymore.

(I'm not entirely convinced that behavior is reasonable, but it's a browser thing, so hey.)

Dave


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


Re: [S2] Form doesn't redirect

Posted by Nick Scavelli <ni...@gmail.com>.
I'm replying to this because it's somewhat related to an issue I'm having.

Let's say I have the following control in my jsp:
<sx:submit type="button" method="search" value="Search"
targets="resultsDiv" indicator="indicator"/>

This of course will update the div defined in my jsp:
<div id="resultsDiv"/>

Everything works great under normal circumstances.  But let's say my
session has timed out, and I need to redirect to the login page.  In
my circumstance the div is replaced by the login jsp, which just looks
strange.  What are the best practices with dealing with these
situations using Ajax.

- Nick

On Mon, Jul 28, 2008 at 8:28 AM, Dave Newton <ne...@yahoo.com> wrote:
> --- On Mon, 7/28/08, Milan Milanovic <mi...@yahoo.com> wrote:
>> well I don't understand what is the problem, I use ajax
>> for my first form, but not to second which should redirect?
>
> ...
>
> Not reloading the entire page is one of the main points of Ajax.
>
> If you want to reload the entire page (like with a redirect) and you're not handling that yourself in JavaScript I don't really see the point (in general; there are exceptions).
>
> You may want to read up on Ajax fundamentals; JJG's article is one of the more popular ones, even though people have been doing it for a decade+ now.
>
> http://www.adaptivepath.com/ideas/essays/archives/000385.php
>
> The Wikipedia article gives a shorter, higher-level overview. The second sentence may be informative:
>
> "With Ajax, web applications can retrieve data from the server asynchronously in the background without interfering with the display and behavior of the existing page."
>
> http://en.wikipedia.org/wiki/AJAX
>
> Dave
>
>
> ---------------------------------------------------------------------
> 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


Re: [S2] Form doesn't redirect

Posted by Milan Milanovic <mi...@yahoo.com>.
I forgot to change theme from ajax to simple in my second form. Now it works,
sorry.

--
Milan


Milan Milanovic wrote:
> 
> Hi Dave,
> 
> well I don't understand what is the problem, I use ajax for my first form,
> but not to second which should redirect ?
> 
> --
> Thx, Milan
> 
> 
> newton.dave wrote:
>> 
>> --- On Mon, 7/28/08, Milan Milanovic <mi...@yahoo.com> wrote:
>>> this second form should redirect and yes it doesn't have target
>>> specified, as I don't want to specify any part of the page, but 
>>> I want to show (redirect to) completely new page. What can I do ?
>> 
>> Don't use Ajax?
>> 
>> Dave
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>> 
>> 
> 
> 
:blush::blush:
-- 
View this message in context: http://www.nabble.com/-S2--Form-doesn%27t-redirect-tp18654630p18689222.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] Form doesn't redirect

Posted by Milan Milanovic <mi...@yahoo.com>.
Hi Dave,

thank you on Ajax reference. I know basically Ajax and I'm using it in my
applications for simple updating of data. I just forgot to remove
theme="ajax" from submit button and that was the problem, as I said so.

--
Regards, Milan


newton.dave wrote:
> 
> --- On Mon, 7/28/08, Milan Milanovic <mi...@yahoo.com> wrote:
>> well I don't understand what is the problem, I use ajax
>> for my first form, but not to second which should redirect?
> 
> ...
> 
> Not reloading the entire page is one of the main points of Ajax.
> 
> If you want to reload the entire page (like with a redirect) and you're
> not handling that yourself in JavaScript I don't really see the point (in
> general; there are exceptions).
> 
> You may want to read up on Ajax fundamentals; JJG's article is one of the
> more popular ones, even though people have been doing it for a decade+
> now.
> 
> http://www.adaptivepath.com/ideas/essays/archives/000385.php
> 
> The Wikipedia article gives a shorter, higher-level overview. The second
> sentence may be informative:
> 
> "With Ajax, web applications can retrieve data from the server
> asynchronously in the background without interfering with the display and
> behavior of the existing page."
> 
> http://en.wikipedia.org/wiki/AJAX
> 
> Dave
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Form-doesn%27t-redirect-tp18654630p18710092.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] Form doesn't redirect

Posted by Dave Newton <ne...@yahoo.com>.
--- On Mon, 7/28/08, Milan Milanovic <mi...@yahoo.com> wrote:
> well I don't understand what is the problem, I use ajax
> for my first form, but not to second which should redirect?

...

Not reloading the entire page is one of the main points of Ajax.

If you want to reload the entire page (like with a redirect) and you're not handling that yourself in JavaScript I don't really see the point (in general; there are exceptions).

You may want to read up on Ajax fundamentals; JJG's article is one of the more popular ones, even though people have been doing it for a decade+ now.

http://www.adaptivepath.com/ideas/essays/archives/000385.php

The Wikipedia article gives a shorter, higher-level overview. The second sentence may be informative:

"With Ajax, web applications can retrieve data from the server asynchronously in the background without interfering with the display and behavior of the existing page."

http://en.wikipedia.org/wiki/AJAX

Dave


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


Re: [S2] Form doesn't redirect

Posted by Milan Milanovic <mi...@yahoo.com>.
Hi Dave,

well I don't understand what is the problem, I use ajax for my first form,
but not to second which should redirect ?

--
Thx, Milan


newton.dave wrote:
> 
> --- On Mon, 7/28/08, Milan Milanovic <mi...@yahoo.com> wrote:
>> this second form should redirect and yes it doesn't have target
>> specified, as I don't want to specify any part of the page, but 
>> I want to show (redirect to) completely new page. What can I do ?
> 
> Don't use Ajax?
> 
> Dave
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Form-doesn%27t-redirect-tp18654630p18688965.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] Form doesn't redirect

Posted by Dave Newton <ne...@yahoo.com>.
--- On Mon, 7/28/08, Milan Milanovic <mi...@yahoo.com> wrote:
> this second form should redirect and yes it doesn't have target
> specified, as I don't want to specify any part of the page, but 
> I want to show (redirect to) completely new page. What can I do ?

Don't use Ajax?

Dave


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


Re: [S2] Form doesn't redirect

Posted by Milan Milanovic <mi...@yahoo.com>.
Hi Newton,

my first form doesn't redirect, it just send some data to action class and
updates targeting div in the page to show updated data from my class, so it
works fine, but it shouldn't redirect from page. But, this second form
should redirect and yes it doesn't have target specified, as I don't want to
specify any part of the page, but I want to show (redirect to) completely
new page. What can I do ?

--
Thanks, Milan


newton.dave wrote:
> 
> --- On Sun, 7/27/08, Milan Milanovic <mi...@yahoo.com> wrote:
>>>> <s:form action="save" validate="false">
>>>>   <s:textfield id="value" tabindex="1" label="Value" name="value"/>
>>>>   <s:submit theme="ajax" tabindex="2" cssStyle="submit"
>>>>             cssClass="submit" align="right" value="Save"/>
>>>> </s:form>
> 
> Do Ajax forms redirect? I thought they submitted in the background via an
> XHR. Since you don't have a target specified, would the result just be
> ignored?
> 
> Dave
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Form-doesn%27t-redirect-tp18654630p18688696.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] Form doesn't redirect

Posted by Dave Newton <ne...@yahoo.com>.
--- On Sun, 7/27/08, Milan Milanovic <mi...@yahoo.com> wrote:
>>> <s:form action="save" validate="false">
>>>   <s:textfield id="value" tabindex="1" label="Value" name="value"/>
>>>   <s:submit theme="ajax" tabindex="2" cssStyle="submit"
>>>             cssClass="submit" align="right" value="Save"/>
>>> </s:form>

Do Ajax forms redirect? I thought they submitted in the background via an XHR. Since you don't have a target specified, would the result just be ignored?

Dave


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


Re: [S2] Form doesn't redirect

Posted by Milan Milanovic <mi...@yahoo.com>.
Hi,

no, no error! My first form works good with ajax and updates some table
value, but this second form that should save one value from textfield and
redirect from that page, works fine with called submit method, but there is
no redirection, it just stays on this page, it even not refresh.

--
Thx, Milan



Dhiraj Thakur wrote:
> 
> r u getting any error?
> 
> Regards,
> Dhiraj
> 
> On Fri, Jul 25, 2008 at 9:29 PM, Milan Milanovic
> <mi...@yahoo.com>wrote:
> 
>>
>> Hi,
>>
>> I have two forms in my .jsp page which are connected to one Action class.
>> They both works fine, but when user submit second form, method in action
>> class
>> is called, but no redirection to resulting .jsp page (as defined GOOD in
>> struts.xml) is done ?
>>
>> This is my (second) form:
>>
>> <s:form action="save" validate="false">
>>        <s:textfield id="value" tabindex="1" label="Value" name="value"/>
>>        <s:submit theme="ajax" tabindex="2" cssStyle="submit"
>> cssClass="submit"
>> align="right" value="Save"/>
>> </s:form>
>>
>> and this is from struts.xml:
>>
>> <action name="save" class="myActionClass" method="save">
>>            <result>/pages/firstPage.jsp</result>
>> </action>
>>
>> --
>> Thx, Milan
>>
>> --
>> View this message in context:
>> http://www.nabble.com/-S2--Form-doesn%27t-redirect-tp18654630p18654630.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Form-doesn%27t-redirect-tp18654630p18682482.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] Form doesn't redirect

Posted by Dhiraj Thakur <de...@gmail.com>.
r u getting any error?

Regards,
Dhiraj

On Fri, Jul 25, 2008 at 9:29 PM, Milan Milanovic
<mi...@yahoo.com>wrote:

>
> Hi,
>
> I have two forms in my .jsp page which are connected to one Action class.
> They both works fine, but when user submit second form, method in action
> class
> is called, but no redirection to resulting .jsp page (as defined GOOD in
> struts.xml) is done ?
>
> This is my (second) form:
>
> <s:form action="save" validate="false">
>        <s:textfield id="value" tabindex="1" label="Value" name="value"/>
>        <s:submit theme="ajax" tabindex="2" cssStyle="submit"
> cssClass="submit"
> align="right" value="Save"/>
> </s:form>
>
> and this is from struts.xml:
>
> <action name="save" class="myActionClass" method="save">
>            <result>/pages/firstPage.jsp</result>
> </action>
>
> --
> Thx, Milan
>
> --
> View this message in context:
> http://www.nabble.com/-S2--Form-doesn%27t-redirect-tp18654630p18654630.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>