Question

I have a problem with submitting form, which contains normal and jQuery submit button.

This is code snippet of my JSP:

<sj:head loadAtOnce="true"/>

<s:form id="createModReadProjectForm" action="createProject" cssClass="internalForm" autocomplete="off">
    <s:token/>

    <s:textfield name="collName" cssClass="textField internal" cssErrorClass="textFieldError internal" />
    <div id="assignCollaborators">

    </div>

    <s:url action="assignCollabolator" id="assignCollaboratorUrl"/>
    <sj:submit key="labels.button.addColl" targets="assignCollaborators" 
            id="assignCollButton" formIds="createModReadProjectForm" cssClass="button small"
            href="%{assignCollaboratorUrl}"/>

    <s:submit />
</s:form>

jQuery submit button only adds typed into textfield user name to ArrayList and list all saved users in div with id="assignCollaborators" and this works fine.

Rendered jQuery submit :

jQuery(document).ready(function () {
     var options_assignCollButton = {};
     options_assignCollButton.jqueryaction = "button";
     options_assignCollButton.id = "assignCollButton";
     options_assignCollButton.name = "labels.button.addColl";
     options_assignCollButton.targets = "assignCollaborators";
     options_assignCollButton.href = "/CloudUML/assignCollabolator.action";
     options_assignCollButton.formids = "createModReadProjectForm";

     jQuery.struts2_jquery.bind(jQuery('#assignCollButton'),options_assignCollButton);
});

Now when I want to submit form, using last submit button, nothing happens. No Java or JavaScript errors. What can cause such strange behavior? Why jQuery submit works fine, when normal Struts2 s:submit not?

I assure that all needed actions and property fields are defined.

EDIT:

When I've created simple submit JavaScriptfunction and assign its toonclick` event to the last submit, it works properly.

function submitFunc() {
        document.forms['createModReadProjectForm'].submit();
    }
Was it helpful?

Solution

Seems like a bug in struts2-jquery-plugin: http://code.google.com/p/struts2-jquery/issues/detail?id=931.

It should work with version 3.3.3 of that plugin.

OTHER TIPS

Problem here is the e.PreventDefault() to prevent a normal submit on press enter inside of an form textfield.

See: http://code.google.com/p/struts2-jquery/source/browse/trunk/struts2-jquery-plugin/src/main/resources/template/js/struts2/jquery.struts2.js#947

What about using an normal Link instead of an button?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top