java.lang.Objectorg.apache.struts.action.Action
org.apache.struts.actions.DispatchAction
net.jspcontrols.dialogs.actions.SelectAction
net.jspcontrols.dialogs.actions.DialogAction
net.jspcontrols.dialogs.actions.crud.CRUDAction
CRUDAction facilitates the processing of the common use case of an interactive application: creation, update and deletion of a business object (BO). Business object is also called item
CRUDAction
has the following features:
These features are ihnerited from DialogAction:
CRUDAction has a notion of current item. It is an existing item, which is being viewed or edited, or a new item, which just has been created and is being filled out. In other words, current item is the item we currently working with.
If current item does not exist, CRUDAction
is switched
to inactive
state. It is possible to switch to one of two
active states, by doing one of the following:
After we created a new item or started to edit an existing one,
CRUDAction switches to one of the active states: editable
or readonly
. Editable
state permits to update
item data. Readonly
state is used for preview mode and may
help to optimize item caching.
CRUDAction must be paired with a form bean, implementing ICRUDForm, to deliver its full power. See sample code for an example of how a concrete CRUDAction can be implemented
Field Summary |
Fields inherited from class net.jspcontrols.dialogs.actions.SelectAction |
keyMethodMap |
Fields inherited from class org.apache.struts.actions.DispatchAction |
clazz, log, messages, methods, types |
Fields inherited from class org.apache.struts.action.Action |
defaultLocale, servlet |
Constructor Summary | |
CRUDAction()
|
Method Summary | |
org.apache.struts.action.ActionForward |
getDialogView(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Returns an ActionForward instance describing the View
for current dialog state, usually a forward to a JSP page. |
protected java.util.Map |
getKeyMethodMap()
Maps submit button names to handler methods; also maps initialization keys to initialization methods. |
org.apache.struts.action.ActionForward |
onCancel(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Cancels filling it new item, or editing existing item without saving it. |
org.apache.struts.action.ActionForward |
onClose(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Closes business item preview page. |
org.apache.struts.action.ActionForward |
onCreate(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Creates new item. |
org.apache.struts.action.ActionForward |
onDelete(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Deletes existing item. |
org.apache.struts.action.ActionForward |
onDuplicate(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Creates new item based on existing item. |
org.apache.struts.action.ActionForward |
onEdit(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Updates existing item. |
org.apache.struts.action.ActionForward |
onPreview(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Previews existing item. |
org.apache.struts.action.ActionForward |
onReset(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Resets form content. |
org.apache.struts.action.ActionForward |
onSave(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Event handler for Save button, persists form data. |
Methods inherited from class net.jspcontrols.dialogs.actions.DialogAction |
clearMessages, execute, execute, getActionSuffix, getMethodName, isBogusGET, isInit, isInput, saveDialogErrors, setNoCache |
Methods inherited from class net.jspcontrols.dialogs.actions.SelectAction |
buildLookupMap, cancelled, execute, getCancelKey, getDefaultKey, getInitKey, getMethod, resolveEvents, unspecified |
Methods inherited from class org.apache.struts.actions.DispatchAction |
dispatchMethod, getMethod |
Methods inherited from class org.apache.struts.action.Action |
addErrors, addMessages, execute, generateToken, getDataSource, getDataSource, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.jspcontrols.dialogs.actions.ISelectAction |
cancelled, unspecified |
Constructor Detail |
public CRUDAction()
Method Detail |
protected java.util.Map getKeyMethodMap()
If you do not want to use all CRUD handlers, and want to protect yourself from calling unneeded handler, you can subclass this class, and override this method. Then you define only mappings that you need.
getKeyMethodMap
in class DialogAction
SelectAction.getInitKey()
public org.apache.struts.action.ActionForward onCreate(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
java.lang.Exception
CRUDConstants.MAPPING_ON_CREATE_SUCCESS
,
CRUDConstants.MAPPING_ON_CREATE_FAILURE
public org.apache.struts.action.ActionForward onDuplicate(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
java.lang.Exception
CRUDConstants.MAPPING_ON_DUPLICATE_SUCCESS
,
CRUDConstants.MAPPING_ON_DUPLICATE_FAILURE
public org.apache.struts.action.ActionForward onEdit(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
java.lang.Exception
CRUDConstants.MAPPING_ON_EDIT_SUCCESS
,
CRUDConstants.MAPPING_ON_LOAD_FAILURE
public org.apache.struts.action.ActionForward onPreview(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
java.lang.Exception
CRUDConstants.MAPPING_ON_PREVIEW_SUCCESS
,
CRUDConstants.MAPPING_ON_LOAD_FAILURE
public org.apache.struts.action.ActionForward onDelete(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
java.lang.Exception
CRUDConstants.MAPPING_ON_DELETE_SUCCESS
,
CRUDConstants.MAPPING_ON_DELETE_FAILURE
public org.apache.struts.action.ActionForward onCancel(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
java.lang.Exception
CRUDConstants.MAPPING_ON_CANCEL
public org.apache.struts.action.ActionForward onReset(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
java.lang.Exception
CRUDConstants.MAPPING_ON_RESET_SUCCESS
,
CRUDConstants.MAPPING_ON_RESET_FAILURE
public org.apache.struts.action.ActionForward onClose(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
java.lang.Exception
CRUDConstants.MAPPING_ON_CLOSE
public org.apache.struts.action.ActionForward onSave(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
Internally, this method calls two methods on associated form bean:
standard validate
method to check input data,
and crudStore
method to persist input data if it is valid.
Both form bean methods should return non-empty ActionMessages object to signal that either validation or persisting was unsuccessful.
Since this method handles POST requests, the outcome mappings for this method should use redirection to avoid double submit situations and POSTDATA messages.
mapping
- The ActionMapping used to select this instanceform
- The optional ActionForm bean for this request (if any)request
- The HTTP request we are processingresponse
- The HTTP response we are creating
ActionForward
instance describing where and how
control should be handed over, or null
to reload
the same action using GET request.
java.lang.Exception
- if an exception occurspublic org.apache.struts.action.ActionForward getDialogView(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
ActionForward
instance describing the View
for current dialog state, usually a forward to a JSP page.
If you want to use the default implementation, define the View under "DIALOG-VIEW" name in <forward> element of your action mapping.
To use different mapping name, define the view in <forward> element of your action mapping, and override this method to return ActionForward object for your mapping name.
getDialogView
in interface IDialogAction
getDialogView
in class DialogAction
mapping
- The ActionMapping used to select this instanceform
- The optional ActionForm bean for this request (if any)request
- The HTTP request we are processingresponse
- The HTTP response we are creating
java.lang.Exception
- if an exception occurs