Java
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives Mailing Lists Java

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old April 26th, 2005, 04:27 PM
Albert Kwong
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
LinkSubmit - issue when clicking back button

Hi Reid,

The reason is that LinkSubmit works by first setting a
javascript variable and then calling the submit()
function on the form. That's how the server side
identify the link being submitted. The javascript is
as follows:

function submitLink(form, elementId) {
form._linkSubmit.value = elementId;
if (form.onsubmit == null || form.onsubmit())
form.submit();
}

Therefore, on the first page, when you click the link
submit, the form._linkSubmit.value is set to the
LinkSubmit's id and you move on to the second page.
When you click back, the form._linkSubmit.value still
have the old value. When you click the Submit button,
the old value is sent again, the same listner is
invoked, and you are on the second page again!

solution: declare an onclick attribute for your Submit
button to call the submitLink() function.

Albert

Reid Badgett <reid.badgett (AT) neovera (DOT) com¤º®e¡G
I am experiencing an issue with using a LinkSubmit
and clicking the back
button. here is the scenario:

* I have two simple pages, First Page and Second
Page.
* First Page has a form which contains one
LinkSubmit component and
two Submit components.
* Clicking on the first LinkSubmit component or
the first Submit
component on the page will invoke a listener (i.e.
the same listener for
both the link submit or the button submit) which
will activate
SecondPage on the cycle and the user will be taken
to SecondPage.
* Clicking on the second Submit component should
invoke a different
listener which does nothing and so the user should
be sent back to the
same page (i.e. FirstPage).

I am experiencing odd behavior with the LinkSubmit.
If I click on the
LinkSubmit I am send to SecondPage as expected, but
when I hit back and
go back to FirstPage and then click the second
Submit button, I do not
stay on FirstPage as expected, but I am redirected
to SecondPage. This
does not happen if I originally get to SecondPage by
clicking on the
first Submit button. For some reason the listener
for the LinkSubmit
button is being called in this scenario before the
listener tied to the
second Submit button is called. However, if I had
clicked on the first
Submit button instead of the LinkSubmit and follow
the same exact flow,
the listener to redirect to the second page does not
get called, only
the listener tied to the second Submit button gets
called - this is the
behavior that I would expect.

In trying to debug the reason for this unexpected
behavior, I see that
during the rewind cycle of the FirstPage (i.e. after
I'd gone to
SecondPage by clicking on the LinkSubmit and then
clicked back to
FirstPage and then clicked on the second Submit
Button to stay on the
same page) it looks like there is an attribute set
on the cycle that
references the LinkSubmit that had been clicked on
previously to get me
to the Second page. This appears to be causing the
action to be invoked
to go to the second page.

I've included my simple FirstPage and SecondPage
example below so you
can see the problem and reproduce it if you like. I
know the previous
paragraph can be confusing.

Please let me know if I am doing something wrong or
this is the expected
behavior or if this is in fact a bug and I should
work around it.

Thanks,

Reid Badgett


P.S. The files are below:


FirstPage.html

<html>

<body jwcid="@Body">
<h1>First Page</h1>

<form jwcid="@Form">

<span jwcid="@LinkSubmit"
listener="">Go to
Page
2</span>&nbsp;(Causes an issue)
<p>
<span jwcid="@Submit" label="Go to Page 2"
>

listener=""/>&nbsp;(Does
not cause an
issue)
<p><p><p><p
<span jwcid="@Submit" label="Stay on
Page 1"
listener="ognl:FirstPageAction"/>

</form>

</body>

</html>



SecondPage.html

<html>

<body>
<h1>Second Page</h1>
</body>

</html>



FirstPage.java

package xyz.tapestrytest;

import org.apache.tapestry.IPage;
import ;
import ;

import
>


ccounts;

public class FirstPage extends BasePage
{

/**
* Will redirect to page two
*/
public void goToPageTwoAction(IRequestCycle
pCycle)
{
System.out.println("in
goToPageTwoAction()");
IPage page = pCycle.getPage("SecondPage");


// redirect to the second page
pCycle.activate(page);
}

/**
* Will do nothing and stay on the same page
*/
public void FirstPageAction(IRequestCycle
pCycle)
{
System.out.println("in
PAction()");
}
}



SecondPage.java

package xyz.tapestrytest;

import ;

public class SecondPage extends BasePage
{


}



FirstPage.page

<?xml version="1.0" encoding="UTF-8"?>
<!DCTYPE page-specification PUBLIC
"-//Apache Software Foundation//Tapestry
Specification 3.0//EN"

>

"">
<!-- generated by Spindle,
http://spindle.sourceforge.net

<page-specification
class="xyz.tapestrytest.FirstPage">


</page-specification>




message truncated

Are you an MBA? Check out http://www.mba.hk for value added services.


To unsubscribe, e-mail: tapestry-user-unsubscribe (AT) jakarta (DOT) apache.org
For additional commands, e-mail: tapestry-user-help (AT) jakarta (DOT) apache.org

Reply With Quote
Reply

Viewing: Web Development Archives Mailing Lists Java > LinkSubmit - issue when clicking back button


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek