• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem with html:radio

 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I want to render radio buttons on html.
I have this chunk of code

<logic resent name = "qvalues" >
<logic:iterate id = "qvalue" name = "qvalues" >
<html:radio property="abc" idName="qvalue" value="value" />
<bean:write name = "qvalue" property = "value" />
</logic:iterate>
</logic resent>

"qvalues" is a collection i get from database. I want to iterate thru the collection and display all the radio buttons. I get this error
javax.servlet.jsp.JspException: Cannot find bean under name org.apache.struts.taglib.html.BEAN
at org.apache.struts.taglib.html.BaseHandlerTag.lookupProperty(BaseHandlerTag.java:945)
at org.apache.struts.taglib.html.RadioTag.currentValue(RadioTag.java:198)
at org.apache.struts.taglib.html.RadioTag.doStartTag(RadioTag.java:166)

If i remove this line of code <html:radio property="abc" idName="qvalue" value="value" /> and replace with regular html radio it works fine.

Please help me...
Thanks,
Srik
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here are some possibilities:

1-Is the <html:radio> tag enclosed in a <html:form></html:form> tag pair?
2-Does the action attribute of the form tag correspond to a valid action mapping?
3-Does the form bean that is used by the action mapping have an "abc" property?

A negative answer to any of the above might cause this error.
 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merrill,

My form bean that is used by the action mapping doesnt have an "abc" property. I am new to struts. I was going thru some tutorials and it said property is like name of the radio button.

The property i have in form bean is 'value' so i am doing
<bean:write name = "qvalue" property = "value" />
but what actually does property in html:radio do??

Thanks,
 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

My form bean that is used by the action mapping doesnt have an "abc" property. I am new to struts. I was going thru some tutorials and it said property is like name of the radio button.

The property i have in form bean is 'value' so i am doing
<bean:write name = "qvalue" property = "value" />
but what actually does property in html:radio do??

Thanks,



Property of html:radio is same as the property of any other struts component... The property name should have a corresponding valid getter and setter in the form bean. In your example, It is "abc" for radio component
[ February 15, 2006: Message edited by: Raghavendra nandavar ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in the html:radio tag, value means the value to be passed if the radio button is checked. Here's an example:

form bean:
private String colorValue;

public String getColorValue() {return this.colorValue);}
public void setColorValue(String c) {this.colorValue = c;}

Action class:
String[] availableColors = {"red", "green", "blue", "orange");
request.setAttribute("availableColors", availableColors);


JSP:

<logic:iterate name="availableColors" id="availableColor" />
<html:radio property="colorValue" value="<%=availableColor%>"/>
</logic:iterate>


This code will produce four radio buttons. When the form is submitted, the colorValue property of the form bean will be populated with one of the four colors depending on which button is selected.
[ February 16, 2006: Message edited by: Merrill Higginson ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic