public abstract class AbstractWidget extends Object implements Widget
| Modifier and Type | Field and Description |
|---|---|
protected static String |
METADATA_KEY_NO_CONTENT
Key to be used in the response metadata to denote that a widget has no content.
|
PARAM_WIDGET_ID| Constructor and Description |
|---|
AbstractWidget()
The initParameters() method is invoked implicitly.
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
determineOutputType()
Determine the output type based on the request
|
Object |
getAttribute(String key)
return widget attribute
|
boolean |
getBooleanParameter(String key,
boolean fallback)
Get a parameter for a key and parse it to a
boolean value |
String |
getGroupName()
Get the group name to build the url based on it.
|
int |
getIntParameter(String key)
Get a parameter for a key and parse it to a
int value |
int |
getIntParameter(String key,
int fallback)
Get a parameter for a key and parse it to a
int value |
Long[] |
getLongArrayParameter(String parameterName)
Get the value of the given parameter.
|
long |
getLongParameter(String key)
Get a parameter for a key and parse it to a
long value |
long |
getLongParameter(String key,
long fallback)
Get a parameter for a key and parse it to a
long value |
String |
getParameter(String key)
return widget parameter
|
String |
getParameter(String key,
String fallback)
return widget parameter
|
String |
getParameterEscaped(String key)
Return a parameter with all characters that are not in [A-Za-z0-9_.-] escaped with
underscore.
|
String |
getParameterEscaped(String key,
String fallback)
Like
getParameterEscaped(String) but returns the provided fallback if the parameter
is not set. |
Map<String,String> |
getParameters()
Get the parameter list
|
protected javax.servlet.http.HttpServletRequest |
getRequest()
get the request for getting some more information
|
protected javax.servlet.http.HttpServletResponse |
getResponse()
The response object the widget is working on.
|
String |
getResponseMetadata()
Return a JSON object containing arbitrary metadata the server-side widget component wants to
transmit to the client-side component as part of the current response.
|
String[] |
getStringArrayParameter(String parameterName)
Get the value of the given parameter.
|
String |
getViewIdentifier()
Get the view identifier which defines the view for rendering the widgets content
|
String |
getWidgetId()
Get the id of the current widget
|
protected abstract void |
initParameters()
abstract method hook that initializes the widget's parameters
|
boolean |
isSuccess()
Is true by default.
|
void |
setAttribute(String key,
Object value) |
void |
setGroupName(String path)
Set the group name to build the url based on it.
|
void |
setParameter(String key,
String value)
set widget parameter
|
void |
setRequest(javax.servlet.http.HttpServletRequest request)
set the http servlet request for this widget
|
void |
setResponse(javax.servlet.http.HttpServletResponse response)
set the http servlet response for this widget
|
protected void |
setResponseMetadata(String key,
Object value)
Add, remove or replace an entry in the response metadata that should be returned when
getResponseMetadata() is called. |
protected void |
setSuccess(boolean success)
Set whether the widget request was successful.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetTile, handleRequestprotected static final String METADATA_KEY_NO_CONTENT
public AbstractWidget()
protected String determineOutputType()
public Object getAttribute(String key)
getAttribute in interface Widgetkey - the parameter keypublic boolean getBooleanParameter(String key, boolean fallback)
boolean valuekey - the keyfallback - the fall back to use in case of an NumberFormatExceptionpublic String getGroupName()
getGroupName in interface Widgetpublic int getIntParameter(String key)
int valuekey - the keypublic int getIntParameter(String key, int fallback)
int valuekey - the keyfallback - the fall back to use in case of an NumberFormatExceptionpublic Long[] getLongArrayParameter(String parameterName)
parameterName - the name of the parameterpublic long getLongParameter(String key)
long valuekey - the keypublic long getLongParameter(String key, long fallback)
long valuekey - the keyfallback - the fallback to use in case of an NumberFormatExceptionpublic String getParameter(String key)
getParameter in interface Widgetkey - the parameter keypublic String getParameter(String key, String fallback)
key - the parameter keyfallback - the fallback if the parameter key doesn't existpublic String getParameterEscaped(String key)
key - the name of the parameterpublic String getParameterEscaped(String key, String fallback)
getParameterEscaped(String) but returns the provided fallback if the parameter
is not set. The fallback is processed by the escape function.key - the name of the parameter to getfallback - the fallback value if the parameter is not setpublic Map<String,String> getParameters()
getParameters in interface Widgetprotected javax.servlet.http.HttpServletRequest getRequest()
protected javax.servlet.http.HttpServletResponse getResponse()
public String getResponseMetadata()
WidgetgetResponseMetadata in interface Widgetpublic String[] getStringArrayParameter(String parameterName)
parameterName - name of the parameter keypublic String getViewIdentifier()
getViewIdentifier in interface Widgetpublic String getWidgetId()
getWidgetId in interface Widgetprotected abstract void initParameters()
public boolean isSuccess()
public void setGroupName(String path)
setGroupName in interface Widgetpath - relative path in which package this controller can be foundpublic void setParameter(String key, String value)
setParameter in interface Widgetkey - the parameter keyvalue - the parameter valuepublic void setRequest(javax.servlet.http.HttpServletRequest request)
setRequest in interface Widgetrequest - the requestpublic void setResponse(javax.servlet.http.HttpServletResponse response)
setResponse in interface Widgetresponse - the responseprotected void setResponseMetadata(String key, Object value)
getResponseMetadata() is called.key - the key of the entry to modifyvalue - the value of the metadata entry, if null the entry with the provided key will be
removedprotected void setSuccess(boolean success)
success - true if the request succeededCopyright © 2019 Communote team. All rights reserved.