File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts Form is not getting Submitted Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Form is not getting Submitted " Watch "Struts Form is not getting Submitted " New topic
Author

Struts Form is not getting Submitted

shiva shanker
Greenhorn

Joined: Sep 02, 2007
Posts: 3
Hi,
Im trying to submit a form using a image button.

Below are the snippets of struts config and the code for html image submit button.I have included the get and setsave code.

Struts Config:
<action
attribute="mnSeaLvlPressureForm"
input="/MnSeaLvlPressureIn.jsp"
name="mnSeaLvlPressureForm"
path="/mnSeaLvlPressure"
scope="request"
type="com.yourcompany.struts.action.MnSeaLvlPressureAction" >
<forward name="report" path="/MnSeaLvlPressureout.jsp" />
<forward name="output" path="/MnSeaLvlPressureIn.jsp" />
</action>

HTML code:
<%String goImage = renderRequest.getContextPath() + "/crystalreportviewers115/images/toolbar/ed_gl_ls_go.gif" ;%>
<tr><td colspan="2" align="center"><html:image property="save" src='<%= goImage %>' onclik="return fnsubmit();" value="View" ></html:image></td></tr>



Form code:

<code>
private ImageButtonBean save = new ImageButtonBean();

public ImageButtonBean getSave() {
return save;
}
public void setSave(ImageButtonBean button) {
System.out.println("calling the setSave method");
this.save = button;
}

public String getval(){
System.out.println("save is "+getSave());
System.out.println("save = getSave()" + (save.equals(getSave())));
System.out.println("X value = " + getSave().getX() + "; Y value = " + getSave().getY());
System.out.println("Get Selected in Form"+getSave().isSelected());
if (getSave().isSelected())
{ return "save";
}
return "False";
}

public String getStationcode() {
return stationcode;
}
</code>

when i tried to print the getSave().getX() and getSave().getY() sometimes it's printing null and sometimes its printing integer, its not consistent.

Hope you can guys can help me out..

Regards
Shiva.
Chris Boldon
Ranch Hand

Joined: Aug 10, 2006
Posts: 190
onclik -> onclick ??
shiva shanker
Greenhorn

Joined: Sep 02, 2007
Posts: 3
its onclick. Was not able to post in this forum as onclick, So,have had to change.

shiva.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Your code will cause a double submit to occur. An html:image tag is already a submit button, so you don't need to put a submit in the onclick event to make the submit occur. That's why you're getting strange results: For the submit caused by the button itself, there will be a value in x and y. For the submit caused by the onclick event, these values will be null.


Merrill
Consultant, Sima Solutions
 
jQuery in Action, 2nd edition
 
subject: Struts Form is not getting Submitted
 
Similar Threads
how to identify which button is pressed in struts!!!
more than one submit button and action
Struts Form not Submitted
Struts 1.2.4 File Upload - Form File is null in action
html:iterate or html:multibox problem