• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Struts Form not Submitted

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 42074
933
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Morning came much too soon and it brought along a friend named Margarita Hangover, and a tiny ad.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic