Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts Form is not getting Submitted

 
shiva shanker
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
onclik -> onclick ??
 
shiva shanker
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its onclick. Was not able to post in this forum as onclick, So,have had to change.

shiva.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic