[ https://issues.apache.org/jira/browse/ISIS-917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14235980#comment-14235980 ]
Dan Haywood commented on ISIS-917: ---------------------------------- Just wanting to progress/close off this thread. Although you've posted your custom representation service, the error you're raising is really in the validation of the arguments, all of which happens before RO delegates off your service, I've been able to reproduce the behaviour you've described, but I don't think it's an error. Here's what I did: In the SimpleObjects service (part of simpleapp example/archetype), I added: @Bookmarkable @ActionSemantics(Of.SAFE) @MemberOrder(sequence = "1") public List<SimpleObject> list(final @Named("name") String name) { return Lists.newArrayList(Iterables.filter( listAll(), new Predicate<SimpleObject>() { @Override public boolean apply(final SimpleObject input) { return input.getName().contains(name); } })); } With the default fixture data, this will match 1 element if called with an 'F', and 2 elements if called with a 'B': http://localhost:8080/restful/services/SimpleObjects/actions/list/invoke?name=F or http://localhost:8080/restful/services/SimpleObjects/actions/list/invoke?name=B As you report though, calling this with a number fails: http://localhost:8080/restful/services/SimpleObjects/actions/list/invoke?name=1 will give: { name: { value: 1, invalidReason: "is not a string" }, x-ro-invalidReason: "'name' is mandatory" } However, you can add quotes and it'll work: http://localhost:8080/restful/services/SimpleObjects/actions/list/invoke?name= "1" URL encoded this is: http://localhost:8080/restful/services/SimpleObjects/actions/list/invoke?name=%221%22 ~~~ All that said, do be aware that invoking actions on the command line is only provided as a "convenience" for @ActionSemantics(Of.SAFE) queries, to be easily invoked by a human. But there is also the limitation that any arguments must be simple scalars; it isn't possible to invoke an action that has a reference to another object (ie as an href) using this mechanism. And it doesn't support PUT (idempotent) or POST (non-idempotent) actions. However, the RO spec does define a fully general purpose way of invoking actions that (a) do allow arguments that are references to other objects, and (b) can be PUT or POST... the contents is in the body, not the query string. Basically, the general form is a URL encoded JSON object, as provided in the "action prompt" resource. So, for the example above, the arguments map is: "name": { "value": null } which by following the "describedby" link ( http://localhost:8080/restful/domain-types/dom.simple.SimpleObjects/actions/list) one can discover that "name" is of type string. Anyway... the general purpose way to invoke this action (ie as I intend that a computer program would invoke it) is to URL encode this string and pass as either the query string or the body. Thus: "name": { "value": "B" } encodes to: %7B%22name%22%3A%7B%22value%22%3A%22B%22%7D%7D which can then be invoked using: http://localhost:8080/restful/services/SimpleObjects/actions/list/invoke?%7B%22name%22%3A%7B%22value%22%3A%22B%22%7D%7D This will produce the same results as: http://localhost:8080/restful/services/SimpleObjects/actions/list/invoke?name= "F" ~~~ So, all that said, I don't think there's an issue. The short answer is to use quotes around anything that might be interpreted as an int; the long answer is that a computer program should be using the URL encoded JSON map. HTH Dan On 28 October 2014 at 10:55, Vladimir Nisevic (JIRA) <j...@apache.org> > Support pluggable representations for the RO viewer (object and list > representations) > ------------------------------------------------------------------------------------- > > Key: ISIS-917 > URL: https://issues.apache.org/jira/browse/ISIS-917 > Project: Isis > Issue Type: New Feature > Components: Core: Viewer: RestfulObjects > Affects Versions: core-1.6.0 > Reporter: Dan Haywood > Fix For: core-1.7.0 > > > This ticket is to factor out the logic in the RO viewer that builds the JSON > representation and put it behind a @DomainService. > As a first cut, I think it's only the object representation and list > representations that need to be pluggable. > Ultimately I would like to get to a point where the representation used > honours the Accept header (Content-Type), but will probably iterate to get > there. -- This message was sent by Atlassian JIRA (v6.3.4#6332)