Hi Vladimir,

Sorry no-one came back to you on this... did you find a solution?

I have two ideas.

First, since in this case the view model is basically just two lsts of
strings, probably the REST API ought to be able to support actions with
collections as parameters.  I know that the Wicket viewer supports
parameter collections, but I'm pretty sure that the RO viewer doesn't,
unfortunately.  Maybe that's a ticket that ought to be raised and
implemented.

Second idea... rather than try to "upload" the OffterTemplateFilter view
model as a parameter, instead treat it as a resource.  That is, have a new
service to create an instance of the filter, and then update this filter
(adding/removing from its two collections).  When done, pass a reference to
the filter to the original REST service, as a regular reference.
(Obviously the URL will be rather long and messy, but that's not a problem
per-se).

HTH
Dan




On Thu, 5 Oct 2017 at 13:58 Vladimir Nišević <vnise...@gmail.com> wrote:

> I must provide a REST service accepting more complex view model as input
> parameter.
>
> My view model parameter would look like
>
> @DomainObject(nature = Nature.VIEW_MODEL, objectType =
> "OfferTemplateFilter")
> @XmlRootElement(name = "OfferTemplateFilter")
> @XmlAccessorType(XmlAccessType.FIELD)
> @Getter @Setter
> public class OfferTemplateFilter {
>
>     public OfferTemplateFilter() {
>     }
>
>     public List<String> selectedDeviceManufacturer = new ArrayList<>();
>
>     public List<String> selectedDeviceSizes = new ArrayList<>();
>
> }
>
> My REST domain service would be someting like
>
> @DomainService(nature = NatureOfService.VIEW_REST_ONLY, objectType =
> "OfferRestService")
> public class OfferRestService {
>
>      @Action(semantics = SemanticsOf.IDEMPOTENT)
>     public OfferTemplateSelectorForCustomer
> offerSelectorForCustomer(final String subscriberNumber, final
> OfferTemplateFilter filter) {
>         return offerSelectorRepository.create(subscriberNumber, filter);
>     }
>
>  ....
> }
>
>
> I'm wondering how this could be achieved without custom rest service.
> Ideally the service consumer would post a kind of JSON structure where my
> view model OfferTemplateFilter would be created?
>
> Any hint on this?
>
> Thanks
> Vladimir
>

Reply via email to