2

According to s2-026:

Support for expression using top will be dropped in upcoming Struts version 2.5!

We used the top object in lots of JSP pages as below (which shows a list of currencyTypes and look up the name from Struts messages):

<s:select name = "selectedCurrencyType" 
          list = "currencyTypes"
       listKey = "top" 
     listValue = "%{getText('acc.currencyType.'+top)}" />

It currently works with struts 2.3.24.1 but according to above comment, will above select box works for 2.5, or we will not have the top reference any more?!

If this is true, please let me know how should we fix above s:select?!

Roman C
  • 49,761
  • 33
  • 66
  • 176
Alireza Fattahi
  • 42,517
  • 14
  • 123
  • 173

2 Answers2

3

Support for top object was added to support internal operations, it shouldn't be used by users (yes, expressing that in docs was a bad idea :( )

Anyway, looks like we must prepare a migration path or keep support for the top object.

Lukasz Lenart
  • 987
  • 7
  • 14
1

What I found in this documentation and what I use in my example Passing parameters to action through ModelDriven in Struts 2 the top object is a element of the CompaundRoot. And this class has a cutStack() method that is mentioned in

With expression like [0] ... [3] etc. Struts 2 will cut the stack and still return back a CompoundRoot object. To get the top of that particular stack cut, use 0.top.

The last expression is a typo for [xxx].top where xxx is the index of the CompoundRoot object. And this object could be referenced as [xxx]. It is a top object cut to the xxx index.

Community
  • 1
  • 1
Roman C
  • 49,761
  • 33
  • 66
  • 176