org.apache.struts2.util
Class StrutsUtil

java.lang.Object
  extended by org.apache.struts2.util.StrutsUtil
Direct Known Subclasses:
VelocityStrutsUtil

public class StrutsUtil
extends java.lang.Object

Struts base utility class, for use in Velocity and Freemarker templates


Field Summary
protected  java.util.Map classes
           
protected static Logger LOG
           
protected  OgnlTool ognl
           
protected  javax.servlet.http.HttpServletRequest request
           
protected  javax.servlet.http.HttpServletResponse response
           
protected  ValueStack stack
           
 
Constructor Summary
StrutsUtil(ValueStack stack, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 
Method Summary
 java.lang.Object bean(java.lang.Object aName)
           
 java.lang.String buildUrl(java.lang.String url)
           
 java.lang.Object findString(java.lang.String name)
           
 java.lang.Object findValue(java.lang.String expression, java.lang.String className)
           
 java.lang.String getContext()
           
 java.lang.String getText(java.lang.String text)
           
 java.lang.String include(java.lang.Object aName)
           
 java.lang.String include(java.lang.Object aName, javax.servlet.http.HttpServletRequest aRequest, javax.servlet.http.HttpServletResponse aResponse)
          Deprecated. the request and response are stored in this util class, please use include(string)
 boolean isTrue(java.lang.String expression)
           
 java.util.List makeSelectList(java.lang.String selectedList, java.lang.String list, java.lang.String listKey, java.lang.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

 int toInt(long aLong)
           
 long toLong(int anInt)
           
 long toLong(java.lang.String aLong)
           
 java.lang.String toString(int anInt)
           
 java.lang.String toString(long aLong)
           
 java.lang.String urlEncode(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final Logger LOG

request

protected javax.servlet.http.HttpServletRequest request

response

protected javax.servlet.http.HttpServletResponse response

classes

protected java.util.Map classes

ognl

protected OgnlTool ognl

stack

protected ValueStack stack
Constructor Detail

StrutsUtil

public StrutsUtil(ValueStack stack,
                  javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
Method Detail

bean

public java.lang.Object bean(java.lang.Object aName)
                      throws java.lang.Exception
Throws:
java.lang.Exception

isTrue

public boolean isTrue(java.lang.String expression)

findString

public java.lang.Object findString(java.lang.String name)

include

public java.lang.String include(java.lang.Object aName)
                         throws java.lang.Exception
Throws:
java.lang.Exception

include

public java.lang.String include(java.lang.Object aName,
                                javax.servlet.http.HttpServletRequest aRequest,
                                javax.servlet.http.HttpServletResponse aResponse)
                         throws java.lang.Exception
Deprecated. the request and response are stored in this util class, please use include(string)

Throws:
java.lang.Exception

urlEncode

public java.lang.String urlEncode(java.lang.String s)

buildUrl

public java.lang.String buildUrl(java.lang.String url)

findValue

public java.lang.Object findValue(java.lang.String expression,
                                  java.lang.String className)
                           throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

getText

public java.lang.String getText(java.lang.String text)

getContext

public java.lang.String getContext()

makeSelectList

public java.util.List makeSelectList(java.lang.String selectedList,
                                     java.lang.String list,
                                     java.lang.String listKey,
                                     java.lang.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(java.lang.String aLong)

toString

public java.lang.String toString(long aLong)

toString

public java.lang.String toString(int anInt)


Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.