Class StrutsUtil

java.lang.Object
org.apache.struts2.util.StrutsUtil

public class StrutsUtil extends Object
Struts base utility class, for use in Velocity and Freemarker templates
  • Field Details

    • LOG

      protected static final org.apache.logging.log4j.Logger LOG
    • request

      protected jakarta.servlet.http.HttpServletRequest request
    • response

      protected jakarta.servlet.http.HttpServletResponse response
    • classes

      protected Map<String,Class<?>> classes
    • stack

      protected ValueStack stack
  • Constructor Details

    • StrutsUtil

      public StrutsUtil(ValueStack stack, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
  • Method Details

    • bean

      public Object bean(Object name) throws Exception
      Throws:
      Exception
    • isTrue

      public boolean isTrue(String expression)
    • findString

      public Object findString(String name)
    • include

      public String include(Object aName) throws Exception
      Throws:
      Exception
    • urlEncode

      public String urlEncode(String s)
    • buildUrl

      public String buildUrl(String url)
    • findValue

      public Object findValue(String expression, String className) throws ClassNotFoundException
      Throws:
      ClassNotFoundException
    • findValue

      public Object findValue(String expr, Object context)
    • getText

      public String getText(String text)
    • getContext

      public String getContext()
    • translateVariables

      public String translateVariables(String expression)
    • makeSelectList

      public List<ListEntry> makeSelectList(String selectedList, String list, String listKey, String listValue)
      the selectedList objects are matched to the list.listValue

      listKey and listValue are optional, and if not provided, the list item is used

      Parameters:
      selectedList - the name of the action property that contains the list of selected items or single item if its not an array or list
      list - the name of the action property that contains the list of selectable items
      listKey - an ognl expression that is exaluated relative to the list item to use as the key of the ListEntry
      listValue - an ognl expression that is exaluated relative to the list item to use as the value of the ListEntry
      Returns:
      a List of ListEntry
    • toInt

      public int toInt(long aLong)
    • toLong

      public long toLong(int anInt)
    • toLong

      public long toLong(String aLong)
    • toString

      public String toString(long aLong)
    • toString

      public String toString(int anInt)
    • toStringSafe

      public String toStringSafe(Object obj)