title: Radio buttons don't have "checked" in Struts 1 ActionForm
body: <p>I have a JSP page with a number of questions and an ActionForm with a Map of input names and values.</p>
  
  <p>When I load the page, the values (checked attribute) of the radio inputs aren’t set, but the checkboxes are. </p>
  
  <p>Form define:</p>
  
  <pre><code>&lt;bean:define id="form" name="questionForm" type="com.example.QuestionForm"/&gt;
  </code></pre>
  
  <p>Radio (jsp):</p>
  
  <pre><code>&lt;html:radio property="&lt;%=\"boolean(\" + questionBase + \"V\" + respLabel + \")\"%&gt;" styleClass="pepperoni1" value="1"  &gt;Yes&lt;/html:radio&gt;
  &lt;html:radio property="&lt;%=\"boolean(\" + questionBase + \"V\" + respLabel + \")\"%&gt;" styleClass="pepperoni0" value="0"  &gt;No&lt;/html:radio&gt;
  </code></pre>
  
  <p>Radio (html):</p>
  
  <pre><code>&lt;input type="radio" class="pepperoni1" value="1" name="boolean(pepperoniVNever)"&gt;Yes
  &lt;input type="radio" class="pepperoni0" value="0" name="boolean(pepperoniVNever)"&gt;No
  </code></pre>
  
  <p>Checkbox (jsp):</p>
  
  <pre><code>&lt;html:checkbox property="&lt;%=\"boolean(\" + questionBase + \"V\" + respLabel + \")\"%&gt;" styleClass="pepperoni" /&gt;
  </code></pre>
  
  <p>Checkbox (html):</p>
  
  <pre><code>&lt;input type="checkbox" class="pepperoni" checked="checked" value="on" name="boolean(pepperoniV1)"&gt;
  </code></pre>
  
  <p>The checked attribute is not set but the values are <strong>not empty</strong> when being access via on page load/form submit by <code>getBoolean</code>/<code>setBoolean</code>. </p>
  
  <p>My ActionForm class has these correlating methods available:</p>
  
  <pre><code>public void setValue(String key, String value) {
      if (value != null)
          values.put(key, value);
  }
  
  public String getValue(String key) {
      return values.get(key);
  }
  
  public boolean getBoolean(String key) {
     if (values.get(key) != null){
          if(values.get(key).equalsIgnoreCase("1")){
              return true;
          } else if(values.get(key).equalsIgnoreCase("0")){
              return false;
          }
          return "yes".equalsIgnoreCase(values.get(key));
      }
      return false;
  }
  
  public void setBoolean(String key, boolean value) {
      if(value){
          values.put(key, "yes");
      }
  }
  </code></pre>
  
  <p>I'm using struts 1.2.7, Hibernate 3, DisplayTag 1.0, OpenJDk 6, and Tomcat 6 on Ubuntu 14.04. </p>
  
  <h2>Update</h2>
  
  <p>However, the following radio inputs <strong>do</strong> work (as you can see by the "checked" attribute:</p>
  
  <p>Radio (jsp):</p>
  
  <pre><code>&lt;html:radio property="&lt;%=\"value(\" + questionBase + \"B)\"%&gt;" value="No"&gt;No&lt;/html:radio&gt;
  &lt;html:radio property="&lt;%=\"value(\" + questionBase + \"B)\"%&gt;" value="Yes"&gt;Yes&lt;/html:radio&gt;
  </code></pre>
  
  <p>Radio (html):</p>
  
  <pre><code>&lt;input name="value(noteB)" value="Yes" checked="checked" type="radio"&gt;
  &lt;input name="value(noteB)" value="No" type="radio"&gt;
  </code></pre>
  
  <p>But after editing the inputs using <code>boolean</code> to use <code>value</code>, the <code>checked</code> attribute is still not set on load.</p>
  
  <h2>Update (5/10/15)</h2>
  
  <p>After making the changes recommended by shinjw, the values are saved correctly (which was a separate issue) but the checked attribute is still not set for some of the radio buttons when <code>getBoolen</code> returns true. </p>