RestfulController (Grails 2.3.8)
Date: 2014-04-24

Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD

## grails.rest
[Groovy] Class RestfulController

    java.lang.Object
      grails.rest.RestfulController

    @Artefact("Controller")
    @Transactional(readOnly = true)
    class RestfulController
    extends java.lang.Object

Base class that can be extended to get the basic CRUD operations needed for a RESTful API.

Authors:
  Graeme Rocher

Since:
  2.3

Property Summary
`static java.lang.Object` | `allowedMethods`
`boolean` | `readOnly`
`java.lang.Class` | `resource`
`java.lang.String` | `resourceClassName`
`java.lang.String` | `resourceName`

Constructor Summary
`RestfulController(java.lang.Class resource)`
`RestfulController(java.lang.Class resource, boolean readOnly)`

Method Summary
`protected java.lang.Integer` | `countResources()` Counts all of resources
`java.lang.Object` | `create()` Displays a form to create a new resource
`protected java.lang.Object` | `createResource(java.util.Map params)` Creates a new instance of the resource for the given parameters
`java.lang.Object` | `delete()` Deletes a resource for the given id
`java.lang.Object` | `edit()`
`protected java.util.Map` | `getParametersToBind()` The parameters that can be bound to a domain instance.
`protected boolean` | `handleReadOnly()` handles the request for write methods (create, edit, update, save, delete) when controller is in read only mode
`java.lang.Object` | `index(java.lang.Integer max)` Lists all resources up to the given maximum
`protected java.util.List` | `listAllResources(java.util.Map params)` List all of resource based on parameters
`protected void` | `notFound()`
`protected java.lang.Object` | `queryForResource(java.io.Serializable id)` Queries for a resource for the given id
`java.lang.Object` | `save()` Saves a resource
`java.lang.Object` | `show()` Shows a single resource
`java.lang.Object` | `update()` Updates a resource for the given id

Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Property Detail

### allowedMethods

    static java.lang.Object allowedMethods

### readOnly

    boolean readOnly

### resource

    java.lang.Class resource

### resourceClassName

    java.lang.String resourceClassName

### resourceName

    java.lang.String resourceName

Constructor Detail

### RestfulController

    RestfulController(java.lang.Class resource)

### RestfulController

    RestfulController(java.lang.Class resource, boolean readOnly)

Method Detail

### countResources

    protected java.lang.Integer countResources()

  Counts all of resources
  Returns:
    List of resources or empty if it doesn't exist

### create

    java.lang.Object create()

  Displays a form to create a new resource

### createResource

    protected java.lang.Object createResource(java.util.Map params)

  Creates a new instance of the resource for the given parameters
  Parameters:
    `params` - The parameters
  Returns:
    The resource instance

### delete

    @Transactional
    java.lang.Object delete()

  Deletes a resource for the given id
  Parameters:
    `id` - The id

### edit

    java.lang.Object edit()

### getParametersToBind

    protected java.util.Map getParametersToBind()

  The parameters that can be bound to a domain instance. Defaults to all, subclasses should override and customize the behavior
  Returns:
    The parameters

### handleReadOnly

    protected boolean handleReadOnly()

  handles the request for write methods (create, edit, update, save, delete) when controller is in read only mode
  Returns:
    true if controller is read only

### index

    java.lang.Object index(java.lang.Integer max)

  Lists all resources up to the given maximum
  Parameters:
    `max` - The maximum
  Returns:
    A list of resources

### listAllResources

    protected java.util.List listAllResources(java.util.Map params)

  List all of resource based on parameters
  Returns:
    List of resources or empty if it doesn't exist

### notFound

    protected void notFound()

### queryForResource

    protected java.lang.Object queryForResource(java.io.Serializable id)

  Queries for a resource for the given id
  Parameters:
    `id` - The id
  Returns:
    The resource or null if it doesn't exist

### save

    @Transactional
    java.lang.Object save()

  Saves a resource

### show

    java.lang.Object show()

  Shows a single resource
  Parameters:
    `id` - The id of the resource
  Returns:
    The rendered resource or a 404 if it doesn't exist

### update

    @Transactional
    java.lang.Object update()

  Updates a resource for the given id
  Parameters:
    id

Groovy Documentation