Spring Web Flow: How to call static method from <evaluate />?
Asked Answered
B

2

5

I need to call static method of org.hibernate.Hibernate class. How to do that in element of flow ?

Bashan answered 23/11, 2010 at 10:19 Comment(2)
Can you elaborate more in detail?Alacrity
@Mohamed Saligh: More details - I have Product entity with list of images, that are lazy initialized. In a flow (on entry some view) i need to initialize images by calling org.hibernate.Hibernate.initialize() static method. How to do that ?Bashan
B
14

You can use the following Spring EL construct to evaluate static methods:

<evaluate expression="T(org.hibernate.Hibernate).initialize(yourObject)"/>

See the appropriate Spring EL reference part:

http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/expressions.html#expressions-types

Barouche answered 25/11, 2010 at 10:49 Comment(0)
E
0

spring-webflow 2 uses OGNL expressions. OGNL allows for static referencing of fields and methods. To utilize it you would want to use the '@' notations.

First you reference the class (with package). You would want to put an @ before the package and class name and an @ before the method call. With hibernate it would look like

<evaluate expression="@org.hibernate.Hibernate@initialize()"/>
Evesham answered 23/11, 2010 at 15:42 Comment(1)
It doesn't work. I get parse error: org.springframework.expression.spel.SpelParseException: EL1041E:(pos 24): After parsing a valid expression, there is still more data in the expression: 'bean_ref(@)'Bashan

© 2022 - 2024 — McMap. All rights reserved.