public class MapToArrayDefaultFirst extends DynamoServlet
This droplet is used to convert a map of items to a sorted array of map entries with the default item in the beginning of the array. The default item is specified either through defaultId parameter (only for repository items) or through defaultKey parameter that is the map key that corresponds to the default item.
The droplet is primarily intended to sort shipping addresses or credit cards so that the default address or card is displayed as the first item on the JSP page.
If sortByKeys parameter is set to true then the returning array will be sorted by keys otherwise an unsorted array will be returned. In the case of a null map, the returning array would be null.
This droplet takes the following parameters
<dsp:droplet name="MapToArrayDefaultFirst"> <param name="defaultId" value="Profile.shippingAddress.repositoryId"/> <param name="map" value="Profile.secondaryAddresses"/> <oparam name="output"> <dsp:droplet name="ForEach"> <param name="array" value="sortedArray"/> <oparam name="output"> key: <dsp:valueof param="element.key"/> address city: <dsp:valueof param="element.value.city">/> </oparam> </dsp:droplet> </oparam>> </droplet>
Output parameters
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string.
|
static ParameterName |
DEFAULT_ID
Default id parameter name.
|
static ParameterName |
DEFAULT_KEY
Default key parameter name.
|
static ParameterName |
EMPTY
Empty parameter name.
|
static ParameterName |
MAP
Map parameter name.
|
static ParameterName |
OUTPUT
Output parameter name.
|
static ParameterName |
SORT_BY_KEYS
Sort by keys parameter name
|
static java.lang.String |
SORTED_ARRAY
Sorted array parameter name.
|
static java.lang.String |
SORTED_ARRAY_SIZE
Sorted array size parameter name.
|
mAllowCleanupRequest, mParameters
SERVLET_INFO_KEY
SERVICE_INFO_KEY
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
MapToArrayDefaultFirst() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
getDefaultMapKey(java.util.Map pMap,
java.lang.String pDefaultId)
Taken the map of repository items and default ID value returns a
map key that corresponds to the item with the specified repository ID.
|
protected java.lang.Object[] |
getSortedArray(java.util.Map pMap,
java.lang.String pDefaultKey,
boolean pSortByKeys,
DynamoHttpServletRequest pRequest)
Converts the map to the array of map entries with the default one in the beginning of the array.
|
void |
service(DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse)
See the class documentation above.
|
doDelete, doGet, doPost, doPut, getParameter, getParameters, getServletContext, init, service, service, setParameter
destroy, getServletConfig, getServletInfo, setServletInfo
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
public static java.lang.String CLASS_VERSION
public static final ParameterName MAP
public static final ParameterName DEFAULT_ID
public static final ParameterName DEFAULT_KEY
public static final ParameterName SORT_BY_KEYS
public static final ParameterName OUTPUT
public static final ParameterName EMPTY
public static java.lang.String SORTED_ARRAY
public static java.lang.String SORTED_ARRAY_SIZE
public void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws javax.servlet.ServletException, java.io.IOException
See the class documentation above.
service
in class DynamoServlet
pRequest
- - http requestpResponse
- - http responsejavax.servlet.ServletException
- if an error occursjava.io.IOException
- if an error occursprotected java.lang.Object[] getSortedArray(java.util.Map pMap, java.lang.String pDefaultKey, boolean pSortByKeys, DynamoHttpServletRequest pRequest)
pSortByKeys
boolean is true then map entries are sorted by keys.pMap
- - the map to convert to the sorted arraypDefaultKey
- - the map key that corresponds to the default itempSortByKeys
- - boolean that specifies whether to sort items by keys or notpRequest
- - the http requestprotected java.lang.String getDefaultMapKey(java.util.Map pMap, java.lang.String pDefaultId)
pMap
- - map of repository items to checkpDefaultId
- - default id