Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.autonomy.utilities
Class HTMLUtils

    java.lang.Object
      |
      +--com.autonomy.utilities.HTMLUtils

public class HTMLUtils
extends java.lang.Object

Library of functions specifically for use for drawing HTML text.
Note: These functions make calls to the deprecated session.get/put/removeValue() methods instead of the new get/set/removeAttribute() methods which perform exactly the same tasks.

Constructor Summary
`HTMLUtils()` Constructor.

Method Summary
`static java.lang.String` | `colorDarkener(java.lang.String sHTMLColor, double dDarkenFactor)` Returns a html string which is a darker color than the one given
`static java.lang.String` | `createCapitalisedCheckboxs(java.lang.String sName, java.lang.String[] asValues, boolean[] abChecked, int nMaxLength)` Returns HTML for a row of checkboxes
`static java.lang.String` | `createCheckboxs(java.lang.String sName, java.lang.String[] asValues, boolean[] abChecked, int nNumColumns)` Returns HTML for a table of checkboxes.
`static java.lang.String` | `createMultipleSelect(java.lang.String sName, java.lang.String[] asValues, java.lang.String[] asSelected, java.lang.String sSize)` Creates the HTML for a muliple select box where the values are the same as the visible options
`static java.lang.String` | `createSelect(java.lang.String sName, int[] anValues, int nSelected)` Creates the HTML for a drop down box where the values are the same as the visible options
`static java.lang.String` | `createSelect(java.lang.String sName, java.lang.String[] asValues, java.lang.String sSelected, boolean bDisabled)` Creates the HTML for a drop down box where the values are the same as the visible options
`static java.lang.String` | `createSelect(java.lang.String sName, java.lang.String[] asValues, java.lang.String sSelected, java.lang.String sTopOption)` Creates the HTML for a drop down box where the values are the same as the visible options
`static void` | `displayRequest(javax.servlet.jsp.JspWriter out, javax.servlet.http.HttpServletRequest request)` Useful for debugging - returns a HTML table displaying all the request.getParamter names and values
`static java.lang.String` | `getTableCenter(javax.servlet.http.HttpSession session)` Get the browser specific HTML attribute to center tables.
`static void` | `invalidateSession(javax.servlet.http.HttpSession session)` Deletes any objects bound to a session
`static java.lang.String` | `isSelectedInt(int number1, int number2)` Useful for drop down boxes - returns "selected" if the two inputs are equal, "" otherwise.
`static java.lang.String` | `isSelectedLong(long number1, long number2)` Useful for drop down boxes - returns "selected" if the two inputs are equal, "" otherwise.
`static java.lang.String` | `isSelectedString(java.lang.String option1, java.lang.String option2)` Useful for drop down boxes - returns "selected" if the two inputs are equal, "" otherwise.
`static java.lang.String` | `requestToQueryString(javax.servlet.http.HttpServletRequest request, boolean bStartWithQuestionMark)` Converts the whole of the request to a querystring which can be attached to a URL Useful when presenting validation errors
`static java.lang.String` | `requestToQueryStringAndStrip(javax.servlet.http.HttpServletRequest request, boolean bStartWithQuestionMark, java.lang.String[] asToStrip)` Converts the whole of the request to a querystring which can be attached to a URL Useful when presenting validation errors
`static java.lang.String` | `safeRequestGet(javax.servlet.http.HttpServletRequest request, java.lang.String sName, java.lang.String sDefault)` Does request.getParameter(sName).
`static java.lang.String[]` | `safeRequestValuesGet(javax.servlet.http.HttpServletRequest request, java.lang.String sName, java.lang.String[] asDefault)` Does request.getParameterValues(sName).
`static java.lang.Object` | `safeSessionGet(javax.servlet.http.HttpSession session, java.lang.String sName, java.lang.Object oDefault)` Gets an object from the session.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### HTMLUtils

    public HTMLUtils()

  Constructor. Takes no action.

Method Detail

### isSelectedString

    public static java.lang.String isSelectedString(java.lang.String option1,
                                                    java.lang.String option2)

  Useful for drop down boxes - returns "selected" if the two inputs are equal, "" otherwise. If you are calling from a JSP page, you can do:
  `<option value="<%=sThisOption%>" <%=HTMLUtils.isSelectedString(sThisOption, sDefaultOption%> >This Option</option>`

### isSelectedInt

    public static java.lang.String isSelectedInt(int number1,
                                                 int number2)

  Useful for drop down boxes - returns "selected" if the two inputs are equal, "" otherwise. If you are calling from a JSP page, you can do:
  `<option value="<%=nThisOption%>" <%=HTMLUtils.isSelectedInt(nThisOption, nDefaultOption%> >This Option</option>`

### isSelectedLong

    public static java.lang.String isSelectedLong(long number1,
                                                  long number2)

  Useful for drop down boxes - returns "selected" if the two inputs are equal, "" otherwise. If you are calling from a JSP page, you can do:
  `<option value="<%=lnThisOption%>" <%=HTMLUtils.isSelectedLong(lnThisOption, lnDefaultOption%> >This Option</option>`

### createSelect

    public static java.lang.String createSelect(java.lang.String sName,
                                                java.lang.String[] asValues,
                                                java.lang.String sSelected,
                                                boolean bDisabled)

  Creates the HTML for a drop down box where the values are the same as the visible options

  Parameters:
    `sName` - HTML name of select box
    `asValues` - array of options/values
    `sSelected` - value of initially selected item
    `bDisabled` - if true, the selectbox is disabled
  Returns:
    HTML for <select> as a String

### createSelect

    public static java.lang.String createSelect(java.lang.String sName,
                                                java.lang.String[] asValues,
                                                java.lang.String sSelected,
                                                java.lang.String sTopOption)

  Creates the HTML for a drop down box where the values are the same as the visible options

  Parameters:
    `sName` - HTML name of select box
    `asValues` - array of options/values
    `sSelected` - value of initially selected item
    `sTopOption` - hard-wired top option such as it might be "---Please Choose an Option---"
  Returns:
    HTML for <select> as a String

### createSelect

    public static java.lang.String createSelect(java.lang.String sName,
                                                int[] anValues,
                                                int nSelected)

  Creates the HTML for a drop down box where the values are the same as the visible options

  Parameters:
    `sName` - HTML name of select box
    `anValues` - array of options/values
    `nSelected` - value of initially selected item
  Returns:
    HTML for <select> as a String

### createMultipleSelect

    public static java.lang.String createMultipleSelect(java.lang.String sName,
                                                        java.lang.String[] asValues,
                                                        java.lang.String[] asSelected,
                                                        java.lang.String sSize)

  Creates the HTML for a muliple select box where the values are the same as the visible options

  Parameters:
    `sName` - HTML name of select box
    `asValues` - array of options/values
    `asSelected` - values of initially selected items
    `sSize` - value of size attribute
  Returns:
    HTML for <select multiple > as a String

### createCheckboxs

    public static java.lang.String createCheckboxs(java.lang.String sName,
                                                   java.lang.String[] asValues,
                                                   boolean[] abChecked,
                                                   int nNumColumns)

  Returns HTML for a table of checkboxes.

  Parameters:
    `sName` - HTML name of checkbox set.
    `asValues` - Array containing the values to give the checkboxes.
    `abChecked` - Array specifying which checkboxs should appear checked. Must be the same length as asValues.

### createCapitalisedCheckboxs

    public static java.lang.String createCapitalisedCheckboxs(java.lang.String sName,
                                                              java.lang.String[] asValues,
                                                              boolean[] abChecked,
                                                              int nMaxLength)

  Returns HTML for a row of checkboxes

  Parameters:
    `sName` - HTML name of checkbox set.
    `asValues` - Array containing the values to give the checkboxes.
    `abChecked` - Array specifying which checkboxs should appear checked. Must be the same length as asValues.
    `nMaxLength` - The maximum number of entries to list before inserting a break point.

### colorDarkener

    public static java.lang.String colorDarkener(java.lang.String sHTMLColor,
                                                 double dDarkenFactor)
                                          throws java.lang.NumberFormatException

  Returns a html string which is a darker color than the one given

  Parameters:
    `sHTMLColor` - color to darken in form #xxxxxx
  Throws:
    `java.lang.NumberFormatException` - if string is not valid

### requestToQueryString

    public static java.lang.String requestToQueryString(javax.servlet.http.HttpServletRequest request,
                                                        boolean bStartWithQuestionMark)

  Converts the whole of the request to a querystring which can be attached to a URL Useful when presenting validation errors

  Parameters:
    `request` - The request
    `bStartWithQuestionMark` - flag to say whether the first char of the return should be ? (or &)
  Returns:
    String of the form "?name1=value1&name2=value2&..." or "&name1=value1&name2=value2&..."

### requestToQueryStringAndStrip

    public static java.lang.String requestToQueryStringAndStrip(javax.servlet.http.HttpServletRequest request,
                                                                boolean bStartWithQuestionMark,
                                                                java.lang.String[] asToStrip)

  Converts the whole of the request to a querystring which can be attached to a URL Useful when presenting validation errors

  Parameters:
    `request` - The request
    `bStartWithQuestionMark` - flag to say whether the first char of the return should be ? (or &)
    `asToStrip` - String array of the names of variables to strip, such as they might be passwords etc
  Returns:
    String of the form "?name1=value1&name2=value2&..." or "&name1=value1&name2=value2&..."

### displayRequest

    public static void displayRequest(javax.servlet.jsp.JspWriter out,
                                      javax.servlet.http.HttpServletRequest request)

  Useful for debugging - returns a HTML table displaying all the request.getParamter names and values

### getTableCenter

    public static java.lang.String getTableCenter(javax.servlet.http.HttpSession session)

  Get the browser specific HTML attribute to center tables.

  Parameters:
    `session` - within which the browser sniffer is stored, in a String key named "BrowserSniffer" For example:
    `com.autonomy.utilities.BrowserSniffer bs = new com.autonomy.utilities.BrowserSniffer();
    bs.sniff();
    session.putValue("BrowserSniffer", bs );
    out.println("Table centering string is: " + HTMLUtils.getTableCenter(session) );
    `
  Returns:
    HTML string containing HTML attribute to make a table centered

### safeSessionGet

    public static java.lang.Object safeSessionGet(javax.servlet.http.HttpSession session,
                                                  java.lang.String sName,
                                                  java.lang.Object oDefault)

  Gets an object from the session. If this returns null, this function will return oDefault

### safeRequestGet

    public static java.lang.String safeRequestGet(javax.servlet.http.HttpServletRequest request,
                                                  java.lang.String sName,
                                                  java.lang.String sDefault)

  Does request.getParameter(sName). If this returns null, this function will return sDefault

### safeRequestValuesGet

    public static java.lang.String[] safeRequestValuesGet(javax.servlet.http.HttpServletRequest request,
                                                          java.lang.String sName,
                                                          java.lang.String[] asDefault)

  Does request.getParameterValues(sName). If this returns null, this function will return asDefault

### invalidateSession

    public static void invalidateSession(javax.servlet.http.HttpSession session)

  Deletes any objects bound to a session

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD