kumarsdk
kumarsdk

Reputation: 13

How to perform single Struts Form Submit action

I have Multiple button in single html form , but i need to perform only single button action other button do not go to execute() method in struts 1.3

Eg:

button1: connect
button2 : disconnect 
button3 :save 

i need to perform only save button action will go to the struts execute() method others won't go

Thanks in advance

Upvotes: 0

Views: 1122

Answers (3)

seedi
seedi

Reputation: 94

first two are normal buttons nd hence click those buttons dont submit the form to server until u write the onclick() event, but 3rd one is submit buttton by click on submit request send to server automayically to the resource given in action attribute in tag.

<input type="button" value="connect"/>
<input type="button" value="disconnect"/>
<input type="submit" value="save"/> 

Upvotes: 1

Alex
Alex

Reputation: 11579

Extend your action DispatchAction and create 3 different methods for each button http://struts.apache.org/development/1.x/struts-extras/apidocs/org/apache/struts/actions/DispatchAction.html
OR
Use <input type="button"> for first 2 buttons and submit for button3.

Upvotes: 0

NullPointerException
NullPointerException

Reputation: 3804

Make Button1 and Button2 as simple button and make button3 as submit button

<button type="button" onclick="connect()">Button1</button>
<button type="button" onclick="disconnect()">Button2</button>

<input type="submit" value="button3">

Upvotes: 1

Related Questions