简体   繁体   中英

JSF2 and GAE: Passing parameter with Method Expression

I followed the tutorial by Google and included el-api-2.2.jar and el-impl-2.2.jar to WEB-INF/lib . My test case is simple:

<f:view contentType="text/html">
  <h:form id="f1">
    <p:commandLink action="#{parameterBean.test(myString)}">
      <h:outputText value="test"/>
    </p:commandLink>
  </h:form>
</f:view>

The action method is just a public void test(String s) {log.log(Level.INFO, "T: "+s);} . I The log shows (during initial rendering of the page):

javax.faces.view.facelets.TagAttributeException: /jsf/admin/test/parameter.xhtml
@15,62 action="#{parameterBean.test('myString')}" Error Parsing:
#{parameterBean.test('myString')}
...
Caused by: javax.el.ELException: Error Parsing: #{parameterBean.test('myString')}
...
Caused by: org.apache.el.parser.ParseException: Encountered " "(" "( ""
at line 1, column 21.
  Was expecting one of: "}" "." "[" ">" ...

I think this error is GAE specific and I'm wondering where org.apache.el.parser comes into the game, since the el-libs provide the following packages:

  • el-api-2.2.jar : javax.el.*
  • el-impl-2.2.jar : com.sun.el.*

Note During investigation of this problem I checked the Unified Expression Language web site (given in the tutorial) again and only found el-api-1.1.jar and el-impl-1.1.jar as the latest versions. The error stays the same.

You can use the `jboss-el.jar' for that purpose

Here.. take a look at issue opened on google about it

Inability to use EL API 2.2

just put jboss-el.jar (of jboss seam 2) in the lib folder

and add this line in your web.xml

<context-param>
    <param-name>com.sun.faces.expressionFactory</param-name>
    <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>

can't find the direct link to jar at the moment... I guess a bit of googleing required

found this for now.... http://www.seamframework.org/Seam2/Downloads

Edit

Just noticed its an old thread...

anyway I think you can get the right one from here Download jboss-el.jar

Normally the web application servlet class loader loads the classes in the following order:

  1. WEB-INF/classes
  2. WEB-INF/lib/*.jar
  3. other classes from the servlet container.

Unfortunately, for security reasons, Google has a messed up non Servlet conformant class loader on their GAE, and their classes have priority over the classes you might have in the jars from your WEB-INF/lib or your own WEB-INF/classes.

Since GAE bundles EL 1.1 you are stucked with it until google decides to update their GAE version - don't hold your breath though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM