planetj.html
Class JavaScriptManager

java.lang.Object
  |
  +--planetj.html.JavaScriptManager

public class JavaScriptManager
extends Object

This method will manage JavaScript functionality Creation date: (5/17/2002 5:55:02 PM)


Field Summary
static String DEFAULT_JAVASCRIPT_SOURCE_PATH
           
static String JAVASCRIPT_DATE_PICKER_SOURCE_FILE_DECLARED
           
static String JAVASCRIPT_EDITABLE_SELECT_SOURCE_FILE_DECLARED
           
static String JAVASCRIPT_OPERATION_INCLUDED
           
static String JAVASCRIPT_REQUEST_VALIDATION_ENABLED
           
static String JAVASCRIPT_VALIDATION_SOURCE_FILE_DECLARED
           
static String ON_BLUR
           
static String ON_CHANGE
           
static String ON_CLICK
           
static String ON_FOCUS
           
static String ON_SELECT
           
static String RETURN_MAGIC_REQUEST
           
 
Method Summary
static StringBuffer ensureEditableSelectSourceFileIsDeclared(StringBuffer sb, javax.servlet.http.HttpServletRequest req)
          We only need to declare the JavaScript editableSelect source file once.
static StringBuffer ensureJavaScriptDatePickerSourceFileIsDeclared(StringBuffer sb, javax.servlet.http.HttpServletRequest req)
          We only need to declare the JavaScript DatePicker source file once.
static StringBuffer ensureJavaScriptOperationIsIncluded(StringBuffer html, javax.servlet.http.HttpServletRequest request)
          We only need to include JavaScript for Operations once.
static StringBuffer ensureJavaScriptValidationSourceFileIsDeclared(StringBuffer sb, javax.servlet.http.HttpServletRequest req)
          We only need to declare the JavaScript Validation source file once.
static StringBuffer generateDatePicker(StringBuffer sb, String id, Field field, javax.servlet.http.HttpServletRequest req)
          This will generate the DatePicker.
static StringBuffer generateDatePickerSourceReferences(StringBuffer sb)
          This will generate source references for DatePicker JavaScript files.
static StringBuffer generateEditableSelectSourceReferences(StringBuffer sb)
          This will generate source references for EditableSelect JavaScript files.
static StringBuffer generateOperationJavaScript(StringBuffer html)
          This will generate JavaScript used for Operations.
static StringBuffer generateValidationFieldJavaScript(StringBuffer sb, Field pField, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          This will generate the java script for a field.
static StringBuffer generateValidationSourceReferences(StringBuffer sb)
          This will generate source references for Validation JavaScript files.
static String getJavaScriptSourcePath()
          This is the path to DataEngine JavaScript files Creation date: (5/17/2002 12:37:10 PM)
static boolean isJavaScriptGlobalValidationEnabled()
          Returns whether the global value for JS Validation.
static boolean isValidatableDateFormat(String pDateFormat)
          Returns true if our date validation supports pDateFormat Creation date: (5/17/2002 6:07:32 PM)
static void setJavaScriptGlobalValidationEnabled(boolean newJavaScriptGlobalValidation)
          Sets the global value for JS Validation.
static void setJavaScriptSourcePath(String newJavaScriptSourcePath)
          This is the path to DataEngine JavaScript files Creation date: (5/17/2002 12:37:10 PM)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAVASCRIPT_OPERATION_INCLUDED

public static final String JAVASCRIPT_OPERATION_INCLUDED
See Also:
Constant Field Values

JAVASCRIPT_VALIDATION_SOURCE_FILE_DECLARED

public static final String JAVASCRIPT_VALIDATION_SOURCE_FILE_DECLARED
See Also:
Constant Field Values

JAVASCRIPT_DATE_PICKER_SOURCE_FILE_DECLARED

public static final String JAVASCRIPT_DATE_PICKER_SOURCE_FILE_DECLARED
See Also:
Constant Field Values

JAVASCRIPT_EDITABLE_SELECT_SOURCE_FILE_DECLARED

public static final String JAVASCRIPT_EDITABLE_SELECT_SOURCE_FILE_DECLARED
See Also:
Constant Field Values

JAVASCRIPT_REQUEST_VALIDATION_ENABLED

public static final String JAVASCRIPT_REQUEST_VALIDATION_ENABLED
See Also:
Constant Field Values

DEFAULT_JAVASCRIPT_SOURCE_PATH

public static final String DEFAULT_JAVASCRIPT_SOURCE_PATH

ON_CHANGE

public static final String ON_CHANGE
See Also:
Constant Field Values

ON_BLUR

public static final String ON_BLUR
See Also:
Constant Field Values

ON_FOCUS

public static final String ON_FOCUS
See Also:
Constant Field Values

ON_SELECT

public static final String ON_SELECT
See Also:
Constant Field Values

ON_CLICK

public static final String ON_CLICK
See Also:
Constant Field Values

RETURN_MAGIC_REQUEST

public static final String RETURN_MAGIC_REQUEST
See Also:
Constant Field Values
Method Detail

ensureEditableSelectSourceFileIsDeclared

public static StringBuffer ensureEditableSelectSourceFileIsDeclared(StringBuffer sb,
                                                                    javax.servlet.http.HttpServletRequest req)
We only need to declare the JavaScript editableSelect source file once. This method will check to see if its already been declared.

If for some reason you delclare the editableSelect.js file in your JSP, you could call req.setAttribute(JavaScriptManager.EDITABLE_SELECT_SOURCE_FILE_DECLARED, new Boolean(true)) and this would prevent the file from being declared twice. Creation date: (5/17/2002 8:42:14 PM)

Returns:
StringBuffer that was passed in.

ensureJavaScriptDatePickerSourceFileIsDeclared

public static StringBuffer ensureJavaScriptDatePickerSourceFileIsDeclared(StringBuffer sb,
                                                                          javax.servlet.http.HttpServletRequest req)
We only need to declare the JavaScript DatePicker source file once. This method will check to see if its already been declared.

If for some reason you delclare the datepicker.js file in your JSP, you could call req.setAttribute(JavaScriptManager.JAVASCRIPT_DATE_PICKER_SOURCE_FILE_DECLARED, new Boolean(true)) and this would prevent the file from being declared twice. Creation date: (5/17/2002 8:42:14 PM)

Returns:
StringBuffer that was passed in.

ensureJavaScriptOperationIsIncluded

public static StringBuffer ensureJavaScriptOperationIsIncluded(StringBuffer html,
                                                               javax.servlet.http.HttpServletRequest request)
We only need to include JavaScript for Operations once. This method will check to see if its already been included.


ensureJavaScriptValidationSourceFileIsDeclared

public static StringBuffer ensureJavaScriptValidationSourceFileIsDeclared(StringBuffer sb,
                                                                          javax.servlet.http.HttpServletRequest req)
We only need to declare the JavaScript Validation source file once. This method will check to see if its already been declared.

If for some reason you delclare the fieldValidation.js file in your JSP, you could call req.setAttribute(JavaScriptManager.JAVASCRIPT_VALIDATION_SOURCE_FILE_DECLARED, new Boolean(true)) and this would prevent the file from being declared twice. Creation date: (5/17/2002 11:01:55 AM)

Returns:
StringBuffer that was passed in.

generateDatePicker

public static StringBuffer generateDatePicker(StringBuffer sb,
                                              String id,
                                              Field field,
                                              javax.servlet.http.HttpServletRequest req)
                                       throws CMException
This will generate the DatePicker. Creation date: (5/17/2002 6:03:30 PM)

Parameters:
sb - java.lang.StringBuffer
Returns:
java.lang.StringBuffer
Throws:
CMException

generateDatePickerSourceReferences

public static StringBuffer generateDatePickerSourceReferences(StringBuffer sb)
This will generate source references for DatePicker JavaScript files. Creation date: (5/17/2002 6:03:30 PM)

Parameters:
sb - java.lang.StringBuffer
Returns:
java.lang.StringBuffer

generateEditableSelectSourceReferences

public static StringBuffer generateEditableSelectSourceReferences(StringBuffer sb)
This will generate source references for EditableSelect JavaScript files.

Parameters:
sb - java.lang.StringBuffer
Returns:
java.lang.StringBuffer

generateOperationJavaScript

public static StringBuffer generateOperationJavaScript(StringBuffer html)
This will generate JavaScript used for Operations.


generateValidationFieldJavaScript

public static StringBuffer generateValidationFieldJavaScript(StringBuffer sb,
                                                             Field pField,
                                                             javax.servlet.http.HttpServletRequest req,
                                                             javax.servlet.http.HttpServletResponse res)
                                                      throws CMException
This will generate the java script for a field. Creation date: (5/17/2002 6:03:30 PM)

Parameters:
sb - java.lang.StringBuffer
pField - Field
Returns:
java.lang.StringBuffer
Throws:
CMException

generateValidationSourceReferences

public static StringBuffer generateValidationSourceReferences(StringBuffer sb)
This will generate source references for Validation JavaScript files. Creation date: (5/17/2002 6:03:30 PM)

Parameters:
sb - java.lang.StringBuffer
Returns:
java.lang.StringBuffer

getJavaScriptSourcePath

public static String getJavaScriptSourcePath()
This is the path to DataEngine JavaScript files Creation date: (5/17/2002 12:37:10 PM)

Returns:
java.lang.String

isJavaScriptGlobalValidationEnabled

public static boolean isJavaScriptGlobalValidationEnabled()
Returns whether the global value for JS Validation.

JavaScript is validation on the client. We have a JavaScript file currently out in ../dataengine/js/fieldValidation.js In this file we are validating each generic field type. Refer to that file for details.

There are 3 levels of witch a user can set the JavaScript validation on or off.

1) A user can statically set a boolean on JavaScriptManager.setJavaScriptGlobalValidation(or) which will set the default for the entire JVM. This defaults to true, meaning we are enabling JavaScript validation by default. However, this global default can be overriden by ->

2) A user can set a value on the HttpServletRequest which will override the GlobalValidation. This would normally be done from a JSP or Servlet where you only want certain JSP's to use JavaScript validation. An example would be if you need to turn off JS validation for most of you Applications/JSPs, then you would set the global variable defined in 1) to false. Then if you had a few JSPs that could use JS validation, you would make a call similiar to request.setAttribute(JavaScriptManager.JAVASCRIPT_REQUEST_VALIDATION_ENABLED, new Boolean(or)); However, sometimes you need to be able to turn JS validation on and off on a field by field basis so ->

3) A user can set a value on an HTMLField which will override the GlobalValidation and the RequestValidation. You would use this in a case where you had some fields on a single JSP that needed JS validation and some that didn't. To set JS validation on a field you would call the instanceMethod HTMLField.setJavaScriptFieldValidation(or) You can ask an HTLMField if its JavaScript validation is enabled and it will consider 1), 2), and 3), above and return the appropriate boolean. You do this by calling isJavaScriptValidationEnabled(HttpServletRequest)

Creation date: (5/16/2002 1:56:31 PM)

Returns:
boolean

isValidatableDateFormat

public static boolean isValidatableDateFormat(String pDateFormat)
Returns true if our date validation supports pDateFormat Creation date: (5/17/2002 6:07:32 PM)

Parameters:
pDateFormat - java.lang.String
Returns:
boolean

setJavaScriptGlobalValidationEnabled

public static void setJavaScriptGlobalValidationEnabled(boolean newJavaScriptGlobalValidation)
Sets the global value for JS Validation.

JavaScript is validation on the client. We have a JavaScript file currently out in ../dataengine/js/fieldValidation.js In this file we are validating each generic field type. Refer to that file for details.

There are 3 levels of witch a user can set the JavaScript validation on or off.

1) A user can statically set a boolean on JavaScriptManager.setJavaScriptGlobalValidation(or) which will set the default for the entire JVM. This defaults to true, meaning we are enabling JavaScript validation by default. However, this global default can be overriden by ->

2) A user can set a value on the HttpServletRequest which will override the GlobalValidation. This would normally be done from a JSP or Servlet where you only want certain JSP's to use JavaScript validation. An example would be if you need to turn off JS validation for most of you Applications/JSPs, then you would set the global variable defined in 1) to false. Then if you had a few JSPs that could use JS validation, you would make a call similiar to request.setAttribute(JavaScriptManager.JAVASCRIPT_REQUEST_VALIDATION_ENABLED, new Boolean(or)); However, sometimes you need to be able to turn JS validation on and off on a field by field basis so ->

3) A user can set a value on an HTMLField which will override the GlobalValidation and the RequestValidation. You would use this in a case where you had some fields on a single JSP that needed JS validation and some that didn't. To set JS validation on a field you would call the instanceMethod HTMLField.setJavaScriptFieldValidation(or) You can ask an HTLMField if its JavaScript validation is enabled and it will consider 1), 2), and 3), above and return the appropriate boolean. You do this by calling isJavaScriptValidationEnabled(HttpServletRequest)

Creation date: (5/16/2002 1:56:31 PM)

Parameters:
newJavaScriptGlobalValidation - boolean

setJavaScriptSourcePath

public static void setJavaScriptSourcePath(String newJavaScriptSourcePath)
This is the path to DataEngine JavaScript files Creation date: (5/17/2002 12:37:10 PM)

Parameters:
newJavaScriptSourcePath - java.lang.String