Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-94540

XWorkList objects unable to be accessed via Velocity templates

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Low
    • 7.19.20
    • 7.19.19
    • Server - Platform
    • None

    Description

      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

      Attachments

        Issue Links

          Activity

            People

              854eef6f5746 Kusal Kithul-Godage
              854eef6f5746 Kusal Kithul-Godage
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: