org.sakaiproject.tool.assessment.ui.listener.util
Class ContextUtil

java.lang.Object
  extended by org.sakaiproject.tool.assessment.ui.listener.util.ContextUtil

public class ContextUtil
extends Object

Description: Action Listener helper utility

Copyright: Copyright (c) 2004

Organization: Sakai Project

Version:
$Id: ContextUtil.java 71511 2010-01-15 22:35:10Z ktsao@stanford.edu $
Author:
Ed Smiley

Constructor Summary
ContextUtil()
           
 
Method Summary
static String escapeApostrophe(String input)
           
static String getLocalizedString(javax.servlet.http.HttpServletRequest request, String bundleName, String key)
           
static String getLocalizedString(String bundleName, String key)
          Gets a localized message string based on the locale determined by the FacesContext.
static String getProtocol()
           
static String getRelativePath(String url)
           
static String getRoundedValue(Float orig, int maxdigit)
           
static String getRoundedValue(String orig, int maxdigit)
           
static String getStringInUnicode(String string)
           
static Serializable lookupBean(String beanName)
          Helper method to look up backing bean.
static Serializable lookupBeanFromExternalServlet(String beanName, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Helper method to look up backing bean, when OUTSIDE faces in a servlet.
static String lookupParam(String lookup)
          Determine if we have been passed a parameter ending in the param string, else null.
static ArrayList paramArrayLike(String paramPart)
          Determine if we have been passed a parameter that contains a given string, return ArrayList of these Strings, else return empty list.
static ArrayList paramArrayValueLike(String paramPart)
          Determine if we have been passed a parameter that contains a given string, return ArrayList of the corresponding values, else return empty list.
static String paramLike(String paramPart)
          Determine if we have been passed a parameter that contains a given string, else null.
static String paramValueLike(String paramPart)
          Determine if we have been passed a parameter that contains a given string, else null.
static void setServletContext(javax.servlet.ServletContext context)
          Called by LoginServlet
static String stringWYSIWYG(String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextUtil

public ContextUtil()
Method Detail

lookupParam

public static String lookupParam(String lookup)
Determine if we have been passed a parameter ending in the param string, else null. We are doing an endsWith test, since the default JSF renderer embeds the parent identity in the HTML id string; we look for the id that was specified in the JSF.

Parameters:
lookup - JSF id String
Returns:
String the full parameter

paramLike

public static String paramLike(String paramPart)
Determine if we have been passed a parameter that contains a given string, else null. Typically this would be where you want to check for one of a set of similar commandLinks or commandButtons, such as the sortBy headings in evaluation.

Parameters:
paramPart - String to look for
Returns:
String last part of full parameter, corresponding to JSF id

paramArrayLike

public static ArrayList paramArrayLike(String paramPart)
Determine if we have been passed a parameter that contains a given string, return ArrayList of these Strings, else return empty list. Typically this would be where you want to check for one of a set of similar radio buttons commandLinks or commandButtons.

Parameters:
paramPart - String to look for
Returns:
ArrayList of last part Strings of full parameter, corresponding to JSF id

paramValueLike

public static String paramValueLike(String paramPart)
Determine if we have been passed a parameter that contains a given string, else null. Typically this would be where you want to check for one of a set of similar commandLinks or commandButtons, such as the sortBy headings in evaluation.

Parameters:
paramPart - String to look for
Returns:
String the value of the first hit

paramArrayValueLike

public static ArrayList paramArrayValueLike(String paramPart)
Determine if we have been passed a parameter that contains a given string, return ArrayList of the corresponding values, else return empty list. Typically this would be where you want to check for one of a set of similar radio buttons commandLinks or commandButtons.

Parameters:
paramPart - String to look for
Returns:
ArrayList of corresponding values

lookupBean

public static Serializable lookupBean(String beanName)
Helper method to look up backing bean. Don't forget to cast! e.g. (TemplateBean) ContextUtil.lookupBean("template")

Parameters:
context - the faces context
Returns:
the backing bean
Throws:
FacesException

lookupBeanFromExternalServlet

public static Serializable lookupBeanFromExternalServlet(String beanName,
                                                         javax.servlet.http.HttpServletRequest request,
                                                         javax.servlet.http.HttpServletResponse response)
Helper method to look up backing bean, when OUTSIDE faces in a servlet. Don't forget to cast! e.g. (TemplateBean) ContextUtil.lookupBean("template")

Parameters:
beanName -
request - servlet request
response - servlet response
Returns:
the backing bean

setServletContext

public static void setServletContext(javax.servlet.ServletContext context)
Called by LoginServlet


getLocalizedString

public static String getLocalizedString(String bundleName,
                                        String key)
Gets a localized message string based on the locale determined by the FacesContext.

Parameters:
key - The key to look up the localized string

getLocalizedString

public static String getLocalizedString(javax.servlet.http.HttpServletRequest request,
                                        String bundleName,
                                        String key)

getStringInUnicode

public static String getStringInUnicode(String string)

getRoundedValue

public static String getRoundedValue(String orig,
                                     int maxdigit)

getRoundedValue

public static String getRoundedValue(Float orig,
                                     int maxdigit)

escapeApostrophe

public static String escapeApostrophe(String input)

getProtocol

public static String getProtocol()

stringWYSIWYG

public static String stringWYSIWYG(String s)

getRelativePath

public static String getRelativePath(String url)


Copyright © 2005-2012 Sakai Project. All Rights Reserved.