This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Struts and the fly likes Strange problem when submitting a form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Strange problem when submitting a form" Watch "Strange problem when submitting a form" New topic
Author

Strange problem when submitting a form

Gustavo Santos
Ranch Hand

Joined: Jan 22, 2009
Posts: 40
Hi everyone, I'm facing a weird problem every time I try to submit a form... this actually has to do a bit with Javascript, which I'm still not very familiar with. but at least I could make it work.

So the issue is that when I submit the form with at least one of the the checkbox checked, I always get the "isChecked" value as false... since this is what I set on the reset() method.... but this happens only when I submit it by hitting the link button that I made up and put some Javascript stuff in... so, I tried putting a submit button on my JSP it worked just fine... so I'm assuming that this has to do with my Javascript.

Just so you guys know, I'm using Struts.

JSP:



The Form:



This is the Action which I use to get the form values and print them out:

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60072
    
  65

Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dave Whaley
Greenhorn

Joined: Aug 07, 2003
Posts: 5
Struts (version 1) has a problem retaining values for checkboxes. Sometimes you have to process the request and extract the named parameters. If you have a debugger, check the request values and look for attributes named by your checkboxes, and the corresponding values.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Unchecked checkboxes aren't sent back by the browser--this isn't a Struts-specific issue, that's just the way browsers work.

In any case, I'd first try using the actual form to call submit() on: inside a link tag I'd assume that this would refer to the link, not the form. I could be wrong about that, but as I've done JavaScript form submits forever without any issues I'd start by checking your assumptions.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Strange problem when submitting a form
 
Similar Threads
Attempting to get a parameter from a link
can we replace submit button with link in order to submit form ?
Unable to fetch data on a specific JSP....getting error "HTTP Status 404 - /getData.do"... help.
Struts- Error while java.lang.IllegalArgumentException: setAttribute: name parameter cannot be null.
spring jdbc and action class