com.scooterframework.web.util
Class W

java.lang.Object
  extended by com.scooterframework.web.util.W

public class W
extends java.lang.Object

W(WebHelper) class has helper methods for web related requests, including AJAX requests.

buttonKeys supported:
disabled, name, type, value, id, class, title, style, dir, lang, accesskey, tabindex, onblur, onclick, ondblclick, onfocus, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup

imageKeys supported:
align (deprecated in HTML4.01, not supported in XHTML 1.0 Strict DTD), alt, border (deprecated in HTML4.01, not supported in XHTML 1.0 Strict DTD), class, dir, height, hspace (deprecated in HTML4.01, not supported in XHTML 1.0 Strict DTD), id, ismap, lang, longdesc, name, onclick, ondblclick, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, src, style, title, usemap, vspace (deprecated in HTML4.01, not supported in XHTML 1.0 Strict DTD), width,

inputKeys supported:
disabled, name, type, value, id, class, title, style, dir, lang, accesskey, tabindex, onblur, onclick, ondblclick, onfocus, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onselect, onchange

linkKeys supported:
accesskey, charset, class, coords, dir, hreflang, id, lang, name, onblue, onclick, ondblclick, onfocus, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, rel, rev, shape, tabindex, target, title, type

AJAX related links are supported through data-* keys:

   data-ajax: Its value is always true. This is the required property for AJAX.
   data-confirm: A confirmation message to be popped up
   data-method: HTTP method (GET, POST, UPDATE, DELETE) of AJAX link, "GET" is the default.
   data-target: The target element in jQuery syntax, e.g. #posts_list.
   data-handler: indicates how the returned message is handled, e.g. html.
   data-type: The type of data expected from the server. See jQuery document.
 


Field Summary
static java.util.List<java.lang.String> buttonKeys
           
static java.util.List<java.lang.String> html5Keys
           
static java.util.List<java.lang.String> imageKeys
           
static java.util.List<java.lang.String> inputKeys
           
static java.util.List<java.lang.String> linkKeys
           
static com.petebevin.markdown.MarkdownProcessor mp
           
static java.lang.String noLinkOnCurrentUri
          Key to embed in linkProperties map or string in order not to show a link on a label when the current uri is the same as the action path.
static java.lang.String noLinkOnEmptyQueryString
          Key to embed in linkProperties map or string in order not to show a link on a label.
static java.util.List<java.lang.String> styleKeys
           
 
Constructor Summary
W()
           
 
Method Summary
static java.lang.String buttonLink(java.lang.String face, java.util.Map<java.lang.String,java.lang.String> buttonProperties, java.lang.String actionPath, java.util.Map<java.lang.String,java.lang.String> linkProperties)
          Returns a url link on a button.
static java.lang.String buttonLink(java.lang.String face, java.lang.String buttonProperties, java.lang.String actionPath)
          Returns a url link on a button.
static java.lang.String buttonLink(java.lang.String face, java.lang.String buttonProperties, java.lang.String actionPath, java.lang.String linkProperties)
          Returns a url link on a button.
static java.lang.String buttonTag(java.lang.String face)
          Returns a button tag.
static java.lang.String buttonTag(java.lang.String face, java.util.Map<java.lang.String,java.lang.String> buttonProperties)
          Returns a button tag.
static java.lang.String buttonTag(java.lang.String face, java.lang.String buttonProperties)
          Returns a button tag.
static java.lang.String checkCheckbox(java.lang.String value, java.lang.String choice)
          Returns a html segment for checked choice.
static java.lang.String checkSelect(java.lang.String value, java.lang.String choice)
          Returns a html segment for selected choice.
static java.lang.Object context(java.lang.String key)
          Returns an object associated with the key in context scope.
static java.lang.String convertButtonPropertiesToString(java.util.Map<java.lang.String,java.lang.String> properties)
          Converts a button properties map to string.
static java.lang.String convertImagePropertiesToString(java.util.Map<java.lang.String,java.lang.String> properties)
          Converts an image properties map to string.
static java.lang.String convertInputPropertiesToString(java.util.Map<java.lang.String,java.lang.String> properties)
          Converts a input properties map to string.
static java.lang.String convertLinkPropertiesToString(java.util.Map<java.lang.String,java.lang.String> properties)
          Converts a link properties map to string.
static java.lang.String currentCycle(java.lang.String name)
          Returns current item in the named cycle.
static java.lang.String cycle(java.lang.String items)
          Returns an item from a list items.
static java.lang.String cycle(java.lang.String items, java.lang.String name)
          Returns an item from a list items.
static java.lang.String decode(java.lang.String s)
          Returns a url-decoded string.
static java.lang.String displayHtmlSelect(java.lang.String name, java.util.List<java.lang.Object> dataList, java.lang.String options)
          Returns html select code of a list of data and options.
static java.lang.String displayHtmlSelect(java.lang.String name, java.lang.String dataListKey, java.lang.String options)
           
