Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Carey Brown
  • Frits Walraven

How to use struts2 submit tag as button without submitting the form ?

Posts: 4
Notepad Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using struts2 framework in my application, I have one button on my jsp page. That is
<s:submit type="button" name="btnSave" />
Now i want this button to behave as normal HTML button type should not submit the form and execute the Scripting
function on onclick event. That function submit the form using ajax.

But what happens is struts2 convert it to
<input type="submit" id="add_btnSave" name="btnSave" value="Save"/>
And my form is submitted.

1)If I use the HTML button tag it will mess the GUI. As theme of my form is ajax.

This is Head with script

<s:head theme="ajax"/>
<script type="text/javascript">

dataType: "json",
error: function(XMLHttpRequest, textStatus, errorThrown){
alert('Error ' + textStatus);
success: function(){

My Body tag is as followes :

<table border="1" width="80%" align="center">
<td width="100%">
<s:tabbedPanel id="EmpDetail" useSelectedTabCookie="true">
<s:div id="one" label="Emp Reg." theme="ajax" tabindex="0" labelposition="top">
<s:form name="frmEmpReg" namespace="/" method="post">
<s:actionmessage />
<input type="hidden" name="" value="<s:property value=""/>"/>
<s:textfield label="Employee First Name" name="empbean.firstName"></s:textfield>
<s:textfield label="Employee Middle Name" name="empbean.middleName"></s:textfield>
<s:textfield label="Employee Last Name" name="empbean.lastName"></s:textfield>
<s:textfield label="Address" name="empbean.address"></s:textfield>
<s:textfield label="State" name="empbean.state"></s:textfield>
<s:textfield label="Employee Designation" name="empbean.designation"></s:textfield>
<s:submit name="btnSave" type="submit" value="Save" align="center"/>
Other Tabs

I had searched more and i found that was a bug but that post was of 2007. So if any one have idea about that or
any one have any idea of handling it with struts2 then please help.

Your help will be really appriciated.
If you send is by car it's a shipment, but if by ship it's cargo. This tiny ad told me:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic