This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Struts and the fly likes request submission struts/jquery Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "request submission struts/jquery" Watch "request submission struts/jquery" New topic

request submission struts/jquery

Bhavin Sanghani
Ranch Hand

Joined: Dec 17, 2003
Posts: 67

I am using JQuery with Struts 1.1. I am using following code when user
clicks on Save button:

$('#save').click(function() {
$.blockUI({ message: "Please wait..." });

url: '/',
cache: false,
complete: function() {

In my struts code,

<html:form action="/saveTemplate.htm?dispatch=save" method="POST">
<div id="firstchildcontainer">
Name: <html:text property="templateName"/>
Description: <html:textarea property="description" rows="8"
<html:submit styleId="save"><bean:message key=""/></
<html:cancel styleId="cancel"><bean:message key="button.cancel"/></

The problem here is it is submitting request twice because it is
defined with struts form and with url (in ajax). How can I avoid
duplicate request?

David Newton

Joined: Sep 29, 2008
Posts: 12617

This is a JavaScript question, not Struts.

You need to return false from your JavaScript handler to prevent the default click handler from running after the Ajax request.
Bhavin Sanghani
Ranch Hand

Joined: Dec 17, 2003
Posts: 67
Thanks. I tried "return false;" at end of ajax call and it submits one request but it does not populate form fields in actionForm.

can anyone give example of Jquery + Struts 1?

I agree. Here's the link:
subject: request submission struts/jquery
It's not a secret anymore!