0

According to this answer: https://stackoverflow.com/a/8229982/988145 , JSF should auto-convert enums. For some reason, it doesn't. I'm getting the following error:

"Type of FrequencyConversion Error setting value 'DAY_OF_WEEK' for 'null Converter'."

My enum:

public enum FrequencyType implements Serializable
{
    DAY_NUMBER, DAY_OF_WEEK
}

Select markup:

<h:selectOneMenu onchange="toggleFrequencyTypes(this);" 
         value="#{cellContentsBean.pillSheetProfile.frequency}" 
         class="form-control" id="frequencyTypeDd">
    <f:selectItems value="#{cellContentsBean.frequencyTypes}" />
</h:selectOneMenu>

Frequency types getter in the bean:

public FrequencyType[] getFrequencyTypes() {
    return FrequencyType.values();
}

Setters:

private FrequencyType frequencyType;

/**
 * @return the frequencyType
 */
public FrequencyType getFrequencyType()
{
    return frequencyType;
}

/**
 * @param frequencyType the frequencyType to set
 */
public void setFrequencyType(FrequencyType frequencyType)
{
    this.frequencyType = frequencyType;
}

I've even added a converter to my faces config as another thread suggests, but it did nothing:

<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.2"
              xmlns="http://java.sun.com/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_2.xsd">
    <application>
        <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>

        <converter>
            <converter-for-class>java.lang.Enum</converter-for-class>
            <converter-class>javax.faces.convert.EnumConverter</converter-class>
        </converter>
    </application>
</faces-config>
Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Creature
  • 994
  • 1
  • 12
  • 27
  • Please consider providing arbitrary version information and a [mcve]. For example the target for `#{cellContentsBean.pillSheetProfile.frequency}` is not defined in your question. – Selaron Jun 24 '19 at 06:27

1 Answers1

1

While this likely won't solve your problem, I have to note that your faces-config.xml is kind of broken:

  1. The JSF Namespaces you declared do not exist this way.
  2. Wrong nesting of elements: converter element is not a child of application element.

Better try this:

<?xml version='1.0' encoding='UTF-8'?>
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
         http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
    version="2.2">
    <application>
        <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
    </application>

    <converter>
        <converter-for-class>java.lang.Enum</converter-for-class>
        <converter-class>javax.faces.convert.EnumConverter</converter-class>
    </converter>
</faces-config>
Selaron
  • 6,105
  • 4
  • 31
  • 39