XWorkList objects unable to be accessed via Velocity templates

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Low
    • 7.19.20
    • Affects Version/s: 7.19.19
    • Component/s: Server - Platform
    • None
    • Severity 3 - Minor

      Issue Summary

      Objects of type com.opensymphony.xwork.util.XWorkList class are inaccessible from Velocity templates.

      Steps to Reproduce

      1. Define a public getter getMyList() on your Action class which returns an XWorkList
      2. Call that getter and access a list item in your Velocity template using $myList.get(0) or $action.myList.get(0)

      Expected Results

      Return value displayed

      Actual Results

      Velocity error logged

      Workaround

      Define an alternative getter which returns a wrapped delegating instance of the XWorkList.

      public class MyAction extends ConfluenceActionSupport {
          private XWorkList<Type> xworkList;
      
          public List<Type> getWrappedList() {
              return new ListWrapper<>(xworkList);
          }
      }
      public class ListWrapper<T> implements List<T> {
          private final List<T> delegate;
      
          public ListWrapper(List<T> delegate) {
              this.delegate = delegate;
          }
          
          // Implement interface methods that call delegate
      } 

      then access the wrapped instance in your Velocity template using:
      $wrappedList or $action.wrappedList

            Assignee:
            Kusal Kithul-Godage
            Reporter:
            Kusal Kithul-Godage
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: