1

Aikau example defines the following:

{
  name: "alfresco/forms/controls/DojoSelect",
  config: {
     label: "List Type",
     name: "prop_dl_dataListItemType",
     value: "dl:event",
     optionsConfig: {
        publishTopic: "ALF_GET_FORM_CONTROL_OPTIONS",
        publishPayload: {
           url: url.context + "/proxy/alfresco/api/classes/dl_dataListItem/subclasses",
           itemsAttribute: "",
           labelAttribute: "title",
           valueAttribute: "name"
        }
     }
  }

}

Pay attention to url.context. I have not found any url definition in example sources. It seems that url implicitly initialized somewhere. But where exactly? What other fields/methods url object has?

Cherry
  • 31,309
  • 66
  • 224
  • 364

2 Answers2

1

Aikau will be building the URL on the service.js file. For example, you can take a look at the CRUDService.js file and refer getUrlFromPayload method and this method is called like,

 onGetAll: function alfresco_services_CrudService__onGetAll(payload) {
var url = this.getUrlFromPayload(payload); .... }

and it will be passed the request object, to make the request.

Hope this help you.

Community
  • 1
  • 1
1

The url object is available in all JavaScript controllers of WebScripts. It is one of a number of built-in objects that are provided for convenience (others include "remote" and "user" for example). The url.context will be configured to the context of the application being run. So typically the value returned would be "share" (as this is the default application context).

The application context is typically required when defining the URL for APIs defined either on the Share tier (i.e. /share/services/...) or the Repository tier (i.e. /share/proxy/alfresco/...).

The url.context should be used as it is possible to configure applications to have alternative context roots so it is better to code to something that Surf can handle for you.

Surf and WebScripts have been around for a lot longer than Aikau and they unfortunately have suffered from a lack of good documentation.

The Java class that back the url object is "org.springframework.extensions.webscripts.DefaultURLHelper" (which extends "org.springframework.extensions.webscripts.URLHelper"). Other attributes that are available include:

  • pageContext
  • uri
  • queryString
  • args
  • templateArgs
Dave Draper
  • 1,837
  • 11
  • 25