• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

more than one submit button and action

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have 2 submit buttons in my JSP.

<html:submit>Save</html:submit>
</html:submit>Delete</html:submit>

clicking on Save action should set to saveAll.do
clicking on Delete ,action should set to deleteAll.do

is it possible ?
if so how come?

pls help me
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi :

One simple solution is that onclick of the button you can use java script and set the action accordingly.
You can pass the button name in the function and check it,if it is delete it should be delete action otherwise submit action or whatever you want.
I think this would help.


Ramesh
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do a Google search on "Struts DispatchAction", and you will find a lot of articles that will help you. The DispatchAction class was designed specifically for this type of processing.

Here is one article:

http://www.reumann.net/struts/lesson3/step6.do
 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use LookupDispatchAction
 
selvi family
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I am using <html:form> tag..here action attribute is mandatory.so I want to set somethinlg like this action="<%= %>"

pls help me...
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried searching this forum? This question is asked and answered quite frequently.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If You use image buttons for different actions (using ImageButtonBean) one ActionClass can be used for different actions.

In your JSP
<html:form action="/ManageAction">
<html:image property="saveButton" src="logonsubmit.jpg" alt="save" />
<html:image property="deleteButton" src="deletesubmit.jpg" alt="delete" />
</html:form>


In your ActionForm

private ImageButtonBean saveButton = new ImageButtonBean();
private ImageButtonBean deleteButton = new ImageButtonBean();

public void setSaveButton(ImageButtonBean button) {
this.saveButton = button;
}

public ImageButtonBean getSaveButton() {
return this.saveButton;
}

public void setDeleteButton(ImageButtonBean button) {
this.deleteButton = button;
}

public ImageButtonBean getDeleteButton() {
return this.deleteButton;
}


public String getSelected() {

if (getSaveButton().isSelected()) {
return "save";
}

if (getDeleteButton().isSelected()) {
return "delete";
}

return null;
}

In your ActionClass

String selected = manageForm.getSelected();
if ("save".equals(selected)) {
//do something
return forward = mapping.findForward("savethankyou");
}
else if ("delete".equals(selected)) {
//do something
forward = mapping.findForward("deletethankyou");
}
else{
forward = mapping.findForward("error");
}


in your struts-config.xml
<form-bean name="manageForm" type="your.package.forms.ManageForm">
</form-bean>

<action name="manageForm" path="/ManageAction" scope="request" type="your.package.actions.ManageAction" validate="false" >

<forward name="deletethankyou" path="/deletethankyou.jsp"/>
<forward name="savethankyou" path="/savethankyou.jsp"/>
<forward name="error" path="/error.jsp"/>
</action>
[ July 27, 2005: Message edited by: rangababu chakravarthula ]
 
Those who dance are thought mad by those who hear not the music. This tiny ad plays the bagpipes:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic