0

Hi I have a spring bean named "connection" - how can I reference that explicitly in a SpEL expression from webflow - by explicitly I mean I don't want SpEL to try and find any other variables named "connection" which may exist in webflow scope - this is what I'm currently doing:

<action-state id="initialise-connection">
    <evaluate result="flowScope.initialisedConnection" expression="connection"/>

I've read about prefixing with "@" to only target beans - what is the right practice and how do I do it?

2 Answers2

0

The evaluate tag used to invoke a bean method or an execute() method inside subclass of Action class

For example if you define your own action, it should be initialized as @Component or defined as bean in your XML configuration file

@Component
public class MyAction {
   public Connection doSomething(RequestContext context){
    ...
   }
}

And in your flow definition XML file, you would simply call it like this

<evaluate result="flowScope.initialisedConnection" expression="myAction.doSomething( flowRequestContext)"/>

But if you defined a subclass of Action class, it will be like this

@Component
public class MyAction implements Action {

   @Override
   public Event execute(RequestContext context) {
     ...
   }
}

And in your flow definition XML file, you would call it like this

<evaluate result="flowScope.initialisedConnection" expression="myAction"/>
fujy
  • 5,168
  • 5
  • 31
  • 50
0

This is how I used to call a static method in a Class of mine. Please try this.

<action-state id="initialise-connection">
    <evaluate result="flowScope.initialisedConnection" expression="@com.app.connection.method()"/>
</acton>
Hbargujar
  • 360
  • 2
  • 4
  • 14