Issue Details (XML | Word | Printable)

Key: TAPESTRY-339
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Jesse Kuhnert
Reporter: Nick Westgate
Votes: 3
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Tapestry

LinkSubmit can cause browser back button problems

Created: 13/Jun/05 06:49 PM   Updated: 30/Apr/06 04:53 PM
Return to search
Component/s: None
Affects Version/s: 3.0.5
Fix Version/s: 3.0.5

Time Tracking:
Not Specified

Environment: Any
Issue Links:
Duplicate
 

Resolution Date: 29/Mar/06 12:56 AM


 Description  « Hide
If LinkSubmit is mixed with other submit components in the same form, erroneous submits can occur from pages accessed via the browser back button. This happens because LinkSubmit's hidden variable is never reset.

Suggested fix (line marked +++) in LinkSubmit.java, renderComponent method:

                // make sure the submit function is on the page (once)
                if (cycle.getAttribute(ATTRIBUTE_FUNCTION_NAME) == null)
                {
+++ body.addInitializationScript("document." + formName + "._linkSubmit.value = null;");
                    body.addBodyScript(
                        "function submitLink(form, elementId) { form._linkSubmit.value = elementId; if (form.onsubmit == null || form.onsubmit()) form.submit(); }");
                    cycle.setAttribute(ATTRIBUTE_FUNCTION_NAME, this);
                }

It would be great if the corrected LinkSubmit submission mechanism detail was factored out into a separate class, so that other submit components could be built using it. For example, Glen Stampoultzis's ButtonSubmit component.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Nick Westgate added a comment - 14/Jun/05 05:18 PM
Oops. Damn Mondays ... the line (+++) should go in this block:

                // one hidden field per form:
                String formHiddenFieldAttributeName = ATTRIBUTE_FUNCTION_NAME + formName;
                if (cycle.getAttribute(formHiddenFieldAttributeName) == null)
                {
+++ body.addInitializationScript("document." + formName + "._linkSubmit.value = null;");
                    writer.beginEmpty("input");
                    writer.attribute("type", "hidden");
                    writer.attribute("name", "_linkSubmit");
                    cycle.setAttribute(formHiddenFieldAttributeName, this);
                }

Jesse Kuhnert added a comment - 29/Mar/06 12:56 AM
Applied to 3.0.4