0

I'm trying to find out how to make a radio button checked by default when using jsp and struts 1.1 with custom tag.

When i write my code this way :

<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
....................................................................  
<html:radio property="operazione" value="addizione" checked="checked">Addizione</html:radio>  
<br />

eclipse say :

Undefined attribute name "checked"

and when i try to run this code on my server Tomcat this is what i get:

Attribute checked invalid for tag radio according to TLD

I've read this q/a but it involves JavaScript... Can you help me?

Community
  • 1
  • 1
aldroid
  • 25
  • 1
  • 8

1 Answers1

0

That doesn't involves javascript. All you need to do is set the property value in the respective action form. While loading the page, set the actionForm.property=value in the action class. If you required in javascript,

(function() {
   // Set the value on loading the page
   document.getElementByID("elementID").value=1;
})();

Hope this helps.

Vinoth Krishnan
  • 2,925
  • 6
  • 29
  • 34
  • now i get it ! simply when the form is submitted, the action class have to test if the property associated with the radio is null or not; if null the action have to set the value to the default one... – aldroid Mar 05 '15 at 11:00
  • so there is no attribute for to set one radio button selected :/ – aldroid Mar 05 '15 at 11:01