Announcement Announcement Module
Collapse
No announcement yet.
Storing and reusing a referenced variable in a SPEL expression Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Storing and reusing a referenced variable in a SPEL expression

    Hi,

    I'm fairly new to SPEL, so maybe this is simple to do and I'm just missing something, but what I need to do is something akin to this (yes, I know this syntax is not valid):

    children.^[value=='rootChild1']?.(#this.value1?:0 + #this.value2?:0)

    as a shorthand for this:

    children.^[value=='rootChild1']?.value1?:0 + children.^[value=='rootChild1']?.value2?:0

    The reason being that in my use case it is expensive to repeatedly retrieve fields (which may be nested quite deep in the graph), so I need a way to 'store' the field in order to interrogate it more than once. It would also help make some of my expressions more succinct.

    Is this even doable? FWIW, I need to include everything in the one expression, as this is being used in a templating engine, so I can't do things like execute multiple sequential steps.

    Thanks.
Working...
X