NullPointerException using h:selectOneRadio with an enum
--------------------------------------------------------

                 Key: MYFACES-3304
                 URL: https://issues.apache.org/jira/browse/MYFACES-3304
             Project: MyFaces Core
          Issue Type: Bug
    Affects Versions: 2.0.8
         Environment: Ubuntu 11.0.4, Jetty 6.1.10, JDK 1.6, Myfaces Core 2.0.8, 
Primefaces 3.0.M3
            Reporter: Joe Rossi
            Priority: Minor


Trying to use a h:selectOneRadio to select one of two values for an enum and it 
fails, throwing a NullPointerException. No explicit converter is in use so 
(from debugging) it appears to be using the default EnumConverter.

Code snippets in question are as follows:

testLovs.xhtml:


    <h:panelGrid columns="1">

      Simple radio button with constant string values
      <h:selectOneRadio id="l1" value="#{testLovsBean.l1}">
         <f:selectItem itemValue="A" itemLabel="labelA"/>
         <f:selectItem itemValue="B" itemLabel="labelB"/>
      </h:selectOneRadio>
      <h:outputText id="l1Str" value="l1: #{testLovBean.l1AsString}"/>

      <p:separator/>

      Radio button for enum
      <h:selectOneRadio id="l2" value="#{testLovsBean.l2}">
         <f:selectItem itemValue="#{VALUEA}" itemLabel="labelA"/>
         <f:selectItem itemValue="#{VALUEB}" itemLabel="labelB"/>
      </h:selectOneRadio>
      <h:outputText id="l2Str" value="l2: #{testLovBean.l2AsString}"/>

      <p:separator/>

      <p:commandButton id="commitCommand"
        action="#{testLovsBean.commitAction}"
        value="Submit"
        ajax="false"/>


TestLovsBean.java:


package tn.view.bean.test;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import tn.view.util.FacesUtils;

/**
 * Class used for testing date controls
 */
@Component
@Scope("request")
public class TestLovsBean
{
  public TestLovsBean()
  {
  }

  public String getL1()
  {
    return _l1;
  }

  public void setL1(String l1)
  {
    _l1 = l1;
  }

  public String getL1AsString()
  {
    return _l1;
  }

  public TestEnum getL2()
  {
    return _l2;
  }

  public void setL2(TestEnum l2)
  {
    _l2 = l2;
  }

  public String commitAction()
  {
    System.out.println("commitAction invoked");
    FacesUtils.addInfoMessage("L1: " + _l1);
    FacesUtils.addInfoMessage("L2: " + _l2);
    return null;
  }

  private String _l1;
  private TestEnum _l2;
}


TestEnum.java:

package tn.view.bean.test;

public enum TestEnum
{
  VALUEA,
  VALUEB,
}




--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to