humbletrader
humbletrader

Reputation: 414

can spring webflow handle a dynamic expression inside "evaluate" tag?

I see that in spring webflow you can use dynamic expression for the view

<view-state id="error" view="error-#{externalContext.locale}.xhtml" />

Can I do the same for evaluate ? Something like:

 <evaluate expression="#{variable}Controller.processData()" />

Thanks in advance for your help.

Upvotes: 1

Views: 179

Answers (2)

humbletrader
humbletrader

Reputation: 414

Let me answer my own question: No, that's not possible. According to the xsd of spring webflow:

<xsd:attribute name="expression" type="expression" use="required">

where

<xsd:simpleType name="expression">
    <xsd:restriction base="xsd:string"/>
</xsd:simpleType>

<xsd:simpleType name="template">
    <xsd:restriction base="xsd:string"/>
</xsd:simpleType>

According to the documentation the expression should have been of type "template" so that it is evaluated.

Upvotes: 0

rptmat57
rptmat57

Reputation: 3787

Here is an idea:

<evaluate expression="webFlowUtil.getBean(variable.concat('Controller'))" result="flowScope.controller"/>

with

@Component
public class WebFlowUtil {

    @Autowired
    private ApplicationContext applicationContext;

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

then later use

<evaluate expression="controller.processData()" />

Upvotes: 1

Related Questions