AJAX framework
The AJAX framework helps determine the refresh areas of pages, and the content that populates them. The framework helps track the status of store pages, and the content that is generated when customers interact with the store.
The Aurora starter store contains the following functions:
- WCRefreshController.refresh(parameters)
The WCRefreshController.refresh function refreshes the refresh area with the parameters specified. The parameters are passed as the data attribute into the JQuery.ajax call.- WCRefreshController.updateFormId(newFormId)
The WCRefreshController.updateFormId function updates the form id that is passed to the AJAX call. If specified, all input elements in the specified form are passed as the data attribute into the JQuery.ajax call.- WCRefreshController.updateUrl(newURL)
The WCRefreshController.updateUrl function allows developers to update the URL of the refresh area. The URL is usually defined in the JSP using the refreshurl attribute, but in some circumstances we might need to change the URL.- wcRenderContext.declare (id, refreshAreaIds, initialProperties)
The wcRenderContext.declare function declares a new refresh controller, associates it with the refreshAreaIds passed in and initializes it with the specified initialization properties. The initialization properties are in addition to the new refresh controller's properties. A refresh controller control refresh area widgets, and listens to changes in the render context and model and decides whether the registered refresh areas must be updated.- wcRenderContext.getRefreshAreaIds (id)
The wcRenderContext.getRefreshAreaIds function returns the refresh area IDs associated with the specified render context.- wcRenderContext.addRefereshAreaId (id, refreshAreaId)
The wcRenderContext.addRefereshAreaId function adds a refresh area ID to an existing render context.- wcRenderContext.getRenderContextProperties (id)
The wcRenderContext.getRenderContextProperties function returns the render context declared by the specified identifier.- wcRenderContext.updateRenderContext (id, updates)
The wcRenderContext.updateRenderContext function retrieves the render context with the specified ID and applies the updates that are found in the specified updates object. After a context object is updated, the framework automatically calls all the renderContextChangedHandler methods of all the controllers.- wcRenderContext.testForChangedRC (id, propertyNames)
The wcRenderContext.testForChangedRC function searches the specified array of property names for a render context property that has changed since the last time a render context changed event was detected. It returns a value of true if any of the specified render context properties have changed, and returns a value of false if none of the specified render context properties have changed.- wcRenderContext.checkIdDefined (id)
The wcRenderContext.checkIdDefined function checks if a render context with the specified ID already exists. It returns true if there is an existing render context defined, false otherwise.- wcService.declare (initProperties)
The wcService.declare function declares a new AJAX service with the specified ID. In WebSphere Commerce, a service is a server URL that performs a server object create, update, delete, or other server processing. When needed, a Transaction Server URL is called by using AJAX in the JavaScript code. When the service completes successfully, a JSON object that contain all the response properties of the URL request is returned to successHandler (the success response) or failureHandler (the failure response) defined JavaScript function. In addition, a WCTopic.publish is sent to any subscribed listeners if the service completes successfully. In this case, the WCTopic.subscribe events listening to the specified topic will be triggered.- wcService.getServiceById (serviceId)
The wcService.getServiceById helper function is for getting a handle on the service object that was declared using the wcService.declare function. Once the service object is obtained, we can update any information in the service object such as URL, formId, or others. This function is helpful when you find a service and update its parameters before you invoke it.- wcService.invoke (serviceId, parameters)
The wcService.invoke function finds the registered service with the specified service ID and invokes the service via AJAX using the specified parameters.
Related reference
WebSphere Commerce AJAX framework
User interface widgets