Search code examples
ajaxjspstrutsyui

Button label gets added to form data as a param with no name


I have a jsp page with two ajaxy buttons on it: Quick Save and Run. Both buttons call a javascript method that essentially does:

function submitForm(url) {
    document.<formname>.action = url;
    // call method that makes ajax call via YAHOO.util.Connect.asyncRequest
    submitAjaxRequest(document.<formname>); 
}

Then the button does return false; so the page doesn't navigate.

The problem: After clicking "Quick Save", everything works as it should. However, now when I click "Run", the submitted form data includes ": Quick Save", which causes tomcat to throw the warning "Parameters: Invalid chunk ignored."

If I try this in reverse (i.e., click Run and then Quick Save) I don't see any such problem. Any idea why a button label would be added to the form data? YUI problem? Struts problem?

Here's the struts definition of the actions:

    <action path="/edit" type="com.llc.MyActionClass" parameter="edit"
            name="formName" validate="false" scope="request">
        <set-property property="permission" value="ModifyData"/>
        <forward name="success"         path="def.tile.edit" />
        <forward name="error"           path="/list.do" />
    </action>

    <action path="/save" type="com.llc.MyActionClass" parameter="save"
            name="formName" validate="true" scope="request"  input="/edit.do?validation_error=true">
        <set-property property="cancellable" value="true"/>
        <set-property property="permission" value="ModifyData"/>
        <forward name="success"         path="/list.do" redirect="false"/>
        <forward name="quicksave"       path="/edit.do" redirect="false"/>
        <forward name="cancel"          path="/list.do" redirect="true"/>
        <forward name="error"           path="/edit.do" />
    </action>

    <action path="/run" type="com.llc.MyActionClass" parameter="find"
            name="formName" validate="true" scope="request"  input="/edit.do?validation_error=true">
        <set-property property="permission" value="ModifyData"/>
        <forward name="success" path="def.tile.result" redirect="true"/>
        <forward name="error"   path="/edit.do" />
    </action>

Solution

  • It was caused by:

    <input type="submit"/>
    

    Changing the type attribute to "button" resulted in the button label not getting added to the form data.