1

As the title states, I'm having issues rendering static values via EL 3 in JSF.

There's a similar issue like mine but it's in JSP and there was a workaround (see this Access static property or method in JSP via EL 3.0 (JEE7; Tomcat 8) )

The issue is nothing is being rendered when I use something as simple as this in any of my .xhtml files

#{Boolean.TRUE}

Although this site https://java.net/projects/el-spec/pages/StaticField says the following would work.

#{T(java.lang.Boolean).TRUE}

It also failed with an error similar to

javax.el.ELException: Function 'T' not found

I've gone ahead and tried the workaround that was mentioned in Access static property or method in JSP via EL 3.0 (JEE7; Tomcat 8). The workaround, which worked for JSP guys, is to replace the jsp-api.jar with javax.servlet.jsp-api-2.3.2-b01.jar in their Tomcat lib. This DIDN'T work for me either :(

What does work for me is the standalone implementation, like so

ELProcessor elp = new ELProcessor(); Object ret = elp.eval("Boolean.FALSE"); getLog().info("Output Value: " + ret);

And I do get the correct output like so

2015-10-07 17:38:13 INFO WelcomeAction:38 - Output Value: false

I've tried with both true and false value and they worked fine. Not sure if this info will help, but I'm using spring 4.1.1 with webflow 2.4.1. I've also tried on two different tomcat instances 8.0.14 and 8.0.27 and neither worked.

There's no way that I'm the only one dealing with this. I have yet to find a bug report regarding this, although one was reported and solved for JSP https://java.net/jira/browse/GLASSFISH-20778

Would really appreciate some help right about meow. Thanks in advance. Aloha!

Community
  • 1
  • 1
Molasses
  • 661
  • 9
  • 12

1 Answers1

3

The issue is nothing is being rendered when I use something as simple as this in any of my .xhtml files

#{Boolean.TRUE}

Unfortunately, that works in JSP only via ${Boolean.TRUE}, not in Facelets.


Although this site https://java.net/projects/el-spec/pages/StaticField says the following would work.

#{T(java.lang.Boolean).TRUE}

That site contains only proposals/prototypes. The final implementation is indeed done differently. For the final implementation, read EL 3.0 specification document instead.


Basically, the change needs to be done in Facelets side, not in EL side. EL 3.0 provides support for static fields, but Facelets simply isn't utilizing it. Even the EL 3.0 import handler after all doesn't work in Facelets. It's likely an oversight. I've pinged the JSF EG on this.

In the meanwhile, your best bet is to create a custom taghandler which does the job. JSF utility library OmniFaces has exactly such taghandler in its assortiment, the <o:importConstants>.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • You mentioned OmniFaces' importConstants, so I decided to look if PrimeFaces had something similar since it's something I'm already using. They do! Well PrimeFaces Extensions does (which I'm also using). So something like `` works and I don't have to download another library. This workaround is good for now :) – Molasses Oct 08 '15 at 21:24