Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

display radio button as selected

 
Dave Jamz
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am trying to set the value of my radio buttons from my action form but in the jsp I am just seeing two unselected radio buttons.

I have tried both of the ways below in the jsp:




action form code:


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see any evidence that you are putting the checked attribute on any of the elements.
 
Dave Jamz
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was trying to set the value from the actionform

When private Boolean testRadio = false; I want the no radio button to be selected and when private Boolean testRadio = true; i would like the yes radio button selected
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand what you are doing with the value attributes; those are usually static. But whatever, to cause a radio button to be checked, give it the checked attribute.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is more along the lines of what I'd do:This will place the checked attribute on the appropriate radio element.

I'd also recommend making use of the label element to make your buttons better behaved.
 
Dave Jamz
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks

What do the question mark and colon do?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ternary operator

You should review the EL specification.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic