Import Enums allSuffix not working

Community Driven Extensions Project
Post Reply
kirenpillay
Posts: 3
Joined: 03 Feb 2016, 16:13

06 Oct 2016, 14:49

When using importEnum with allSuffix in a selectOneMenu, I kept getting the validation Error "Validation Error: Value is not valid".
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>
Getter:

Code: Select all

      public GraphDateRangeType[] getGraphDateRangeTypes(){
		return GraphDateRangeType.values();
	}
Enum:

Code: Select all

public enum GraphDateRangeType {
	Monthly, Daily
}
Converter

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);
	}

}

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

07 Oct 2016, 18:12

importEnums was moved to PF, so try this.
If it doesn't work, feel free to create a issue + maybe a PR.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 20 guests