[BUG] Switch not working with enum

Community Driven Extensions Project
Post Reply
djmj
Posts: 383
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: 5.3
Primefaces-Extension: 4.0.0
Jsf: Mojarra 2.2.9
Server: Glassfish 4.1

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

26 Sep 2014, 09:11

feel free to create a feature request + pull request ;)
Always Bet On Prime (+ Extensions)!

Thomas Andraschko
PrimeFaces Developer | PrimeFaces Extensions Founder
Apache OpenWebBeans PMC | Apache DeltaSpike PMC | Apache MyFaces PMC

Personal Blog: http://tandraschko.blogspot.de/

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()
.

User avatar
Melloware
Posts: 390
Joined: 22 Apr 2013, 15:48

28 Nov 2017, 21:55

Yep that will turn the enum into a String. Good call.
PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 6.1.X / PF Extensions 6.1.5

User avatar
Melloware
Posts: 390
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 Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 6.1.X / PF Extensions 6.1.5

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest