|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |
Object Enum<Operation> hirondelle.web4j.action.Operation
public enum Operation
Type-safe enumeration for common operations.
This type-safe enumeration
is somewhat unusual, since its elements are not meant to form a strictly distinct
set. For example, one might choose to identify the same operation using
either Save
or Add
, simply according to taste. Elements may be used as
desired, but please note that isDatastoreEdit()
and hasSideEffects()
return
true only for specified items.
Many Action
implementations can benefit from using a request parameter named
'Operation', whose value corresponds to a specific subset of the members of this enumeration.
For example, ActionTemplateSearch
expects only Show
and Search
operations. See ActionImpl.getOperation()
as well.
Occasionally, you may need to define just such a subset of operations for your own actions. Typically, your code would use the following code snippets.
Define an Operation RequestParameter
in the Action
using :
public static final RequestParameter SUPPORTED_OP = RequestParameter.withRegexCheck(
"Operation",
Pattern.compile("(" + Operation.Show + "|" + Operation.Search + ")")
);
Set the value of a corresponding Operation field in the Action
constructor using :
fOperation = Operation.valueOf(aRequestParser.toString(SUPPORTED_OP));
Your Action.execute()
method will then branch according to the value of
the fOperation field.
Note regarding forms submitted by hitting the Enter key.
One must exercise care for the possible submission of forms by hitting the Enter key.
Browser behavior is not specified exactly by HTML 4, and various browsers exhibit
different behaviors. A common workaround is to place the Operation in a
HIDDEN form item, to ensure that it is always submitted, regardless of
the submission mechanism.
See as well this discussion of Submit buttons in multilingual applications.
Enum Constant Summary | |
---|---|
Activate
Activate an item. |
|
Add
Add an item to the datastore. |
|
Apply
Apply an edit to the datastore. |
|
Change
Post a change to an item to the datastore. |
|
Delete
Delete an item from the datastore. |
|
DeleteAll
Delete all items from the datastore. |
|
Display
Display a result. |
|
Do
Generic operation meant as a catch-all. |
|
Fetch
Retrieve a single item, for read-only display. |
|
FetchForAdd
Fetch items needed before adding a new item. |
|
FetchForChange
Fetch a single item, in preparation for editing the item. |
|
First
Fetch the first item in a list. |
|
Generate
Generate a result. |
|
Inactivate
Inactivate an item. |
|
Last
Fetch the last item in a list. |
|
List
Retrieve what is usually a list of many items, for read-only display. |
|
ListForChange
Retrieve what is usually a list of many items, in preparation for editing the items. |
|
Next
Fetch the next item in a list. |
|
Previous
Fetch the previous item in a list. |
|
Render
Render a result. |
|
Save
Save an edit to the datastore. |
|
Search
Search for one or more items. |
|
Show
Show an item. |
|
Start
Start some process. |
|
Stop
Stop some process. |
Method Summary | |
---|---|
boolean |
hasSideEffects()
Returns true only if this Operation isDataStoreEdit(), or is Start or Stop . |
boolean |
isDatastoreEdit()
Return true only if this Operation represents an action which has edited the datastore : Add , Change , Delete ,
DeleteAll , Save , Apply , Inactivate , or Activate . |
static Operation |
valueFor(String aOperation)
Parse a parameter value into an Operation (not case-sensitive). |
static Operation |
valueOf(String name)
Returns the enum constant of this type with the specified name. |
static Operation[] |
values()
Returns an array containing the constants of this enum type, in the order they are declared. |
Methods inherited from class Enum |
---|
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf |
Methods inherited from class Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Enum Constant Detail |
---|
public static final Operation Add
public static final Operation Change
public static final Operation Delete
public static final Operation DeleteAll
public static final Operation Save
public static final Operation Apply
public static final Operation Activate
The reverse of Inactivate
public static final Operation Inactivate
Often used to implement an abstract delete operation, where an item is nominally removed (perhaps by setting the value of a certain column), but no physical deletion of records occurs.
public static final Operation Start
The reverse of Stop
.
public static final Operation Stop
The reverse of Start
.
public static final Operation Fetch
public static final Operation FetchForChange
public static final Operation FetchForAdd
public static final Operation List
public static final Operation ListForChange
public static final Operation Show
public static final Operation Generate
public static final Operation Render
public static final Operation Display
public static final Operation Search
public static final Operation Next
public static final Operation Previous
public static final Operation First
public static final Operation Last
public static final Operation Do
Method Detail |
---|
public static Operation[] values()
for (Operation c : Operation.values()) System.out.println(c);
public static Operation valueOf(String name)
name
- the name of the enum constant to be returned.
IllegalArgumentException
- if this enum type has no constant
with the specified name
NullPointerException
- if the argument is nullpublic boolean isDatastoreEdit()
Add
, Change
, Delete
,
DeleteAll
, Save
, Apply
, Inactivate
, or Activate
.
Intended to identify actions which very likely require a redirect instead of a forward.
public boolean hasSideEffects()
Start
or Stop
.
Intended to identify cases that need a POST request.
public static Operation valueFor(String aOperation)
Similar to valueOf(java.lang.String)
, but not case-sensitive, and has alternate behavior when a problem is found.
If aOperation has no content, or has an unknown value, then a message
is logged at SEVERE level, and null is returned.
|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |