PDA

View Full Version : How to call custom api which is specified in the proxy in the model



nohsib
7 Aug 2012, 8:17 AM
Hi,
My model has a proxy like this :


proxy:
{
type: 'rest',
url: '<service>',
api:{
read:'<read_service>',
update:'<update_service>',
create:'<create_service>'
},
reader:
{
type: 'json',
root: 'List.elements.collection'
},
writer: {
type: 'json',
nameProperty: 'mapping',
root: 'VO'
}
}


When I call save on the model, based on the idProperty, the model decides to call the create (idProperty=0)or update(idProperty!=0). Now if I have new services like Enable and Disable, as below. Then how do I call/invoke the enable and/or disable service.


proxy:
{
type: 'rest',
url: '<service>',
api:{
read:'<read_service>',
update:'<update_service>',
create:'<create_service>',
enable:'<enable_service>',
disable:'<enable_service>'
},
reader:
{
type: 'json',
root: 'List.elements.collection'
},
writer: {
type: 'json',
nameProperty: 'mapping',
root: 'VO'
}
}



thanks
Nohsib

friend
7 Aug 2012, 9:21 AM
It would be a lot simpler just to treat an enable/disable as an 'update'. After all, you're basically updating the 'status' of an item. Otherwise, you're going to have to do a whole lot of extending/overriding...

nohsib
7 Aug 2012, 10:08 AM
Thanks friend. But on the server side enable and disable are exposed as separate services as there are more operations associated than just enable /disable.