From the course: Java EE 8: JavaServer Faces JSF 2.3

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Enums and Java 8 Date-Time in JSF 2.3

Enums and Java 8 Date-Time in JSF 2.3

From the course: Java EE 8: JavaServer Faces JSF 2.3

Start my 1-month free trial

Enums and Java 8 Date-Time in JSF 2.3

- [Instructor] It used to be that enums in your Facelets page required workaround code. Then when you needed to use any of the Java 8 DateTime classes like localDateTime, and zonedDateTime, you needed a different workaround to manually handle the conversion. That ends here. JSF 2.3 comes with native support for both enums and many varieties of fancy date and time handling. I'll show you how it's done. For enums, it's very straightforward. Use the new f:importConstants tag as I've done here on line 12. Note that the enum component tag is inside of the f:metadata tag. See as I have it here on line 11 and line 13, wrap the f:importConstant component. What I've now done here on line 12 is to import the enum class ConstantHolder specifying the fully qualified class name into this page. Here's the enum class. You can see here's an enum and has four possible values. With this import, I'm then able to refer to…

Contents