static void doForward(java.lang.String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
static java.lang.String encode(java.lang.String s)
          Returns a url-encoded string.
static java.lang.String errorMessage(java.lang.String model)
          Returns a div block containing all the error messages for the object located as an instance variable by the name of model.
static java.lang.String errorMessage(java.lang.String model, java.util.Properties options)
          Returns a div block containing all the error messages for the object located as an instance variable by the name of model.
static java.lang.Object get(java.lang.String key)
          Returns an object associated with the key.
static java.lang.Object get(java.lang.String key, java.lang.Object def)
          Returns an object associated with the key.
static java.lang.String getContextName()
          Returns context name of the webapp.
static java.lang.String getContextPath()
          Returns context path of a http request.
static java.lang.String getCurrentControllerPath()
          Returns controller path associated with the servlet request.
static java.lang.String getDocumentRoot()
          Returns document root of a http request.
static javax.servlet.http.HttpServletRequest getHttpRequest()
          Returns http servlet request instance.
static java.lang.String getPureURLString(java.lang.String url)
          Returns non-query string portion of an url.
static java.lang.String getQueryString(java.lang.String url)
          Returns query string portion of an url.
static java.lang.String getRealPath()
          Returns real path of the http servlet context.
static java.lang.String getURL(java.lang.String actionPath)
          Returns a url.
static java.lang.String getURL(java.lang.String actionPath, java.util.Map<java.lang.String,java.lang.String> options)
          Returns a url.
static java.lang.String getURL(java.lang.String actionPath, java.lang.String options)
          Returns a url.
static java.lang.Object global(java.lang.String key)
          Returns an object associated with the key in global scope.
static java.lang.String h(java.lang.String s)
          A short-hand alias of htmlEsacpe method.
static java.lang.String htmlEsacpe(java.lang.String s)
          Removes the following html unfriendly characters from the input string:
double quote("), single quote('), lower than(<), greater than(>), and &.
static java.lang.String imageLink(java.lang.String imageSrc, java.util.Map<java.lang.String,java.lang.String> imageProperties, java.lang.String actionPath, java.util.Map<java.lang.String,java.lang.String> linkProperties)
          Returns a url link on an image.
static java.lang.String imageLink(java.lang.String imageSrc, java.lang.String imageProperties, java.lang.String actionPath)
          Returns a url link on an image.
static java.lang.String imageLink(java.lang.String imageSrc, java.lang.String imageProperties, java.lang.String actionPath, java.lang.String linkProperties)
          Returns a url link on an image.
static java.lang.String imageTag(java.lang.String imageSrc)
          Returns an image tag.
static java.lang.String imageTag(java.lang.String imageSrc, java.util.Map<java.lang.String,java.lang.String> imageProperties)
          Returns an image tag.
static java.lang.String imageTag(java.lang.String imageSrc, java.lang.String imageProperties)
          Returns an image tag.
static boolean isEmpty(java.lang.Object object)
          Checks whether the object is empty.
static boolean isEmpty(java.lang.Object object, java.lang.String property)
          Checks whether the object has property that is empty.
static boolean isEmpty(java.lang.String key, java.lang.String property)
          Checks whether the object represented by the key has property that is empty.
static boolean isEqual(java.lang.Object object, java.lang.Object desired)
          Checks whether the object has the same value as the desired value.
static boolean isEqual(java.lang.Object object, java.lang.String property, java.lang.Object desired)
          Checks whether the Object's property has the same value as the desired value.
static boolean isEqual(java.lang.String key, java.lang.String property, java.lang.Object desired)
          Checks whether the Object represented by the key has property value that is equal to the desired value.
static boolean isGreaterThan(java.lang.Object object, java.lang.Object desired)
          Checks whether the object value is greater than the desired value.
static boolean isGreaterThan(java.lang.Object object, java.lang.String property, java.lang.Object desired)
          Checks whether the Object's property value is greater than the desired value.
static boolean isGreaterThan(java.lang.String key, java.lang.String property, java.lang.Object desired)
          Checks whether the Object represented by the key has property value that is greater than the desired value.
static boolean isGreaterThanOrEqual(java.lang.Object object, java.lang.Object desired)
          Checks whether the object value is greater than or equal to the desired value.
static boolean isGreaterThanOrEqual(java.lang.Object object, java.lang.String property, java.lang.Object desired)
          Checks whether the Object's property value is greater than or equal to the desired value.
static boolean isGreaterThanOrEqual(java.lang.String key, java.lang.String property, java.lang.Object desired)
          Checks whether the Object represented by the key has property value that is greater than or equal to the desired value.
static boolean isLessThan(java.lang.Object object, java.lang.Object desired)
          Checks whether the object value is less than the desired value.
static boolean isLessThan(java.lang.Object object, java.lang.String property, java.lang.Object desired)
          Checks whether the Object's property value is less than the desired value.
static boolean isLessThan(java.lang.String key, java.lang.String property, java.lang.Object desired)
          Checks whether the Object represented by the key has property value that is less than the desired value.
static boolean isLessThanOrEqual(java.lang.Object object, java.lang.Object desired)
          Checks whether the object value is less than or equal to the desired value.
static boolean isLessThanOrEqual(java.lang.Object object, java.lang.String property, java.lang.Object desired)
          Checks whether the Object's property value is less than or equal to the desired value.
static boolean isLessThanOrEqual(java.lang.String key, java.lang.String property, java.lang.Object desired)
          Checks whether the Object represented by the key has property value that is less than or equal to the desired value.
static boolean isLocalRequest()
          Checks if the request is a local request.
static boolean isPresent(java.lang.String key)
          Checks whether there is data represent by the key string in a scope.
static boolean isPresent(java.lang.String key, java.lang.String scope)
          Checks whether there is data represent by the key string in a specific scope.
static java.lang.String javascriptLink(java.lang.String javascriptFileName)
          Returns a link to a javascript file.
static java.lang.String label(java.lang.String key)
          Returns label value stored in a property file based on user's current locale.
static java.lang.String labelLink(java.lang.String label, java.lang.String actionPath)
          Returns a url link on a label.
static java.lang.String labelLink(java.lang.String label, java.lang.String actionPath, java.util.Map<java.lang.String,java.lang.String> linkProperties)
          Returns a url link with query strings on a label.
static java.lang.String labelLink(java.lang.String label, java.lang.String actionPath, java.lang.String linkProperties)
          Returns a url link on a label.
static java.lang.String labelLinkForRecord(java.lang.String label, java.lang.String actionPath, ActiveRecord record)
          Returns a url link on a label related to a record.
static java.lang.String labelLinkForRecord(java.lang.String label, java.lang.String actionPath, ActiveRecord record, java.lang.String linkProperties)
          Returns a url link on a label related to a record.
static java.lang.String markdown(java.lang.String text)
          Returns html text converted by Markdown.
static java.lang.String message(java.lang.String messageKey)
          Returns a message associated with the messageKey.
static java.lang.String message(java.lang.String messageKey, java.util.Locale locale)
          Returns a message associated with the messageKey in the specific locale.
static java.lang.String message(java.lang.String messageKey, java.util.Locale locale, java.lang.Object[] values)
          Returns a message associated with the messageKey and the values in a specific locale.
static java.lang.String message(java.lang.String messageKey, java.lang.Object[] values)
          Returns a message associated with the messageKey and the values.
static java.lang.String message(java.lang.String messageKey, java.lang.String language)
          Returns a message associated with the messageKey in the specific language.
static java.lang.String message(java.lang.String messageKey, java.lang.String language, java.lang.String country)
          Returns a message associated with the messageKey in the specific language of the specific country.
static java.lang.String message(java.lang.String messageKey, java.lang.String language, java.lang.String country, java.lang.String variant)
          Returns a message associated with the messageKey in the specific language of the specific country's particular variant.
static java.lang.String nl2br(java.lang.String text)
          Returns a string formatted for html display by adding "
"
after each occurance of newlines "\n" in a string.
static java.lang.String pageLink(int pageNumber, java.lang.String pageTitle, java.lang.String actionPath, java.lang.String queryString)
          Returns a url link for a page in pagination.
static java.lang.String pageLink(java.lang.String label, java.lang.String actionPath, java.lang.String queryString)
          Returns a url link for a page in pagination.
static java.lang.String pageLink(java.lang.String label, java.lang.String actionPath, java.lang.String queryString, java.lang.String linkProperties)
          Returns a url link for a page in pagination.
static java.lang.String paginationLinks(Paginator paginator, java.lang.String actionPath)
          Returns a string of pagination page links.
static java.lang.String paginationLinks(Paginator paginator, java.lang.String actionPath, java.lang.String linkProperties)
          Returns a string of pagination page links.
static java.lang.Object param(java.lang.String key)
          Returns an object associated with the key in parameter scope.
static boolean redirect(java.lang.String uri)
          Redirects to a new address.
static java.lang.Object request(java.lang.String key)
          Returns an object associated with the key in request scope.
static void resetCycle(java.lang.String name)
          Resets the cycle
static java.lang.Object session(java.lang.String key)
          Returns an object associated with the key in session scope.
static void setHTTPResponseDateHeader(java.lang.String name, long value)
          Sets a response header with the given name and date-value.
static void setHTTPResponseHeader(java.lang.String name, java.lang.String value)
          Sets a response header with the given name and value.
static java.lang.String simpleForeignKeyRecordShowActionLink(java.lang.String columnName, java.lang.String columnValue)
          Returns a label link on the columnName for columnValue for show action.
static java.lang.String stylesheetLink(java.lang.String stylesheetFileName)
          Returns a link to a stylesheet file.
static java.lang.String submitButtonLink(java.lang.String face, java.lang.String actionPath)
          Returns a html submit button.
static java.lang.String submitButtonLink(java.lang.String face, java.lang.String actionPath, java.util.Map<java.lang.String,java.lang.String> options)
          Returns a html submit button.
static java.lang.String submitButtonLink(java.lang.String face, java.lang.String actionPath, java.lang.String options)
          Returns a html submit button.
static java.lang.String taggedContent(java.lang.Object object, java.lang.String field, java.lang.String tag, java.lang.String content, java.util.Map<java.lang.String,java.lang.String> properties)
          Returns a formatted html string.
static java.lang.String taggedContent(java.lang.String tag, java.lang.String content)
          Returns a formatted html string.
static java.lang.String taggedContent(java.lang.String tag, java.lang.String content, java.util.Map<java.lang.String,java.lang.String> properties)
          Returns a formatted html string.
static java.lang.String taggedContent(java.lang.String tag, java.lang.String content, java.lang.String properties)
          Returns a formatted html string.
static java.lang.Object thread(java.lang.String key)
          Returns an object associated with the key in thread scope.
static java.lang.String value(java.lang.String key)
          Returns a string value for a key.
static java.lang.String value(java.lang.String key, javax.servlet.http.HttpServletRequest request, ActiveRecord record)
          Returns a string value for a key.
static java.lang.String windowStylePageLinks(Paginator paginator, java.lang.String actionPath)
          Returns a string of window-style pagination page links.
static java.lang.String windowStylePageLinks(Paginator paginator, java.lang.String actionPath, int side, int window)
          Returns a string of pagination page links.
static java.lang.String windowStylePageLinks(Paginator paginator, java.lang.String actionPath, int side, int window, java.lang.String linkProperties)
          Returns a string of pagination page links.
static java.lang.String windowStylePageLinks(Paginator paginator, java.lang.String actionPath, java.lang.String linkProperties)
          Returns a string of window-style pagination page links.
static java.lang.String yahooStylePageLinks(Paginator paginator, java.lang.String actionPath)
          Returns a string of Yahoo-style pagination page links.
static java.lang.String yahooStylePageLinks(Paginator paginator, java.lang.String actionPath, java.lang.String linkProperties)
          Returns a string of Yahoo-style pagination page links.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mp

public static final com.petebevin.markdown.MarkdownProcessor mp

html5Keys

public static final java.util.List<java.lang.String> html5Keys

buttonKeys

public static final java.util.List<java.lang.String> buttonKeys

imageKeys

public static final java.util.List<java.lang.String> imageKeys

inputKeys

public static final java.util.List<java.lang.String> inputKeys

linkKeys

public static final java.util.List<java.lang.String> linkKeys

styleKeys

public static final java.util.List<java.lang.String> styleKeys

noLinkOnEmptyQueryString

public static java.lang.String noLinkOnEmptyQueryString

Key to embed in linkProperties map or string in order not to show a link on a label.

For example, if it is desired that no link is displayed when query string is empty, then developer can embed "noLinkOnEmptyQueryString:true" in the linkProperties map or string.


noLinkOnCurrentUri

public static java.lang.String noLinkOnCurrentUri

Key to embed in linkProperties map or string in order not to show a link on a label when the current uri is the same as the action path.

For example, if it is desired that no link is displayed when current uri is the same as actionPath, then developer can embed "noLinkOnCurrentUri:true" in the linkProperties map or string.

Constructor Detail

W

public W()
Method Detail

encode

public static java.lang.String encode(java.lang.String s)
Returns a url-encoded string.

Parameters:
s - the input string
Returns:
encoded string.

decode

public static java.lang.String decode(java.lang.String s)
Returns a url-decoded string.

Parameters:
s - the input string
Returns:
decoded string.

thread

public static java.lang.Object thread(java.lang.String key)
Returns an object associated with the key in thread scope. See method ActionContext.getFromThreadData(String).

Parameters:
key - a string
Returns:
object associated with the key

param

public static java.lang.Object param(java.lang.String key)
Returns an object associated with the key in parameter scope. See method ActionContext.getFromParameterData(String).

Parameters:
key - a string
Returns:
object associated with the key

request

public static java.lang.Object request(java.lang.String key)
Returns an object associated with the key in request scope. See method ActionContext.getFromRequestData(String).

Parameters:
key - a string
Returns:
object associated with the key

session

public static java.lang.Object session(java.lang.String key)
Returns an object associated with the key in session scope. See method ActionContext.getFromSessionData(String).

Parameters:
key - a string
Returns:
object associated with the key

context

public static java.lang.Object context(java.lang.String key)
Returns an object associated with the key in context scope. See method ActionContext.getFromContextData(String).

Parameters:
key - a string
Returns:
object associated with the key

global

public static java.lang.Object global(java.lang.String key)
Returns an object associated with the key in global scope. See method ActionContext.getFromGlobalData(String).

Parameters:
key - a string
Returns:
object associated with the key

get

public static java.lang.Object get(java.lang.String key)
Returns an object associated with the key. See method ActionContext.get(String).

Parameters:
key - a string
Returns:
object associated with the key

get

public static java.lang.Object get(java.lang.String key,
                                   java.lang.Object def)
Returns an object associated with the key. See method ActionContext.get(String). If there is no value associated with the key, a default value is returned.

Parameters:
key - a string
def - default value
Returns:
object associated with the key

value

public static java.lang.String value(java.lang.String key)
Returns a string value for a key. The returned value is html-escaped.

Parameters:
key - a string
Returns:
string value associated with the key

value

public static java.lang.String value(java.lang.String key,
                                     javax.servlet.http.HttpServletRequest request,
                                     ActiveRecord record)
Returns a string value for a key. If there is no value found from the request, the key is treated as a field name of the record and its corresponding value in the record is returned. The returned value is html-escaped.

Parameters:
key - a string
request - a http request
record - an active record instance
Returns:
string value associated with the key

isLocalRequest

public static boolean isLocalRequest()
Checks if the request is a local request.

Returns:
true if local request

isEmpty

public static boolean isEmpty(java.lang.String key,
                              java.lang.String property)
Checks whether the object represented by the key has property that is empty.

Parameters:
key -
property -
Returns:
true if the property value is empty.

isEmpty

public static boolean isEmpty(java.lang.Object object,
                              java.lang.String property)
Checks whether the object has property that is empty.

Parameters:
object -
property -
Returns:
true if the property value is empty.

isEmpty

public static boolean isEmpty(java.lang.Object object)
Checks whether the object is empty.

Parameters:
object -
Returns:
true if the object is empty.

isEqual

public static boolean isEqual(java.lang.String key,
                              java.lang.String property,
                              java.lang.Object desired)
Checks whether the Object represented by the key has property value that is equal to the desired value.

Parameters:
key -
property -
desired -
Returns:
true if the property has the same value as the desired.

isEqual

public static boolean isEqual(java.lang.Object object,
                              java.lang.String property,
                              java.lang.Object desired)
Checks whether the Object's property has the same value as the desired value.

Parameters:
object -
property -
desired -
Returns:
true if the property has the same value as the desired.

isEqual

public static boolean isEqual(java.lang.Object object,
                              java.lang.Object desired)
Checks whether the object has the same value as the desired value.

Parameters:
object -
desired -
Returns:
true if the object has the same value as the desired.

isGreaterThan

public static boolean isGreaterThan(java.lang.String key,
                                    java.lang.String property,
                                    java.lang.Object desired)
Checks whether the Object represented by the key has property value that is greater than the desired value.

Parameters:
key -
property -
desired -
Returns:
true if the property value is greater than the desired.

isGreaterThan

public static boolean isGreaterThan(java.lang.Object object,
                                    java.lang.String property,
                                    java.lang.Object desired)
Checks whether the Object's property value is greater than the desired value.

Parameters:
object -
property -
desired -
Returns:
true if the property value is greater than the desired.

isGreaterThan

public static boolean isGreaterThan(java.lang.Object object,
                                    java.lang.Object desired)
Checks whether the object value is greater than the desired value.

Parameters:
object -
desired -
Returns:
true if the object value is greater than the desired.

isGreaterThanOrEqual

public static boolean isGreaterThanOrEqual(java.lang.String key,
                                           java.lang.String property,
                                           java.lang.Object desired)
Checks whether the Object represented by the key has property value that is greater than or equal to the desired value.

Parameters:
key -
property -
desired -
Returns:
true if the property value is greater than or equal to the desired.

isGreaterThanOrEqual

public static boolean isGreaterThanOrEqual(java.lang.Object object,
                                           java.lang.String property,
                                           java.lang.Object desired)
Checks whether the Object's property value is greater than or equal to the desired value.

Parameters:
object -
property -
desired -
Returns:
true if the property value is greater than or equal to the desired.

isGreaterThanOrEqual

public static boolean isGreaterThanOrEqual(java.lang.Object object,
                                           java.lang.Object desired)
Checks whether the object value is greater than or equal to the desired value.

Parameters:
object -
desired -
Returns:
true if the object value is greater than or equal to the desired.

isLessThan

public static boolean isLessThan(java.lang.String key,
                                 java.lang.String property,
                                 java.lang.Object desired)
Checks whether the Object represented by the key has property value that is less than the desired value.

Parameters:
key -
property -
desired -
Returns:
true if the property value is less than the desired.

isLessThan

public static boolean isLessThan(java.lang.Object object,
                                 java.lang.String property,
                                 java.lang.Object desired)
Checks whether the Object's property value is less than the desired value.

Parameters:
object -
property -
desired -
Returns:
true if the property value is less than the desired.

isLessThan

public static boolean isLessThan(java.lang.Object object,
                                 java.lang.Object desired)
Checks whether the object value is less than the desired value.

Parameters:
object -
desired -
Returns:
true if the object value is less than the desired.

isLessThanOrEqual

public static boolean isLessThanOrEqual(java.lang.String key,
                                        java.lang.String property,
                                        java.lang.Object desired)
Checks whether the Object represented by the key has property value that is less than or equal to the desired value.

Parameters:
key -
property -
desired -
Returns:
true if the property value is less than or equal to the desired.

isLessThanOrEqual

public static boolean isLessThanOrEqual(java.lang.Object object,
                                        java.lang.String property,
                                        java.lang.Object desired)
Checks whether the Object's property value is less than or equal to the desired value.

Parameters:
object -
property -
desired -
Returns:
true if the property value is less than or equal to the desired.

isLessThanOrEqual

public static boolean isLessThanOrEqual(java.lang.Object object,
                                        java.lang.Object desired)
Checks whether the object value is less than or equal to the desired value.

Parameters:
object -
desired -
Returns:
true if the object value is less than or equal to the desired.

isPresent

public static boolean isPresent(java.lang.String key)
Checks whether there is data represent by the key string in a scope.

Parameters:
key -
Returns:
true if found

isPresent

public static boolean isPresent(java.lang.String key,
                                java.lang.String scope)

Checks whether there is data represent by the key string in a specific scope.

There are four accepted scope constants: parameter, request, sesison and context. All are defined in ActionContext class.

Parameters:
key -
Returns:
true if found

htmlEsacpe

public static java.lang.String htmlEsacpe(java.lang.String s)
Removes the following html unfriendly characters from the input string:
double quote("), single quote('), lower than(<), greater than(>), and &.


h

public static java.lang.String h(java.lang.String s)
A short-hand alias of htmlEsacpe method.

Parameters:
s - input string
Returns:
html escaped string

displayHtmlSelect

public static java.lang.String displayHtmlSelect(java.lang.String name,
                                                 java.util.List<java.lang.Object> dataList,
                                                 java.lang.String options)

Returns html select code of a list of data and options. Data items in the dataList can be any object.

The options string contains name and value pairs of options. The name and value are separated by colon, while each pair is separated by semi-colon.

The follow option keys are supported:
 options: id:aaa; class:bbb; javascript:ccc; optionId:ddd; optionValue:eee;
          selectedId:fff; useBlank:true; prompt:ggg
 
 Description of the option keys:
 id:          html select id
 class:       css class of the select
 javascript:  javascript codes embeded in the select
 optionId:    the property name of the data item object that will be used in the value portion of the option
 optionValue: the property name of the data item object that will be used in the display portion of the option
 selectedId:  selected optionId or optionValue if optionId is not present
 useBlank:    add a blank option. If the useBlank is not "false", its value is display in the option.
 prompt:      a prompt option displayed only when useBlank if not present. For example, 
 
 Examples:
 1. nameList: Cindy, Dave, Eddy, Frank
    displayHtmlSelect("person", nameList, "id:fname;class:big;useBlank:None")
    The generated select html code is:
    <select id=fname, class=big, name=person>
        <option>None</option>
        <option value="Cindy">Cindy</option>
        <option value="Dave">Dave</option>
        <option value="Eddy">Eddy</option>
        <option value="Frank">Frank</option>
    </select>
 
 2. stateList: a list of states {(id=1, name=CA), (id=2, name=MA), (id=3, name=VA)}
    displayHtmlSelect("state", stateList, "optionId:id;optionValue:name;prompt:Select a state;selectedId:3")
    The generated select html code is:
    <select id=fname, class=big, name=person>
        <option>Select a state</option>
        <option value="1">CA</option>
        <option value="2">MA</option>
        <option value="3" selected="selected">VA</option>
    </select>
 

Parameters:
name - the name of the select
dataList - the list of data to be used in the select
options - configuration options of the select
Returns:
html select string

displayHtmlSelect

public static java.lang.String displayHtmlSelect(java.lang.String name,
                                                 java.lang.String dataListKey,
                                                 java.lang.String options)

yahooStylePageLinks

public static java.lang.String yahooStylePageLinks(Paginator paginator,
                                                   java.lang.String actionPath)
Returns a string of Yahoo-style pagination page links. The following is an example of the Yahoo-style page links for page limit of 10:
 Showing 31 - 40 of 42  First |  Previous |  Next |  Last
 

Parameters:
paginator - The Paginator instance
actionPath - Path to an action
Returns:
a string of Yahoo-style pagination links

yahooStylePageLinks

public static java.lang.String yahooStylePageLinks(Paginator paginator,
                                                   java.lang.String actionPath,
                                                   java.lang.String linkProperties)
Returns a string of Yahoo-style pagination page links. The following is an example of the Yahoo-style page links for page limit of 10:
 Showing 31 - 40 of 42  First |  Previous |  Next |  Last
 

Parameters:
paginator - The Paginator instance
actionPath - Path to an action
linkProperties - string of link related properties
Returns:
a string of Yahoo-style pagination links

paginationLinks

public static java.lang.String paginationLinks(Paginator paginator,
                                               java.lang.String actionPath)
Returns a string of pagination page links.

Parameters:
paginator - The Paginator instance
actionPath - Path to an action
Returns:
a string of pagination links

paginationLinks

public static java.lang.String paginationLinks(Paginator paginator,
                                               java.lang.String actionPath,
                                               java.lang.String linkProperties)
Returns a string of pagination page links.

Parameters:
paginator - The Paginator instance
actionPath - Path to an action
linkProperties - string of link related properties
Returns:
a string of pagination links

windowStylePageLinks

public static java.lang.String windowStylePageLinks(Paginator paginator,
                                                    java.lang.String actionPath)
Returns a string of window-style pagination page links.

Parameters:
paginator - The Paginator instance
actionPath - Path to an action
Returns:
a string of window-style pagination links

windowStylePageLinks

public static java.lang.String windowStylePageLinks(Paginator paginator,
                                                    java.lang.String actionPath,
                                                    java.lang.String linkProperties)
Returns a string of window-style pagination page links.

Parameters:
paginator - The Paginator instance
actionPath - Path to an action
linkProperties - string of link related properties
Returns:
a string of window-style pagination links

windowStylePageLinks

public static java.lang.String windowStylePageLinks(Paginator paginator,
                                                    java.lang.String actionPath,
                                                    int side,
                                                    int window)
Returns a string of pagination page links. The following is an example of the window-style page links for size=4 and window=11:
 
  Previous 1 2 3 4 .... 6 7 8 9 10 11 12 13 14 15 16 .... 18 19 20 21 Next 
 

Parameters:
paginator - The Paginator instance
actionPath - Path to an action
side - Size of side window
window - Width of total page links shown
Returns:
a string of window-style pagination links

windowStylePageLinks

public static java.lang.String windowStylePageLinks(Paginator paginator,
                                                    java.lang.String actionPath,
                                                    int side,
                                                    int window,
                                                    java.lang.String linkProperties)
Returns a string of pagination page links. The following is an example of the window-style page links for size=4 and window=11:
 
  Previous 1 2 3 4 .... 6 7 8 9 10 11 12 13 14 15 16 .... 18 19 20 21 Next 
 

Parameters:
paginator - The Paginator instance
actionPath - Path to an action
side - Size of side window
window - Width of total page links shown
linkProperties - string of link related properties
Returns:
a string of window-style pagination links

setHTTPResponseHeader

public static void setHTTPResponseHeader(java.lang.String name,
                                         java.lang.String value)

Sets a response header with the given name and value. If the header had already been set, the new value overwrites the previous one. Otherwise, the value is added to the response.

Example: "Location:", "http://www.google.com/mypage.jsp"

Parameters:
name - the name of the header
value - the header value If it contains octet string, it should be encoded according to RFC 2047.

setHTTPResponseDateHeader

public static void setHTTPResponseDateHeader(java.lang.String name,
                                             long value)

Sets a response header with the given name and date-value. The date is specified in terms of milliseconds since the epoch. If the header had already been set, the new value overwrites the previous one.

Parameters:
name - the name of the date header
value - the header value If it contains octet string, it should be encoded according to RFC 2047.

redirect

public static boolean redirect(java.lang.String uri)
Redirects to a new address. Examples of address:
  1. Absolute url: "http://www.google.com"
  2. Relative uri: "/shop/order.do"
  3. Relative uri: "order.do"

Parameters:
uri - a new location to go
Returns:
boolean status of the redirect. True if success.

doForward

public static void doForward(java.lang.String uri,
                             javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response)
                      throws java.io.IOException,
                             javax.servlet.ServletException
Throws:
java.io.IOException
javax.servlet.ServletException

getContextName

public static java.lang.String getContextName()
Returns context name of the webapp.


getContextPath

public static java.lang.String getContextPath()
Returns context path of a http request. Context path is the same as document root.


getDocumentRoot

public static java.lang.String getDocumentRoot()
Returns document root of a http request.


getRealPath

public static java.lang.String getRealPath()

Returns real path of the http servlet context.

Examples:

If the myapp.war is running under E:\tomcat\webapps, the real path of the context is E:\tomcat\webapps\myapp


getCurrentControllerPath

public static java.lang.String getCurrentControllerPath()

Returns controller path associated with the servlet request.

 Examples:
      servletPath                     controllerPath
      ----------------------------------------------
      /posts/list.do                   /posts
      /report/posts/list.do            /report/posts
      /posts                           /posts
 

Returns:
string current controller path

getHttpRequest

public static javax.servlet.http.HttpServletRequest getHttpRequest()
Returns http servlet request instance.

Returns:
http servlet request instance

checkSelect

public static java.lang.String checkSelect(java.lang.String value,
                                           java.lang.String choice)

Returns a html segment for selected choice. If the choice is the same as the value, the returned html string will be selected="selected".

Parameters:
value - the value on the selection list
choice - the value chosen by the user
Returns:
html element

checkCheckbox

public static java.lang.String checkCheckbox(java.lang.String value,
                                             java.lang.String choice)

Returns a html segment for checked choice. If the choice is the same as the value, the returned html string will be checked="checked". This is for html radio button and checkbox.

Parameters:
value - the value on the selection list
choice - the value chosen by the user
Returns:
html element

getURL

public static java.lang.String getURL(java.lang.String actionPath)

Returns a url. By default, this method returns relative url.

See description of getURL(java.lang.String, java.util.Map) method for more details and examples.

Parameters:
actionPath - path to an action
Returns:
a url string

getURL

public static java.lang.String getURL(java.lang.String actionPath,
                                      java.lang.String options)

Returns a url. By default, this method returns relative url.

See description of getURL(java.lang.String, java.util.Map) method for more details and examples.

Parameters:
actionPath - path to an action
options - a string of options
Returns:
a url string

getURL

public static java.lang.String getURL(java.lang.String actionPath,
                                      java.util.Map<java.lang.String,java.lang.String> options)

Returns a url. By default, this method returns relative url.

The format of the generated url depends on values in options map.

The options string contains name and value pairs of options. The name and value are separated by colon, while each pair is separated by semi-colon.

The following keys are supported in the options:
 extension: overrides the default (current) extension if provided
 fullurl: if true, a fully qualified URL like http://example.com/posts/list.do is returned. Default is false.
 protocol: overrides the default (http) protocol if provided
 host: overrides the default (current) host if provided
 port: overrides the default (current) port if provided
 encode: if true, the url's query string is encoded. Default is false.
 
The generated url string may have the following format:
      actionPath              options                         returned url
      --------------------------------------------------------------------
      list                                                    /posts/list.do
      /posts/list             extension:dx                    /posts/list.dx
      list                    extension:dx;fullurl:true       http://example.com/demo/posts/list.dx
      /posts/list             fullurl:true;protocol:https;    https://another.com:8080/demo/posts/list.do
                              host:another.com;port:8080
 

If actionPath is empty, an empty string (not url) is returned.

Parameters:
actionPath - path to an action
options - a map of options
Returns:
a url string

getPureURLString

public static java.lang.String getPureURLString(java.lang.String url)
Returns non-query string portion of an url. A pure url string is anything before the first ? in an url.


getQueryString

public static java.lang.String getQueryString(java.lang.String url)
Returns query string portion of an url. A query string is anything after the first ? in an url. A null is returned if there is no ? character in the url.


buttonTag

public static java.lang.String buttonTag(java.lang.String face)

Returns a button tag.

Example:

For face = "Click Here!", the result button tag is

Parameters:
face - display of the button
Returns:
a string of html button code

buttonTag

public static java.lang.String buttonTag(java.lang.String face,
                                         java.lang.String buttonProperties)

Returns a button tag.

The buttonProperties string contains name and value pairs of options. The name and value are separated by colon, while each pair is separated by semi-colon.

Supported keys for buttonProperties are listed in the description of this class.

 Example: 
      For face = "Click Here!", 
          buttonProperties = "id:fish; name:fish", the result button tag is 
      
 

Parameters:
face - display of the button
buttonProperties - string of button related properties
Returns:
a string of html button code

buttonTag

public static java.lang.String buttonTag(java.lang.String face,
                                         java.util.Map<java.lang.String,java.lang.String> buttonProperties)

Returns a button tag.

The buttonProperties string contains name and value pairs of options. The name and value are separated by colon, while each pair is separated by semi-colon.

Supported keys for buttonProperties are listed in the description of this class.

 Example: 
      For face = "Click Here!", 
          buttonProperties = "id:fish; name:fish", the result button tag is 
      
 

Parameters:
face - display of the button
buttonProperties - map of button related properties
Returns:
a string of html button code

buttonLink

public static java.lang.String buttonLink(java.lang.String face,
                                          java.lang.String buttonProperties,
                                          java.lang.String actionPath)

Returns a url link on a button. This does not work well with IE7. Use a corresponding submitButtonLink method instead.

Supported keys for buttonProperties are listed in the description of this class.

See description of buttonLink(java.lang.String, java.util.Map, java.lang.String, java.util.Map) method for more details and examples.

Parameters:
face - display of the button
buttonProperties - button related properties
actionPath - path to an action
Returns:
a url link

buttonLink

public static java.lang.String buttonLink(java.lang.String face,
                                          java.lang.String buttonProperties,
                                          java.lang.String actionPath,
                                          java.lang.String linkProperties)

Returns a url link on a button. This does not work well with IE7. Use a corresponding submitButtonLink method instead.

Supported keys for buttonProperties are listed in the description of this class.

Supported keys for linkProperties are listed in the description of this class.

See description of buttonLink(java.lang.String, java.util.Map, java.lang.String, java.util.Map) method for more details and examples.

Parameters:
face - display of the button
buttonProperties - button related properties
actionPath - path to an action
linkProperties - http link related properties
Returns:
a url link

buttonLink

public static java.lang.String buttonLink(java.lang.String face,
                                          java.util.Map<java.lang.String,java.lang.String> buttonProperties,
                                          java.lang.String actionPath,
                                          java.util.Map<java.lang.String,java.lang.String> linkProperties)

Returns a url link on a button. This does not work well with IE7. Use a corresponding submitButtonLink method instead.

Supported keys for buttonProperties are listed in the description of this class.

Supported keys for linkProperties are listed in the description of this class.

 Example: 
      For face = "Click Here!", 
          buttonProperties = "id:fish; name:fish", and 
          actionPath = "/category/show?catid=FISH", 
          linkProperties = "confirm:'Do you agree?';id:good", 
          the result button link is 
      
 

Parameters:
face - display of the button
buttonProperties - button related properties
actionPath - path to an action
linkProperties - http link related properties
Returns:
a url link

submitButtonLink

public static java.lang.String submitButtonLink(java.lang.String face,
                                                java.lang.String actionPath)
Returns a html submit button.

See description of submitButtonLink(java.lang.String, java.lang.String, java.util.Map) method for more details and examples.

Parameters:
face - display of the button
actionPath - path to an action
Returns:
a html submit button in a form

submitButtonLink

public static java.lang.String submitButtonLink(java.lang.String face,
                                                java.lang.String actionPath,
                                                java.lang.String options)
Returns a html submit button.

See description of submitButtonLink(java.lang.String, java.lang.String, java.util.Map) method for more details and examples.

Parameters:
face - display of the button
actionPath - path to an action
options - http input related properties
Returns:
a html submit button in a form

submitButtonLink

public static java.lang.String submitButtonLink(java.lang.String face,
                                                java.lang.String actionPath,
                                                java.util.Map<java.lang.String,java.lang.String> options)

Returns a html submit button.

The options string contains name and value pairs of options. The name and value are separated by colon :, while each pair

is separated by semi-colon ;.

Supported options are:

Examples

      submitButtonLink("Back to Home", "/category/show?catid=FISH", "confirm:'Do you agree?';id:fish")
      result submit: 
      
You can also use the following because onclick is a key attribute: submitButtonLink("Back to Home", "/category/show?catid=FISH", "method:post;onclick:return confirm('Do you agree?');id:fish")

Parameters:
face - display of the button
actionPath - path to an action
options - http input related properties
Returns:
a html submit button in a form

labelLinkForRecord

public static java.lang.String labelLinkForRecord(java.lang.String label,
                                                  java.lang.String actionPath,
                                                  ActiveRecord record)
Returns a url link on a label related to a record.

Parameters:
label - link label
actionPath - path to an action
record - ActiveRecord instance
Returns:
String label link

labelLinkForRecord

public static java.lang.String labelLinkForRecord(java.lang.String label,
                                                  java.lang.String actionPath,
                                                  ActiveRecord record,
                                                  java.lang.String linkProperties)
Returns a url link on a label related to a record.

Parameters:
label - link label
actionPath - path to an action
record - ActiveRecord instance
linkProperties - string of link related properties
Returns:
url link on the label

labelLink

public static java.lang.String labelLink(java.lang.String label,
                                         java.lang.String actionPath)

Returns a url link on a label.

See description of labelLink(java.lang.String, java.lang.String, java.util.Map) method for more details and examples.

Parameters:
label - link label
actionPath - path to an action
Returns:
url link on the label

labelLink

public static java.lang.String labelLink(java.lang.String label,
                                         java.lang.String actionPath,
                                         java.lang.String linkProperties)

Returns a url link on a label.

See description of labelLink(java.lang.String, java.lang.String, java.util.Map) method for more details and examples.

Parameters:
label - link label
actionPath - path to an action
linkProperties - string of link related properties
Returns:
url link on the label

labelLink

public static java.lang.String labelLink(java.lang.String label,
                                         java.lang.String actionPath,
                                         java.util.Map<java.lang.String,java.lang.String> linkProperties)

Returns a url link with query strings on a label.

The linkProperties string contains name and value pairs of options. The name and value are separated by colon, while each pair is separated by semi-colon.

Supported linkProperties are:

Examples

      labelLink("Back to Home", "http://www.example.com", "", "confirm:'Do you agree?';id:good")
      result link: Back to Home
      
      You can also use this because onclick is a key attribute:
      labelLink("Back to Home", "http://www.example.com", "", "onclick:return confirm('Do you agree?');id:good")
      result link: Back to Home
      
      labelLink("Back to Home", "http://www.example.com", "", "popup:true")
      result link: Back to Home
      
      labelLink("Back to Home", "http://www.example.com", "", "popup:'http://www.google.com','new_window_name','height=440,width=650,resizable,top=200,left=250,scrollbars=yes'")
      result link: Back to Home
 

Parameters:
label - link label
actionPath - path to an action
linkProperties - map of link related properties
Returns:
url link on the label

imageTag

public static java.lang.String imageTag(java.lang.String imageSrc)

Returns an image tag.

Example:

Parameters:
imageSrc - source path to image file
Returns:
a string of html image code

imageTag

public static java.lang.String imageTag(java.lang.String imageSrc,
                                        java.lang.String imageProperties)

Returns an image tag.

The imageProperties string contains name and value pairs of options. The name and value are separated by colon, while each pair is separated by semi-colon.

Supported keys for imageProperties are listed in the imageKeys section of the description of this class.

 Example: 
      For imageProperties = "alt:Fish; id:fish; name:fish", the result image tag is 
      Fish
 

Parameters:
imageSrc - source path to image file
imageProperties - string of image related properties
Returns:
a string of html image code

imageTag

public static java.lang.String imageTag(java.lang.String imageSrc,
                                        java.util.Map<java.lang.String,java.lang.String> imageProperties)

Returns an image tag.

Supported keys for imageProperties are in the imageKeys section of the description of this class.

 Example: 
      For imageProperties = "alt:Fish; id:fish; name:fish", the result image tag is 
      Fish
 

Parameters:
imageSrc - source path to image file
imageProperties - map of image related properties
Returns:
a string of html image code

imageLink

public static java.lang.String imageLink(java.lang.String imageSrc,
                                         java.lang.String imageProperties,
                                         java.lang.String actionPath)

Returns a url link on an image.

See description of imageLink(java.lang.String, java.util.Map, java.lang.String, java.util.Map) method for more details and examples.

Parameters:
imageSrc - source path to image file
imageProperties - image related properties
actionPath - path to an action
Returns:
a url link

imageLink

public static java.lang.String imageLink(java.lang.String imageSrc,
                                         java.lang.String imageProperties,
                                         java.lang.String actionPath,
                                         java.lang.String linkProperties)

Returns a url link on an image.

See description of imageLink(java.lang.String, java.util.Map, java.lang.String, java.util.Map) method for more details and examples.

Parameters:
imageSrc - source path to image file
imageProperties - image related properties
actionPath - path to an action
linkProperties - http link related properties
Returns:
a url link

imageLink

public static java.lang.String imageLink(java.lang.String imageSrc,
                                         java.util.Map<java.lang.String,java.lang.String> imageProperties,
                                         java.lang.String actionPath,
                                         java.util.Map<java.lang.String,java.lang.String> linkProperties)

Returns a url link on an image.

Supported keys for imageProperties are in the imageKeys section of the description of this class.

Supported keys for linkProperties are in the linkKeys section of the description of this class.

 Example: 
      For imageSrc = "../images/fish_icon.gif", 
          imageProperties = "alt:Fish; id:fish; name:fish", 
          actionPath = "/category/show?catid=FISH", 
          linkProperties = "confirm:'Do you agree?';id:good", 
          the result image link is 
      
          Fish
 

Parameters:
imageSrc - source path to image file
imageProperties - image related properties
actionPath - path to an action
linkProperties - http link related properties
Returns:
a url link

stylesheetLink

public static java.lang.String stylesheetLink(java.lang.String stylesheetFileName)
Returns a link to a stylesheet file.

Returns:
String link

javascriptLink

public static java.lang.String javascriptLink(java.lang.String javascriptFileName)
Returns a link to a javascript file.

Returns:
String link

pageLink

public static java.lang.String pageLink(java.lang.String label,
                                        java.lang.String actionPath,
                                        java.lang.String queryString)
Returns a url link for a page in pagination.

Parameters:
label - link label
actionPath - path to an action
queryString - query string
Returns:
a url link

pageLink

public static java.lang.String pageLink(int pageNumber,
                                        java.lang.String pageTitle,
                                        java.lang.String actionPath,
                                        java.lang.String queryString)
Returns a url link for a page in pagination.

Parameters:
pageNumber - page number
pageTitle - title of a page
actionPath - path to an action
queryString - query string
Returns:
a url link

pageLink

public static java.lang.String pageLink(java.lang.String label,
                                        java.lang.String actionPath,
                                        java.lang.String queryString,
                                        java.lang.String linkProperties)
Returns a url link for a page in pagination.

Parameters:
label - link label
actionPath - path to an action
queryString - query string
linkProperties - string of link related properties
Returns:
a url link

convertButtonPropertiesToString

public static java.lang.String convertButtonPropertiesToString(java.util.Map<java.lang.String,java.lang.String> properties)
Converts a button properties map to string.

Parameters:
properties - a map of key value pairs
Returns:
string

convertImagePropertiesToString

public static java.lang.String convertImagePropertiesToString(java.util.Map<java.lang.String,java.lang.String> properties)
Converts an image properties map to string.

Parameters:
properties - a map of key value pairs
Returns:
string

convertInputPropertiesToString

public static java.lang.String convertInputPropertiesToString(java.util.Map<java.lang.String,java.lang.String> properties)
Converts a input properties map to string.

Parameters:
properties - a map of key value pairs
Returns:
string

convertLinkPropertiesToString

public static java.lang.String convertLinkPropertiesToString(java.util.Map<java.lang.String,java.lang.String> properties)
Converts a link properties map to string.

Parameters:
properties - a map of key value pairs
Returns:
string

errorMessage

public static java.lang.String errorMessage(java.lang.String model)

Returns a div block containing all the error messages for the object located as an instance variable by the name of model.

Parameters:
model - model name
Returns:
String formatted error message

errorMessage

public static java.lang.String errorMessage(java.lang.String model,
                                            java.util.Properties options)

Returns a div block containing all the error messages for the object located as an instance variable by the name of model.

 This div block can be tailored by the following options:
 
 headerTag - Used for the header of the error div (default: h2)
 header - Used for the header of the error div (default: "error(s) happened:")
 name - The name of the error div (default: errorDetails)
 id - The id of the error div (default: errorDetails)
 class - The css class of the error div (default: errorDetails)
 

Parameters:
model - model name
options - A Map of options
Returns:
String formatted error message

taggedContent

public static java.lang.String taggedContent(java.lang.String tag,
                                             java.lang.String content)

Returns a formatted html string.

Example:
3 Errors

Parameters:
tag -
content -
Returns:
String formatted html string

taggedContent

public static java.lang.String taggedContent(java.lang.String tag,
                                             java.lang.String content,
                                             java.lang.String properties)

Returns a formatted html string.

Example:
3 Errors

Parameters:
tag - tag name
content - content of the tag
properties - string of properties
Returns:
String formatted html string

taggedContent

public static java.lang.String taggedContent(java.lang.String tag,
                                             java.lang.String content,
                                             java.util.Map<java.lang.String,java.lang.String> properties)

Returns a formatted html string.

Example:
3 Errors

Parameters:
tag - tag name
content - content of the tag
properties - map of properties
Returns:
String formatted html string

taggedContent

public static java.lang.String taggedContent(java.lang.Object object,
                                             java.lang.String field,
                                             java.lang.String tag,
                                             java.lang.String content,
                                             java.util.Map<java.lang.String,java.lang.String> properties)

Returns a formatted html string. The object is used to check if the record has error.

Example:
3 Errors

Parameters:
object - an object
field - field name of the object
tag - tag name
content - content of the tag
properties - map of properties
Returns:
String formatted html string

cycle

public static java.lang.String cycle(java.lang.String items)
Returns an item from a list items. The name of the cycle is items. Examples:
      class=<%=WebHelper.cycle("odd, even")%> 
      -- use "red" class for odd rows and "blue" class for even rows.
 

Parameters:
items - list of items to be cycled
Returns:
an item value

cycle

public static java.lang.String cycle(java.lang.String items,
                                     java.lang.String name)
Returns an item from a list items.

Parameters:
items - list of items to be cycled
name - the cycle name
Returns:
an item value

currentCycle

public static java.lang.String currentCycle(java.lang.String name)
Returns current item in the named cycle.

Parameters:
name - name of the cycle
Returns:
current item in the named cycle.

resetCycle

public static void resetCycle(java.lang.String name)
Resets the cycle

Parameters:
name - cycle's name

label

public static java.lang.String label(java.lang.String key)
Returns label value stored in a property file based on user's current locale.

Parameters:
key - label key
Returns:
value associated with the key

message

public static java.lang.String message(java.lang.String messageKey)

Returns a message associated with the messageKey.

If there is no message associated with the messageKey in messages property files, the messageKey itself is used as the message.

Parameters:
messageKey - a message key in messages resource files
Returns:
a message string

message

public static java.lang.String message(java.lang.String messageKey,
                                       java.lang.String language)

Returns a message associated with the messageKey in the specific language.

If there is no message associated with the messageKey in messages property files, the messageKey itself is used as the message.

Parameters:
messageKey - a message key in messages resource files
language - ISO Language Code
Returns:
a message string

message

public static java.lang.String message(java.lang.String messageKey,
                                       java.lang.String language,
                                       java.lang.String country)

Returns a message associated with the messageKey in the specific language of the specific country.

If there is no message associated with the messageKey in messages property files, the messageKey itself is used as the message.

Parameters:
messageKey - a message key in messages resource files
language - ISO Language Code
country - ISO Country Code
Returns:
a message string

message

public static java.lang.String message(java.lang.String messageKey,
                                       java.lang.String language,
                                       java.lang.String country,
                                       java.lang.String variant)

Returns a message associated with the messageKey in the specific language of the specific country's particular variant.

If there is no message associated with the messageKey in messages property files, the messageKey itself is used as the message.

Parameters:
messageKey - a message key in messages resource files
language - ISO Language Code
country - ISO Country Code
variant - Variant string
Returns:
a message string

message

public static java.lang.String message(java.lang.String messageKey,
                                       java.util.Locale locale)

Returns a message associated with the messageKey in the specific locale.

If there is no message associated with the messageKey in messages property files, the messageKey itself is used as the message.

Parameters:
messageKey - a message key in messages resource files
locale - a specific locale object
Returns:
a message string

message

public static java.lang.String message(java.lang.String messageKey,
                                       java.lang.Object[] values)
Returns a message associated with the messageKey and the values.

If there is no message associated with the messageKey in messages property files, the messageKey itself is used as the message.

Parameters:
messageKey - a message key in messages resource files
values - an array of objects to be included in the message
Returns:
a message string

message

public static java.lang.String message(java.lang.String messageKey,
                                       java.util.Locale locale,
                                       java.lang.Object[] values)

Returns a message associated with the messageKey and the values in a specific locale.

If there is no message associated with the messageKey in messages property files, the messageKey itself is used as the message.

Parameters:
messageKey - a message key in messages resource files
locale - a specific locale object
values - an array of objects to be included in the message
Returns:
a message string

markdown

public static java.lang.String markdown(java.lang.String text)
Returns html text converted by Markdown. See http://daringfireball.net/projects/markdown for details.

Parameters:
text - a generic text
Returns:
html text converted by Markdown

nl2br

public static java.lang.String nl2br(java.lang.String text)
Returns a string formatted for html display by adding "
"
after each occurance of newlines "\n" in a string.
 Examples: 
   "This is a little world. \r\n A little world." =>
   "This is a little world. \r\n
A little world."

Parameters:
text - a string with line break
Returns:
altered string

simpleForeignKeyRecordShowActionLink

public static java.lang.String simpleForeignKeyRecordShowActionLink(java.lang.String columnName,
                                                                    java.lang.String columnValue)

Returns a label link on the columnName for columnValue for show action.

There are several restrictions of the use of this method.

First, the column name must be of the '{referencedModelName}_id' format where the referencedModelName is the model name of the referenced entity. Second, the primary key of the referenced model must be id.

If the above conditions are violated, the original columnName is returned.

 Examples:
      column    value    link
      ------    -----    ----
      user_id   10       10
 

See method R.simpleForeignKeyResourceRecordLink(String, String) for resource case.

Parameters:
columnName - a column name ended with "_id"
columnValue - the value on the column
Returns:
a label link