• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts Form not Submitted

 
Sri Ram
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Im trying to submit a form using a Html Submit button

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

public ImageButtonBean getSaveButton() {
return saveButton;
}



public void setSaveButton(ImageButtonBean saveButton) {
System.out.println("Calling the Set Save Button");
this.saveButton = saveButton;
}</code>

My JSP has the submit button


When I click on the submit button the Setter for Save Button is not called.Can you please let me know the fix for this

Thanks and Regards,
Sriram
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34198
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sri,
Can you show the relevant snippet of your Struts config file and the code for the HTML submit buttton?

Also, where does the code snippet you provided reside? I'm not sure how instantiating the form bean fits in. Usually Struts takes care of that for you.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using an html:image tag for your submit button? Having a property of type ImageButtonBean only works when you use this tag along with an image file.

It's also important to realize that it's perfectly normal that your setter does not get called. The calls that Struts will make when the form is submitted by pressing this button will be something like this:

Once Struts has done this and you call myActionForm.getSaveButton.isSelected() in your Action class, it will return true.
[ September 02, 2007: Message edited by: Merrill Higginson ]
 
shiva shanker
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne,
On Behalf of Sriram i am including the snippets of struts config and the code for html submit button.Also, have included the get and setsavebutton 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:submit property="saveButton" on click="return fnsubmit();" value="View" >Submit</html:submit></td></tr>




<code>
private ImageButtonBean saveButton = new ImageButtonBean();
public ImageButtonBean getSaveButton() {
return saveButton;
}
public void setSaveButton(ImageButtonBean saveButton) {
System.out.println("Calling the Set Save Button");
this.saveButton = saveButton;
}

public String getval(){
System.out.println("Get Selected in Form"+getSaveButton().isSelected());
if (getSaveButton().isSelected())
{ return "save";
}
return "False";
}
</code>

Hope you can give some suggestions

Regards
Shiva.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic