Hello Dan,

Could you assist with this problem please:

I am having problems persisting an object as a type.

I could pass the properties of the object from the client, then compose the 
object in the method getBasket(...)

But, we need to do things the right way!

Below is the error in my chrome debugger:



"invalidReason":"Expected a link (because this object's type is not a value) 
but found no 'href'"},"x-ro-invalidReason":"Basket Item is mandatory"}



The operation RO Json:


{
    "rel" : "urn:org.restfulobjects:rels/invoke",
    "href" : 
"http://localhost:8080/xxx-webapp-1.0-SNAPSHOT/restful/services/ShoppingBaskets/actions/getBasket/invoke";,
    "method" : "POST",
    "type" : 
"application/json;profile=\"urn:org.restfulobjects:repr-types/action-result\"",
    "arguments" : {
      "enterVanNumber" : {
        "value" : null
      },
      "sessionId" : {
        "value" : null
      },
      "customerId" : {
        "value" : null
      },
      "email" : {
        "value" : null
      },
      "basketItem" : {
        "value" : null
      }
    }

Method signature is below:

  @Bookmarkable
    @MemberOrder(sequence = "1")
    @Named("View Basket - rich client")
    @PublishedAction
    public final ShoppingBasket getBasket(@Named("Enter Van Number") final 
String vanNumber,
            @Named("Session ID") final String sessionID,
            @Named("Customer ID") final String customerID,
            @Named("Email") final String email,
            @Named("Basket Item") final Object obj) {
}
NB- Object obj is the argument giving me headache!

The implementation of this method casts the obj parameter to a specific type 
for the Basket Item.

In my AngularJS Controller, I am obtaining all the required params to compose 
the Basket Item, but Isis does not like the JSON I am sending to the server for 
the entity.
Below is the sample JSON sent to the RO server:

                 var basketItem=
                 {
                                   vanNumber : {
                                            id : "vanNumber",
                                            memberType: "property",
                                            value : '12344456'
                                   },
                                   startJourney : {
                                            id : "startJourney",
                                            memberType : "property",
                                            value : 'Watford'
                                   },
                                   endJourney : {
                                            id : "endJourney",
                                            memberType: "property",
                                            value : 'Coventry'
                                   }
                 };



                 var basketItemToPersist=
                 {
                                   enterVanNumber : {
                                            id : "enterVanNumber",
                                            memberType: "property",
                                            value : $scope.vanNumber
                                   },
                                   sessionId : {
                                            id : "sessionId",
                                            memberType : "property",
                                            value : '343234543636hghghgh'
                                   },
                                   customerId : {
                                            id : "customerId",
                                            memberType: "property",
                                            value : '123456'
                                   },
                                   email : {
                                            id : "email",
                                            memberType : "property",
                                            value : "[email protected]"
                                   },
                                   basketItem : {
//href:"http://localhost:8080/xxx-1.0-SNAPSHOT/restful/objects/VanItem";, ????? 
I am not sure why Isis expects a href and how to determine the href for a 
non-existing entity
                                                   id : "basketItem",
                                                    memberType : "property",
                                                    value : basketItem
                                   }
                 };



                 ShoppingBasketFactory.create(basketItemToPersist,
                                   function(data) {
                                            //Success Handler
                                            $scope.success =true;
                                            },
                                            function(error) {
                                            //Error Handler
                                            $scope.success =false;
                                            }
                 );

Thanks.

OLA TOMOLOJU


Reply via email to