0

I am using GWT. I have a chkBox and fileupload which are added to formPanel.

after formPanel.submit();

On Server Side

I want the value of chkbox

so

if (item.isFormField()) {
        if (item.getFieldName().equalsIgnoreCase("chkbox")) {
                        chkbox= Streams.asString(item.openStream());
                    }

                }

when chkbox.getvalue is true , the value on server side is On and chkbox.getValue is false the i get null on the server side.

i need the values of chkbox so that i can perform operation on file depending on the value of chkbox

GameBuilder
  • 1,169
  • 4
  • 31
  • 62
  • The logical thing to do would be to pass the value up from the client as part of the request. IMO, the server should be agnostic of UI -- as far as the server should be concerned, the UI doesn't exist. – Chris Cashwell Apr 25 '12 at 14:50

1 Answers1

1

"On" is the default value of a checkbox when no form value has been provided.

That value will only be sent to the server if the box is checked (absence of the field means it was unchecked): http://www.w3.org/TR/html5/form-submission.html#constructing-form-data-set

If you really want to send anything else, then don't give your checkbox a name and instead use a Hidden field that you update using a ValueChangeHandler on the Checkbox.

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164