org.araneaframework.jsp.tag.basic
Class BaseKeyboardHandlerTag

java.lang.Object
  extended byorg.araneaframework.jsp.tag.BaseTag
      extended byorg.araneaframework.jsp.tag.basic.BaseKeyboardHandlerTag
All Implemented Interfaces:
ContainedTagInterface, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag, javax.servlet.jsp.tagext.TryCatchFinally
Direct Known Subclasses:
FormKeyboardHandlerHtmlTag, KeyboardHandlerHtmlTag, ServerSideKeyboardHandlerHtmlTag

public abstract class BaseKeyboardHandlerTag
extends BaseTag
implements ContainedTagInterface

The base class for a set of "keyboard handler" tags. All these tags simply emit a "uiRegisterKeyboardHandler" javascript invocation. Custom subclasses should basically use the "writeRegisterKeypressHandlerScript" static method of this class to do their job.

Author:
Konstantin Tretyakov (kt@webmedia.ee)

Field Summary
protected  String defaultKey
           
protected  String defaultKeyCode
           
protected  String intKey
           
protected  String intKeyCode
           
protected  String key
           
protected  String keyCode
           
protected  String keyCombo
           
 
Fields inherited from class org.araneaframework.jsp.tag.BaseTag
GLOBAL_CONTEXT_ENTRIES_KEY, pageContext, parent
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
BaseKeyboardHandlerTag()
           
 
Method Summary
protected  int doStartTag(Writer out)
          Checks that either keyCode or key is specified (not both), and initializes the keyCode field.
static int keyToKeyCode(String key)
          Translates a "key alias" to its key-code.
 void setKey(String key)
          Key to which the event must be triggered.
 void setKeyCode(String keyCode)
           
 void setKeyCombo(String keyCombo)
           
static void writeRegisterKeycomboHandlerScript(Writer out, String scope, String keyCombo, String handler)
           
static void writeRegisterKeypressHandlerScript(Writer out, String scope, String keyCode, String handler)
          Writes "uiRegisterKeypressHandler" javascript, surrounded by <script> tags.
 
Methods inherited from class org.araneaframework.jsp.tag.BaseTag
addContextEntry, doCatch, doEndTag, doEndTag, doFinally, doStartTag, evaluate, evaluateNotNull, executeEndSubtag, executeEndTagAndUnregister, executeStartSubtag, executeSubtag, getConfiguration, getContextEntry, getContextWidget, getContextWidgetFullId, getEnvironment, getLocalizationContext, getOutputData, getParent, hideGlobalContextEntries, registerAndExecuteStartTag, registerSubtag, release, requireContextEntry, restoreGlobalContextEntries, setPageContext, setParent, unregisterSubtag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.araneaframework.jsp.tag.ContainedTagInterface
doEndTag, doFinally, doStartTag, release, setPageContext
 

Field Detail

defaultKeyCode

protected String defaultKeyCode

intKeyCode

protected String intKeyCode

keyCode

protected String keyCode

defaultKey

protected String defaultKey

intKey

protected String intKey

key

protected String key

keyCombo

protected String keyCombo
Constructor Detail

BaseKeyboardHandlerTag

public BaseKeyboardHandlerTag()
Method Detail

setKeyCode

public void setKeyCode(String keyCode)
                throws javax.servlet.jsp.JspException
Throws:
javax.servlet.jsp.JspException
Jsp.attribute:
type = "java.lang.String" required = "false" description = "Keycode to which the event must be triggered. 13 means enter. Either keyCode or key must be specified, but not both."

setKeyCombo

public void setKeyCombo(String keyCombo)
                 throws javax.servlet.jsp.JspException
Throws:
javax.servlet.jsp.JspException
Jsp.attribute:
type = "java.lang.String" required = "false" description = "Keycode to which the event must be triggered. 13 means enter. Either keyCode or key must be specified, but not both."

setKey

public void setKey(String key)
            throws javax.servlet.jsp.JspException
Key to which the event must be triggered. Similar to setKeyCode, but accepts key "aliases" instead of codes. For example, to react to the return key, you either specify keyCode = "13", or key = "enter" (but you can't specify both!). A list of available aliases is given in keyToKeyCode(java.lang.String).

Throws:
javax.servlet.jsp.JspException
See Also:
keyToKeyCode(java.lang.String)
Jsp.attribute:
type = "java.lang.String" required = "false" description = "Key, to which the event must be triggered. Key is specified as a certain 'alias'. The alias may be an ASCII character or a digit (this will denote the corresponding key on a US keyboard), a space (' '), or one of the following: 'return', 'escape', 'backspace', 'tab', 'shift', 'control', 'space', 'f1', 'f2', ..., 'f12'."

doStartTag

protected int doStartTag(Writer out)
                  throws Exception
Checks that either keyCode or key is specified (not both), and initializes the keyCode field. When overriding don't forget to invoke superimplementation first.

Overrides:
doStartTag in class BaseTag
Throws:
Exception

writeRegisterKeypressHandlerScript

public static final void writeRegisterKeypressHandlerScript(Writer out,
                                                            String scope,
                                                            String keyCode,
                                                            String handler)
                                                     throws javax.servlet.jsp.JspException,
                                                            IOException
Writes "uiRegisterKeypressHandler" javascript, surrounded by <script> tags. Throws exceptions if parameters are not consistent (e.g. keyCode not specified).

Throws:
javax.servlet.jsp.JspException
IOException

writeRegisterKeycomboHandlerScript

public static final void writeRegisterKeycomboHandlerScript(Writer out,
                                                            String scope,
                                                            String keyCombo,
                                                            String handler)
                                                     throws javax.servlet.jsp.JspException,
                                                            IOException
Throws:
javax.servlet.jsp.JspException
IOException

keyToKeyCode

public static final int keyToKeyCode(String key)
Translates a "key alias" to its key-code. Under key-code we mean the keyboard code reported by the javascript keyboard event, when the corresponding key is pushed on a usual US keyboard.

For example keyToKeyCode("A") returns 65. keyToKeyCode("RETURN") returns 13. Available key aliases are: Case does not matter. If input is invalid, zero iz returned.

Parameters:
key -
Returns:
corresponding keyCode (that is supposed