Heuristic Method Matching

Action

SQL

REST Verb

HTML Method

URI

Invokes

Parameters

Notes

Create

Insert

PUT

POST

/my-resource

MyResource.create

...

 

Read

Select

GET

GET

/my-resource/-id

MyResource.read

...

aka FindbyId

Update

Update

POST

POST

/my-resource/-id

MyResource.update

id="id", ...

with one or more POST attributes

Delete

Delete

DELETE

POST

/my-resource/-id

MyResource.delete

id="id"

with zero POST attributes (or single delete attribute )

Welcome

Describe

n/a

GET

/my-resource

MyResource.index

...

 

Input for Create

n/a

n/a

GET

/my-resource-input

MyResource.input

...

 

Input for Update

n/a

n/a

GET

/my-resource-input/-id

MyResource.input

id="id", ...

 

Other State Read

n/a

n/a

GET

/my-resource-other(/-id)

MyResource.other

...

 

Other State Change

n/a

n/a

POST

/my-resource-other(/-id)

MyResource.other

...

 

Key

"..."

indicates that there may be other attributes passed through the POST or GET request

"-id"

is the action.name.separator followed by the value of the primary identifier for the resource (/album/-Thriller)

Not shown is the possibility that other attribute name/value pairs may follow the /-id/ field or a blank /-/ field.

  • POST /inventory/album/-/id/Thriller/artist/Michael Jackson/genre/pop
  • GET /inventory/album/-Thriller
  • POST /inventory/album/-Thriller/released/1984-12-01
  • POST /inventory/album/-Thriller

Note that whether PUT maps to create or update varies by source.

Heuristic Result Matching

  1. (on "success") my-resource-$method (e.g., -create, -read, -update, -delete, -index, -input, -other)
  2. my-resource-$result-code (e.g., "success", "cancel", "input", "error")
  3. $result-code
  4. my-resource

An "extension" to result matching would be to map default result-type to suffixes added to result codes. For example, a result code like "success.ftl" would utilize the FreeMarker result.

Heuristic Action Matching

  1. MyResource
  2. MyResourceAction
  3. My.resource
  4. MyAction.resource
  5. my-resource/Index
  6. or the package default (ActionSupport)

Settings

  • base.action.packages (action)
  • base.result.location (/WEB-INF/result)
  • create.method (create), read.method (read), update.method (update), delete.method (delete), welcome.method (index)
  • action.name.separator (-)

Resources

  • No labels

2 Comments

  1. Why /my-resource/-id instead of /my-resource/id? For example, why /album/-Thriller instead of /album/Thriller?

  2. It just seemed like

    /inventory/album/thriller/released/1984-12-01

    would be harder to parse, if we are using extensionless URIs, RESTful parameters, and automatic namespacing.

    For example, what would happen if we had a page in the /inventory/album folder named "thriller.jsp"? Should the system then look for a thriller action-method?

    Likewise, what if we are not putting all of our methods on one action class, and prefer separate classes. What happens if we have a "inventory.album.ThrillerAction" class?

    Without the separator, it just seems to me that we are opening a door where user input could be interpreted as code.

    -Ted.