{"id":1386,"date":"2011-06-14T18:28:09","date_gmt":"2011-06-14T18:28:09","guid":{"rendered":"http:\/\/salientsoft.co.uk\/?p=1386"},"modified":"2011-06-14T18:29:03","modified_gmt":"2011-06-14T18:29:03","slug":"passing-an-enum-as-an-argument-to-a-jsf-2-el-method-expression","status":"publish","type":"post","link":"https:\/\/salientsoft.co.uk\/?p=1386","title":{"rendered":"Passing an enum as an argument to a JSF 2 EL method expression"},"content":{"rendered":"<p>It is useful to be able to pass an enum rather than a string value as this introduces additional error checking by JSF.<\/p>\n<p>JSF has a built in enum converter, so that all you need to do is pass a literal string which must then be one of the enum fields. JSF detects that the method argument is an enum and does the appropriate conversion and error checking. This will not occur until run time, but you will at the very least get a JSF error on your browser page and in the log, for example:-<\/p>\n<p><strong><em>javax.faces.el.EvaluationException: java.lang.IllegalArgumentException:       <br \/>&#160;&#160; <\/em><\/strong><strong><em>No enum const class uk.co.salientsoft.view.Workspace$PageType.LOGOUT<\/em><\/strong><\/p>\n<p><strong><em><\/em><\/strong><\/p>\n<p>See <a href=\"http:\/\/stackoverflow.com\/questions\/3916871\/passing-a-enum-value-as-a-parameter-from-jsf\"><strong>here<\/strong><\/a> for the StackOverflow post detailing this issue&#160; &#8211; BalusC to the rescue again!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is useful to be able to pass an enum rather than a string value as this introduces additional error checking by JSF. JSF has a built in enum converter, so that all you need to do is pass a literal string which must then be one of the enum fields. JSF detects that the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[22],"tags":[184,16],"_links":{"self":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1386"}],"collection":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1386"}],"version-history":[{"count":1,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1386\/revisions"}],"predecessor-version":[{"id":1387,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1386\/revisions\/1387"}],"wp:attachment":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1386"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}