If you take a look at web APIs and the web service landscape nowadays you’ll notice that the predominant architectural style is REST (Representational State Transfer).
qooxdoo helps you utilize REST with our REST layer (qx.io.rest.Resource), which can be used to work against RESTful web-services in an elegant way. That means rather than requesting URLs with a specific HTTP method manually, you can define resource objects and invoke actions upon them. Our REST manual page explains this in greater detail.
Until now the REST layer was not available within qx.Website but this has changed. In order to provide the same functionality that qx.io.rest.Resource offers we had to introduce another Resource class: qx.bom.rest.Resource. This enabled us to change the API slightly where needed (i.e. smaller dependency footprint) while staying backwards-compatible (unchanged API for qx.io.rest.Resource).
So here is a small example of the usage of qx.bom.rest.Resource:
q.ready(function() { var resourceDescription = { "get": { method: "GET", url: "http://example.org/resources/{name}" }, }; var resource = q.rest.resource(resourceDescription); resource.on("getSuccess", function(e) { console.log(e.response); }); resource.on("getError", function(e) { console.log(e.response); }); resource.get({"name": "sample"}); });
This functionality is now available in the devel version of q (i.e. qx.Website) which is available in the download section (look for q-devel.min.js). If you want to dive deeper check out the qx.Website API documentation also.
The rest of this article simply goes into detail how qx.bom.rest.Resource differs from qx.io.rest.Resource – which is mainly interesting for those who already used the old one and want to try the new one within qx.Website:
- The event object available in the listeners (e.g.
success(),getSuccess()andgetError()) is a native JavaScript object instead of a qooxdoo object (qx.event.type.Rest). qx.io.rest.Resourcevs.qx.bom.rest.Resource
event.getId() => event.id
event.getRequest() => event.request
event.getAction() => event.action
event.getData() => event.response
event.getPhase() => --- (see below)- Methods which allow manipulation of the request (e.g.
configureRequest()) will operate on an instance ofqx.bom.request.SimpleXhrinstead ofqx.io.request.Xhr(the API is similar but not identical) poll()returns noqx.event.Timerobject. There are two new methods (stopPollByAction()andrestartPollByAction()) available atqx.bom.rest.Resourcewhich replace the functionality provided by the Timer object.- The phase support, which is a more elaborate version of
readyState, is not available. So usereadyStateinstead. - Phases (available only in
qx.io.rest.Resource): unsent,opened,sent,loading,load,successabort,timeout,statusErrorreadyState(available inqx.bom.rest.Resourceandqx.io.rest.Resource):UNSENTOPENEDHEADERS_RECEIVEDLOADINGDONE
We are looking forward to your feedback.


