title: Mapping an Enum to form elements using struts2
body: <p>I'm trying to create a form which contains a radio button that maps to a class that extends java.lang.Enum.</p>
  
  <pre><code>&lt;s:form action="corp_low_save"&gt;
    &lt;s:textfield label="Corporate Client Name" name="name"/&gt;
    &lt;s:radio list="clientStatus.status" name="clientStatus.status"/&gt;
    &lt;s:textfield label="Primary Address Street" name="primaryAddress.street"/&gt;  
    &lt;s:submit /&gt;
  &lt;/s:form&gt;
  </code></pre>
  
  <p>The Action implements ModelDriven and is making a new instance of the following object available via getModel():</p>
  
  <pre><code>public class com...Customer extends java.lang.Object{
      protected java.lang.String name;
      protected com...ClientStatus clientStatus;
      protected com...Address primaryAddress;
      public com...Customer();
      public java.lang.String getName();
      public void setName(java.lang.String);
      public com...ClientStatus getClientStatus();
      public void setClientStatus(com...ClientStatus);
      public com...Address getPrimaryAddress();
      public void setPrimaryAddress(com...Address);
  }
  </code></pre>
  
  <p>Here are the rest of the relevant classes.  They were all generated by JAXB:</p>
  
  <pre><code>public class com...ClientStatus extends java.lang.Object{
      protected com...StatusString status;
      protected javax.xml.datatype.XMLGregorianCalendar since;
      protected java.lang.String business;
      public com...ClientStatus();
      public com...StatusString getStatus();
      public void setStatus(com...StatusString);
      public javax.xml.datatype.XMLGregorianCalendar getSince();
      public void setSince(javax.xml.datatype.XMLGregorianCalendar);
      public java.lang.String getBusiness();
      public void setBusiness(java.lang.String);
  }
  
  public final class com...StatusString extends java.lang.Enum{
      public static final com...StatusString NEW_CLIENT;
      public static final com...StatusString EXISTING_CLIENT;
      public static final com...StatusString RENEWAL;
      public static com...StatusString[] values();
      public static com...StatusString valueOf(java.lang.String);
      public java.lang.String value();
      public static com...StatusString fromValue(java.lang.String);
      static {};
  }
  </code></pre>
  
  <p>I'm getting this error:</p>
  
  <blockquote>
    <p>org.apache.jasper.JasperException: tag
    'radio', field 'list', name
    'clientStatus.status': The requested
    list key 'clientStatus.status' could
    not be resolved as a
    collection/array/map/enumeration/iterator
    type. Example: people or people.{name}</p>
  </blockquote>
  
  <p>Any ideas about what the problem could be?</p>
  
  <p><strong>Edit:</strong>
  I think the issue is that ClientStatus is null.  Since I simply instantiated a new Customer() its fields are null.  This is a bummer because it requires me to encode duplicate information in two parts of my program.  I can do something like this in the view:</p>
  
  <pre><code>  &lt;s:radio name="clientStatus.status"
         list="#{'NEW_CLIENT':'New Client',
                 'EXISTING_CLIENT':'Existing Client',
                 'RENEWAL':'Renewal'}"/&gt;
  </code></pre>
  
  <p>Or, in the controller, I have to explicitly instantiate the fields of Customer that my view needs.  This also dashes my hopes of writing a general action that can process all sorts of JAXB objects by simply instantiating a given JAXB class and making it available via getModel().</p>
  
  <p>Anyone have any ideas of how to recover from this unfortunate state of affairs?</p>
  
  <p><strong>Edit 2:</strong> Fixed the first form to what I would expect to work.</p>