I need to call static method of org.hibernate.Hibernate class. How to do that in element of flow ?
Spring Web Flow: How to call static method from <evaluate />?
Asked Answered
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
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:
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()"/>
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.