java.lang.Object
net.i2p.router.web.FormHandler
net.i2p.router.web.helpers.ConfigSidebarHandler
Simple sidebar configuration handler.
Nested Class Summary
Nested classes/interfaces inherited from class FormHandler
FormHandler.MessageModifier and TypeClassDescriptionstatic classMessage class to encapsulate the message text and the canClose flag.Field Summary
FieldsFields inherited from class FormHandler
_action, _context, _log, _method, _out, _requestWrapper, _session, _settingsModifier and TypeFieldDescriptionprotected StringForm action.protected RouterContextRouter context.protected LogClass logger.protected StringRequest method.protected WriterOutput writer.protected RequestWrapperOnly for multipart/form-data.protected HttpSessionHTTP session for nonce validation.protected MapNot for multipart/form-data, will be null.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionprivate StringgetJettyStringOrDefault(String key, String defaultVal) Reads a Jetty config value.private voidhandleAddSection(Map<Integer, String> sections) Adds a sidebar section from the form.private voidhandleDeleteSections(Map<Integer, String> sections) Deletes the sections marked in the form.private voidSaves the sidebar graph settings.private voidhandleMoveSection(Map<Integer, String> sections) Moves one sidebar section.private voidhandleSave(boolean currentUnifiedSidebar, boolean currentStickySidebar) Saves the sidebar settings from the form.voidmoveSection(String action) Moves, adds, deletes, or saves sidebar sections ordering based on the requested action.private intparseRefreshInterval(String refreshStr) Parses the graph refresh interval from the form.protected voidProcesses the form submission from the sidebar configuration page.private voidrestoreDefault(boolean full) Restores the default sidebar settings.voidScans settings to detect move button actions and sets the _action field accordingly.Methods inherited from class FormHandler
_t, _t, _t, _x, addFormError, addFormError, addFormErrorNoEscape, addFormErrorNoEscape, addFormNotice, addFormNotice, addFormNoticeNoEscape, addFormNoticeNoEscape, getAllMessages, getErrors, getJettyString, getNotices, isAdvanced, resolveEffectiveAction, setAction, setContextId, setNonce, setRequestWrapper, setSettings, storeMethod, storeSession, storeWriterModifier and TypeMethodDescriptionTranslate a string.Translate a string with a parameter This is a lot more expensive than _t(s), so use sparingly.Translate a string with two parameters.static StringMark a string for extraction by xgettext and translation.protected voidaddFormError(String errorMsg) Add an error message to display Use if it does not include a link.protected voidaddFormError(String errorMsg, boolean canClose) Add an error message to display Use if it does not include a link.protected voidAdd an error message to display Use if it includes a link or other formatting.protected voidaddFormErrorNoEscape(String msg, boolean canClose) Add an error message to display Use if it includes a link or other formatting.protected voidaddFormNotice(String msg) Add a non-error message to display Use if it does not include a link.protected voidaddFormNotice(String msg, boolean canClose) Add a non-error message to display Use if it does not include a link.protected voidAdd a non-error message to display Use if it includes a link or other formatting.protected voidaddFormNoticeNoEscape(String msg, boolean canClose) Add a non-error message to display Use if it includes a link or other formatting.Display everything, wrap it in a div for consistent presentation.Display any error messages (processing the form if it hasn't been yet).protected StringgetJettyString(String key) FormHandler.setSettings(Map)must have been called previously Curses Jetty for returning arrays.Display any non-error messages (processing the form if it hasn't been yet).booleanSame as HelperBase.static StringresolveEffectiveAction(String action, Map<?, ?> settings) Resolve which operation the user actually requested.voidAction value.voidsetContextId(String contextId) Configure this bean to query a particular router context.voidNonce value.voidOnly set by formhandler.jsi for multipart/form-data.voidsetSettings(Map settings) For many forms, it's easiest just to put all the parameters here.voidstoreMethod(String val) Call this to prevent changes using GET.voidstoreSession(HttpSession session) For nonce validation.voidstoreWriter(Writer out) Store the output writer for inline form processing.
Field Details
ORDER_PREFIX
Form field prefix of the section ordering.- See Also:
DELETE_PREFIX
Form field prefix of the section deletions.- See Also:
MOVE_PREFIX
Form field prefix of the section moves.- See Also:
Constructor Details
ConfigSidebarHandler
public ConfigSidebarHandler()ConfigSidebarHandler default constructor.
Method Details
processForm
protected void processForm()Processes the form submission from the sidebar configuration page. Handles add, delete, move, save order, and restore defaults actions. Delegates to helper methods as appropriate.- Specified by:
processFormin classFormHandler
handleSave
private void handleSave(boolean currentUnifiedSidebar, boolean currentStickySidebar) Saves the sidebar settings from the form.- Parameters:
currentUnifiedSidebar- true if the unified sidebar is on nowcurrentStickySidebar- true if the sticky sidebar is on now
handleGraphSave
private void handleGraphSave()Saves the sidebar graph settings.parseRefreshInterval
Parses the graph refresh interval from the form.- Parameters:
refreshStr- the string from the form- Returns:
- the interval, in seconds
- Throws:
NumberFormatException- if it is not a number
getJettyStringOrDefault
restoreDefault
private void restoreDefault(boolean full) Restores the default sidebar settings.- Parameters:
full- true to restore the sections as well
moveSection
Moves, adds, deletes, or saves sidebar sections ordering based on the requested action. Updates the sidebar sections order and persists the changes.- Parameters:
action- the resolved fixed action value (additem, deleteitems, or move_N)
handleAddSection
handleDeleteSections
handleMoveSection
setMovingAction
public void setMovingAction()Scans settings to detect move button actions and sets the _action field accordingly.