aspose file tools*
The moose likes Struts and the fly likes Struts Form not Submitted Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Form not Submitted" Watch "Struts Form not Submitted" New topic
Author

Struts Form not Submitted

Sri Ram
Greenhorn

Joined: Feb 13, 2006
Posts: 20
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


Sriram<br />SCJP<br />SCWCD
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29219
    
134

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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 ]

Merrill
Consultant, Sima Solutions
shiva shanker
Greenhorn

Joined: Sep 02, 2007
Posts: 3
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts Form not Submitted
 
Similar Threads
how to identify which button is pressed in struts!!!
problem in html:image
more than one submit button and action
Can button be mapped to member variable?
Struts Form is not getting Submitted