public class B2BRepositoryFormHandler extends RepositoryFormHandler
For example, you can use this form handler to manage the relationship between organizations and billing addresses, automatically adding each a billing address that is created to a parent organization's list of billing addresses, and automatically removing that address from the parent organization's list when it is removed from the repository.
You use this form handler by configuring the repository id and item descriptor type of the parent item whose properties you want to manage, and configuring the name of the property you want to update when a repository item is created or deleted. This configuration is typically performed using hidden input fields in your jhtml pages, since each use of the form handler may affect a different parent item and a different property of that item.
The following properties will typically be set in a properties file
The following properties will typically be set in a jhtml file
RepositoryFormHandler
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
static java.lang.String |
MY_RESOURCE_NAME |
STATUS_ERROR_REDIRECT, STATUS_ERROR_STAY, STATUS_SUCCESS
PARAM_DEFER_FORWARD_OR_REDIRECT, PARAM_USE_FORWARDS
SERVICE_INFO_KEY
NULL_SENTINEL, REPOSITORY_ID_PROPERTY_NAME, RESOURCE_BUNDLE_NAME, UPDATE_APPEND, UPDATE_PREPEND, UPDATE_REMOVE, UPDATE_REPLACE
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
B2BRepositoryFormHandler() |
Modifier and Type | Method and Description |
---|---|
protected void |
addItemToProperty(RepositoryItem pItem,
java.lang.Object updatableProperty)
Based on whether the argument is of type Map or Collection, this method calls
addToMap or addToCollection respectively.
|
protected void |
addToCollection(RepositoryItem pItem,
java.util.Collection updatableProperty)
This method adds the newly created repository item to the Collection
property of the updateRepositoryItem.
|
protected void |
addToMap(RepositoryItem pItem,
java.util.Map updatableProperty)
This method adds the newly created repository item to the Map property of
the updateRepositoryItem.
|
protected void |
checkForRequiredProperties(DynamoHttpServletRequest pRequest)
Makes sure all the required repository item properties have
values submitted in the form.
|
protected void |
deleteItem(DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse)
Override deleteItem method to check for references to the item being
deleted by other repository items.
|
protected RepositoryItem |
getCurrentItem()
Get the repository item that this form is operating on.
|
protected java.util.Locale |
getLocale(DynamoHttpServletRequest pRequest)
Get the locale to use for user-visible error messages.
|
protected java.lang.String |
getMsgResource(java.lang.String pMessageKey,
DynamoHttpServletRequest pRequest)
Return a message from a resource file, taking into account the
locale used for user-visible messages.
|
protected java.lang.String |
getMsgResource(java.lang.String pMessageKey,
DynamoHttpServletRequest pRequest,
java.lang.Object pArg)
Return a message from a resource file, taking into account the
locale used for user-visible messages and substituting the value
of a specified argument for the {0} placeholder in the message text.
|
java.lang.String[] |
getRequiredFields()
Return the list of required property names.
|
static java.lang.String |
getResourceBundleName()
Return the name of the resource bundle to use for this class.
|
protected MutableRepositoryItem |
getUpdatableItem()
Get a mutable version of the repository item whose id
updateRepositoryId and whose type is
updateItemDescriptorName . |
protected java.lang.Object |
getUpdatableProperty()
Get the property of the update repository item that is to be updated
when a new repository item is created.
|
java.lang.String |
getUpdateItemDescriptorName()
Return the item descriptor name for the item specified by
updateRepositoryId . |
java.lang.String |
getUpdateKey()
Return the key that identifies the map entry to modify, in cases
where
updatePropertyName specifies a map-valued property. |
java.lang.String |
getUpdatePropertyName()
Return the property of the update item to modify when this form
handler creates or deletes a repository item.
|
java.lang.String |
getUpdateRepositoryId()
Return the repository id of a "container" or "parent" item that may
be updated automatically whenever a repository item is created or
deleted by this form handler.
|
java.lang.String |
getUserLocale()
Return the preferred Locale for user-vislble error messages.
|
static boolean |
isBlank(java.lang.String pStr)
Return true if pStr is null, the empty string, or consists
entirely of whitespace where whitespace is defined by the
String.trim method.
|
protected void |
postCreateItem(DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse)
This method is called just after a new repository item has been
created to add the new item to some property of the update item.
|
protected void |
preCreateItem(DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse)
This method is called just before the item creation process is
started to verify that all required properties have been specified
in the form.
|
protected void |
preDeleteItem(DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse)
This method is called just before a repository item is deleted
to remove the item from some property of the update item.
|
protected void |
preUpdateItem(DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse)
This method is called just before the an item is updated to verify
that all required properties have been specified in the form.
|
protected void |
removeFromCollection(RepositoryItem pItem,
java.util.Collection updatableProperty)
This method removes a specified repository item from a specified collection.
|
protected void |
removeFromMap(RepositoryItem pItem,
java.util.Map updatableProperty)
This method removes a specified repository item from a specified map.
|
protected void |
removeItemFromProperty(RepositoryItem pItem,
java.lang.Object updatableProperty)
Based on whether the argument is of type Map or Collection, this method calls
removeFromMap or removeFromCollection respectively.
|
void |
setRequiredFields(java.lang.String[] pRequiredFields)
Specify a list of property names that must be set by the form
using this form handler.
|
void |
setUpdateItemDescriptorName(java.lang.String pUpdateItemDescriptorName)
Set the item descriptor name for the item specified by
updateRepositoryId . |
void |
setUpdateKey(java.lang.String pUpdateKey)
Set the key that identifies the map entry to modify, in cases
where
updatePropertyName specifies a map-valued property. |
void |
setUpdatePropertyName(java.lang.String pPropertyName)
Set the property of the update item to modify when this form
handler creates or deletes a repository item.
|
void |
setUpdateRepositoryId(java.lang.String pUpdateRepositoryId)
Set the repository id of a "container" or "parent" item that may
be updated automatically whenever a repository item is created or
deleted by this form handler.
|
void |
setUserLocale(java.lang.String pUserLocale)
Set the preferred Locale for user-vislble error messages.
|
checkFormError, checkFormSuccess, checkForRequiredProperties, getCheckForReadOnlyProperties, getCheckForRequiredProperties, getContentItemDescriptor, getContentNameProperty, getContentPathProperty, getCreateErrorURL, getCreateSuccessURL, getDeleteErrorURL, getDeleteSuccessURL, getEditMapsAsLists, getErrorHandler, getExtractDefaultValuesFromItem, getFolderIdProperty, getItemDescriptor, getItemDescriptorName, getItemProperty, getLogger, getMapKeyValueSeparator, getRemoveReferencesToDeletedItems, getRepository, getRepositoryId, getRepositoryItem, getRepositoryItemEditor, getRepositoryPathName, getRequireIdOnCreate, getSpecifiedIdPropertyValue, getTransactionDemarcation, getTransactionManager, getTrimProperties, getUpdateErrorURL, getUpdateSuccessURL, getValue, getValueProperty, handleCreate, handleDelete, handleUpdate, isClearValueOnSet, isCreateTransientItems, isRequireMapKeys, isSortRepositoryItemSets, isTrimProperty, isUpdateItemsInCollection, postDeleteItem, postUpdateItem, postUpdateItemProperties, setCheckForReadOnlyProperties, setCheckForRequiredProperties, setClearValueOnSet, setContentNameProperty, setContentPathProperty, setCreateErrorURL, setCreateSuccessURL, setCreateTransientItems, setDeleteErrorURL, setDeleteSuccessURL, setEditMapsAsLists, setExtractDefaultValuesFromItem, setFolderIdProperty, setItemDescriptorName, setMapKeyValueSeparator, setRemoveReferencesToDeletedItems, setRepository, setRepositoryId, setRepositoryItemEditor, setRepositoryPathName, setRequireIdOnCreate, setRequireMapKeys, setSortRepositoryItemSets, setTrimProperties, setUpdateErrorURL, setUpdateItemsInCollection, setUpdateSuccessURL, setValueProperty, testPropertyAttribute, updateChildItemProperty, updateContentItemValues, updateItem, updateItemProperties, updateListProperty, updateMapProperty
addFormException, addUncheckedFormException, afterSet, beforeSet, checkFormRedirect, createFormSubmissionMessage, getCancelURL, getCheckForValidSession, getFormError, getFormExceptions, getFormName, getMessagePort, getMessageSource, getMessageType, getPropertyExceptions, getSendMessages, getUncheckedFormExceptions, handleCancel, handleFormException, handleUncheckedFormException, hasUncheckedFormExceptions, isDeferForwardsAndRedirects, isRestorableForm, isUseForwards, isValidSession, redirectOrForward, resetFormExceptions, setCancelURL, setCheckForValidSession, setDeferForwardsAndRedirects, setFormName, setMessagePort, setMessageSource, setMessageType, setRestorableForm, setSendMessages, setUseForwards
afterGet, beforeGet
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 java.lang.String MY_RESOURCE_NAME
public java.lang.String getUpdateRepositoryId()
public void setUpdateRepositoryId(java.lang.String pUpdateRepositoryId)
public java.lang.String getUpdateItemDescriptorName()
updateRepositoryId
.public void setUpdateItemDescriptorName(java.lang.String pUpdateItemDescriptorName)
updateRepositoryId
.public java.lang.String getUpdatePropertyName()
updateRepositoryId
refers to a repository item of
type Organization, and the updatePropertyName
is
billingAddresses, then creating a new repository item
will automatically add it to that organization's
billingAddresses
property, and removing a repository
item will automatically remove it from that organization's
billingAddresses
.
public void setUpdatePropertyName(java.lang.String pPropertyName)
public java.lang.String getUpdateKey()
updatePropertyName
specifies a map-valued property.public void setUpdateKey(java.lang.String pUpdateKey)
updatePropertyName
specifies a map-valued property.public java.lang.String[] getRequiredFields()
public void setRequiredFields(java.lang.String[] pRequiredFields)
public java.lang.String getUserLocale()
public void setUserLocale(java.lang.String pUserLocale)
public static java.lang.String getResourceBundleName()
protected void checkForRequiredProperties(DynamoHttpServletRequest pRequest)
RepositoryException
- if there was an error while
accessing the repositoryprotected void preCreateItem(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws javax.servlet.ServletException, java.io.IOException
preCreateItem
in class RepositoryFormHandler
pRequest
- the servlet's requestpResponse
- the servlet's responsejavax.servlet.ServletException
- if there was an error while executing
the codejava.io.IOException
- if there was an error with servlet ioprotected void preUpdateItem(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws javax.servlet.ServletException, java.io.IOException
preUpdateItem
in class RepositoryFormHandler
pRequest
- the servlet's requestpResponse
- the servlet's responsejavax.servlet.ServletException
- if there was an error while executing
the codejava.io.IOException
- if there was an error with servlet ioprotected void postCreateItem(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws javax.servlet.ServletException, java.io.IOException
updateRepositoryId
and the property identified by updatePropertyName
, then
calls addItemToProperty
to add the new item to the named
property of the existing item.postCreateItem
in class RepositoryFormHandler
pRequest
- the servlet's requestpResponse
- the servlet's responsejavax.servlet.ServletException
- if there was an error while executing
the codejava.io.IOException
- if there was an error with servlet ioprotected void preDeleteItem(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws javax.servlet.ServletException, java.io.IOException
updateRepositoryId
and the property identified by
updatePropertyName
, then calls
removeItemFromProperty
to remove the item being
deleted from that property of the existing item.preDeleteItem
in class RepositoryFormHandler
pRequest
- the servlet's requestpResponse
- the servlet's responsejavax.servlet.ServletException
- if there was an error while executing
the codejava.io.IOException
- if there was an error with servlet ioprotected void deleteItem(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws javax.servlet.ServletException, java.io.IOException
deleteItem
in class RepositoryFormHandler
pRequest
- the servlet's requestpResponse
- the servlet's responsejavax.servlet.ServletException
- if there was an error while executing
the codejava.io.IOException
- if there was an error with servlet ioprotected void addItemToProperty(RepositoryItem pItem, java.lang.Object updatableProperty)
protected void addToMap(RepositoryItem pItem, java.util.Map updatableProperty)
protected void addToCollection(RepositoryItem pItem, java.util.Collection updatableProperty)
protected void removeItemFromProperty(RepositoryItem pItem, java.lang.Object updatableProperty)
protected void removeFromMap(RepositoryItem pItem, java.util.Map updatableProperty)
protected void removeFromCollection(RepositoryItem pItem, java.util.Collection updatableProperty)
protected RepositoryItem getCurrentItem() throws RepositoryException
RepositoryException
protected MutableRepositoryItem getUpdatableItem() throws RepositoryException
updateRepositoryId
and whose type is
updateItemDescriptorName
.RepositoryException
protected java.lang.Object getUpdatableProperty() throws RepositoryException
RepositoryException
protected java.lang.String getMsgResource(java.lang.String pMessageKey, DynamoHttpServletRequest pRequest)
atg.core.util.getMsgResource
protected java.lang.String getMsgResource(java.lang.String pMessageKey, DynamoHttpServletRequest pRequest, java.lang.Object pArg)
atg.core.util.getMsgResource
protected java.util.Locale getLocale(DynamoHttpServletRequest pRequest)
userLocale
property if set, otherwise
returns the request locale from pRequest
if set, otherwise
returns the default server locale.public static boolean isBlank(java.lang.String pStr)
String