Action Invocation
When an action is invoked (section 19) it can return a domain object, a list, a scalar, or return nothing.
Returning an Object
If the action returned an object, then the domain object representation is returned.
For example, in a todo app, accessing this resource:
http://localhost:8080/restful/objects/TODO/45/actions/updateCost/invoke
with an Accept
request header of:
Accept: application/json;profile="urn:org.apache.causeway/v2"
returns the following representation:
{
"$$href" : "http://localhost:8080/restful/objects/TODO/45",
"$$instanceId" : "45",
"$$title" : "Buy bread due by 2015-12-04",
"description" : "Buy bread",
"category" : "Domestic",
"subcategory" : "Shopping",
"complete" : false,
...
"similarTo" : [ ... ]
...
"$$ro" : { /* ... */ }
}
with a Content-Type
of:
Content-Type: application/json;profile="urn:org.apache.causeway/v2";repr-type="object"
... in other words no different to a representation obtained of the returned domain object directly.
Returning a List
On the other hand if the action returned a list (a "standalone" collection, then an array representation is returned.
This is very similar to that returned by a (parented) object collection, though with a slightly different Content-Type
to distinguish.
For example, in a todo app, accessing this resource:
http://localhost:8080/restful/services/ToDoItems/actions/notYetComplete/invoke
with an Accept
request header of:
Accept: application/json;profile="urn:org.apache.causeway/v2"
returns the following representation:
[ {
"$$href" : "http://localhost:8080/restful/objects/TODO/45",
"$$instanceId" : "45",
"$$title" : "Buy bread due by 2015-12-04",
"description" : "Buy bread",
"category" : "Domestic",
...
}, {
"$$href" : "http://localhost:8080/restful/objects/TODO/46",
"$$instanceId" : "46",
"$$title" : "Buy milk due by 2015-12-04",
"description" : "Buy milk",
"category" : "Domestic",
...
},
...
, {
"$$ro" : {
"links" : [ ... ]
"resulttype" : "list",
"result" : { /* ... */ }
"value" : [ ... ],
"links" : [ ... ],
"extensions" : { }
}
}
} ]
with a Content-Type
header:
Content-Type: application/json;profile="urn:org.apache.causeway/v2";repr-type="list"