3

I have a bean

<bean name="api.HelloWorld" class="ru.example.api.HelloWorld"/>

When you call in flow I get an error.

<evaluate expression="api.HelloWorld.test()"/>

How to call?

1 Answers1

1

If you are using SpEL, you can use this:

<evaluate expression="@'api.HelloWorld'.test()"/>

if you are using OGNL or jboss-el, I don't think it can be done other than using a utility class, like this:

@Component
public class WebFlowUtil {

    @Autowired
    private ApplicationContext applicationContext;

    public Object getBean(String beanName) {
        return applicationContext.getBean(beanName);
    }
}

then use:

<evaluate expression="webFlowUtil.getBean('api.HelloWorld').test()"/>
rptmat57
  • 3,643
  • 1
  • 27
  • 38
  • ERROR: SEVERE: Servlet.service() for servlet spring threw exception ognl.ParseException: Encountered " "\'" "\'api.HelloWorld\' "" at line 1, column 2. Was expecting one of: "@" ... ... at ognl.OgnlParser.generateParseException(OgnlParser.java:3172) at ognl.OgnlParser.jj_consume_token(OgnlParser.java:3051) – user5809756 May 04 '16 at 06:43
  • did you escape the single quotes? – rptmat57 May 04 '16 at 12:04
  • anyway, it looks like you are using OGNL so I don't think it will work, as I stated in my answer – rptmat57 May 04 '16 at 12:04
  • added a workaround that should work with OGNL and jboss-el (tested with jboss-el) – rptmat57 May 04 '16 at 12:14