If instead I used my own method to return the array of Enum Values, it doesn't throw the validation error, and works fine.
I think it should work in both cases, is this defect? PF (5.3)
Code: Select all
<pe:importEnum var="GraphDayOrMonth"
type="portal.common.GraphDateRangeType" allSuffix="ALL_ENUM_VALUES" />
<p:selectOneMenu id="periodUsageDropdown" converter="enumConverter"
value="${connectivityUsageController.currentRangeType}">
<p:ajax listener="#{connectivityUsageController.changeGraphrange}"
update='updateHistory' immediate="true" process="@this" />
<f:selectItem noSelectionOption="true"
itemLabel="Select Daily or Monthly" />
<!--Works-->
<f:selectItems
value="#{connectivityUsageController.graphDateRangeTypes}" />
<!--Doesn't work -->
<f:selectItems value="#{GraphDateRangeType.ALL_ENUM_VALUES}" />
</p:selectOneMenu>
Code: Select all
public GraphDateRangeType[] getGraphDateRangeTypes(){
return GraphDateRangeType.values();
}
Code: Select all
public enum GraphDateRangeType {
Monthly, Daily
}
Code: Select all
public class GraphDateTypeConverter extends EnumConverter {
private static Logger log = Logger.getLogger(ConnectivityUsageController.class);
public GraphDateTypeConverter() {
super(GraphDateRangeType.class);
}
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
Object asObject = super.getAsObject(context, component, value);
return asObject;
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
return super.getAsString(context, component, value);
}
}