[BUG] Switch not working with enum

Community Driven Extensions Project
Post Reply
djmj
Posts: 400
Joined: 16 Dec 2011, 01:23

26 Sep 2014, 01:34

Switch is not working with implicit JSF enum support.
Nothing is renderd in example:

Code: Select all

public enum FooEnum
{
    A, B
}

public Bean
{
    private FooEnum = A;
}

Code: Select all

<pe:switch value="#{bean.fooEnum}" >
	<pe:case value="A">
		A
	</pe:case>
	<pe:case value="B">
		B
	</pe:case>
</pe:switch>
Primefaces: 11.0.0 RC2
Primefaces-Extension: 11.0.0
PrimeFaces-Mobile: 11.0
OmniFaces: 3.11
Jsf: Mojarra 2.3.8
Server: Glassfish 5.1.0

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

26 Sep 2014, 09:11

feel free to create a feature request + pull request ;)
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

man910
Posts: 2
Joined: 28 May 2014, 23:25

28 Nov 2017, 21:35

I was able to get around it by calling

Code: Select all

enum.name()
.

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

28 Nov 2017, 21:55

Yep that will turn the enum into a String. Good call.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

06 Dec 2017, 20:50

You can use p:importEnum..

https://www.primefaces.org/showcase/ui/ ... Enum.xhtml

Or I reported it on GitHub and I have proposed a fix to compare both Object equality and String equality...

https://github.com/primefaces-extension ... issues/513
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests