Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to retrieve value from Radiobutton..It always returns null inspite of selecting .

 
shalu buchasia
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

getcolor alwauys returns null? Why? How should I retrieve value from a radio button..

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In jsp you have to read the value of the button by getParameter()method.then that value passes to the bean to set the color.
thanks.
 
shalu buchasia
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where should I call getparameter in my code.....
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have the right approach with:
public void setcolor(String tp)
{ color = tp;
}
public String getcolor()
{ return color;
}
BUT you are not observing the Bean naming rule, those methods should be
setColor( String x)
getColor( )
The variable name part of the method name must start with an upper case letter.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic