File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
    Bookmark Topic Watch Topic
  • New Topic

Return type of checkbox

 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi All,
I'm trying to return to set the value returned by a checkbox(whether checked or not) to a bean variable.However Imnot sure what the return type of the checkbox would be .
Is it boolean or String?
Thanks for helping.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
All request parameters are strings. That's the way HTTP works.

Various frameworks, and tools like BeanUtils, can convert these strings to other types, but the submitted data itself is always a string.
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks for the reply it worked !
 
Stefan Evans
Bartender
Posts: 1640
9
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
You should note that standard HTML checkboxes will submit
- their value if they are checked (or ON if there is no value defined)
- no request parameter if they are unchecked.


 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Stefan ,
Thanks for replying!
I think I'm missing something of the sort ,but cant figure how to work around it . Ive posted it in the post:
http://www.coderanch.com/t/538471/JSP/java/Return-value-checkbox-throwing-NPE
Your comment would be much appreciated.
 
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic