public abstract class FormHandler extends Object
| Modifier and Type | Class and Description |
|---|---|
static class | FormHandler.MessageMessage class to encapsulate the message text and the canClose flag |
| Modifier and Type | Field and Description |
|---|---|
protected String | _actionForm action |
protected RouterContext | _contextRouter context |
protected Log | _logClass logger. |
protected String | _methodRequest method |
protected Writer | _outOutput writer |
protected RequestWrapper | _requestWrapperOnly for multipart/form-data. |
protected HttpSession | _sessionHTTP session for nonce validation |
protected Map | _settingsNot for multipart/form-data, will be null |
| Constructor and Description |
|---|
FormHandler()FormHandler. |
| Modifier and Type | Method and Description |
|---|---|
String | _t(String s)Translate a string. |
String | _t(String s,
Object o)translate a string with a parameter
This is a lot more expensive than _t(s), so use sparingly. |
String | _t(String s,
Object o,
Object o2)Translate a string with two parameters. |
static String | _x(String s)Mark a string for extraction by xgettext and translation. |
protected void | addFormError(String errorMsg)Add an error message to display
Use if it does not include a link. |
protected void | addFormError(String errorMsg,
boolean canClose)Add an error message to display
Use if it does not include a link. |
protected void | addFormErrorNoEscape(String msg)Add an error message to display
Use if it includes a link or other formatting. |
protected void | addFormErrorNoEscape(String msg,
boolean canClose)Add an error message to display
Use if it includes a link or other formatting. |
protected void | addFormNotice(String msg)Add a non-error message to display
Use if it does not include a link. |
protected void | addFormNotice(String msg,
boolean canClose)Add a non-error message to display
Use if it does not include a link. |
protected void | addFormNoticeNoEscape(String msg)Add a non-error message to display
Use if it includes a link or other formatting. |
protected void | addFormNoticeNoEscape(String msg,
boolean canClose)Add a non-error message to display
Use if it includes a link or other formatting. |
String | getAllMessages()Display everything, wrap it in a div for consistent presentation |
String | getErrors()Display any error messages (processing the form if it hasn't
been yet) |
protected String | getJettyString(String key)setSettings() must have been called previously
Curses Jetty for returning arrays. |
String | getNotices()Display any non-error messages (processing the form if it hasn't
been yet) |
boolean | isAdvanced()Same as HelperBase |
protected abstract void | processForm()Implement this to perform the final processing (in turn, adding formNotice
and formError messages, etc)
Will only be called if _action is non-null and the nonce is valid. |
void | setAction(String val)Action value. |
void | setContextId(String contextId)Configure this bean to query a particular router context |
void | setNonce(String val)Nonce value. |
void | setRequestWrapper(RequestWrapper rw)Only set by formhandler.jsi for multipart/form-data |
void | setSettings(Map settings)For many forms, it's easiest just to put all the parameters here. |
void | storeMethod(String val)Call this to prevent changes using GET |
void | storeSession(HttpSession session)For nonce validation |
void | storeWriter(Writer out)Store the output writer for inline form processing. |
protected String _action
protected RouterContext _context
protected Log _log
protected String _method
protected Writer _out
protected RequestWrapper _requestWrapper
protected HttpSession _session
protected Map _settings
public String _t(String s)
s - the string to translatepublic String _t(String s, Object o)
s - string to be translated containing {0}
The {0} will be replaced by the parameter.
Single quotes must be doubled, i.e. ' -> '' in the string.o - parameter, not translated.
To translate parameter also, use _t("foo {0} bar", _t("baz"))
Do not double the single quotes in the parameter.
Use autoboxing to call with ints, longs, floats, etc.public String _t(String s, Object o, Object o2)
s - the string to translate containing {0} and {1}o - the first parametero2 - the second parameterpublic static String _x(String s)
s - the string to markprotected void addFormError(String errorMsg)
errorMsg - the error messageprotected void addFormError(String errorMsg, boolean canClose)
errorMsg - the error messagecanClose - If true, the message can be closed by the user.protected void addFormErrorNoEscape(String msg)
msg - the error messageprotected void addFormErrorNoEscape(String msg, boolean canClose)
msg - the error messagecanClose - If true, the message can be closed by the user.protected void addFormNotice(String msg)
msg - the notice messageprotected void addFormNotice(String msg, boolean canClose)
msg - the notice messagecanClose - If true, the message can be closed by the user.protected void addFormNoticeNoEscape(String msg)
msg - the notice messageprotected void addFormNoticeNoEscape(String msg, boolean canClose)
msg - the notice messagecanClose - If true, the message can be closed by the user.public String getAllMessages()
public String getErrors()
protected String getJettyString(String key)
key - the setting keypublic String getNotices()
public boolean isAdvanced()
protected abstract void processForm()
public void setAction(String val)
val - the action valuepublic void setContextId(String contextId)
contextId - beginning few characters of the routerHash, or null to pick
the first one we come across.public void setNonce(String val)
val - the nonce valuepublic void setRequestWrapper(RequestWrapper rw)
rw - the request wrapperpublic void setSettings(Map settings)
settings - the form parameterspublic void storeMethod(String val)
val - the request methodpublic void storeSession(HttpSession session)
session - the HTTP sessionpublic void storeWriter(Writer out)
out - the writer