Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Data Injectors

Data Injectors

Cortex provides a number of data injectors for injecting data into prototype instances. Resource identifier annotations are always accompanied by an @Inject annotation. For more information and examples on when and how to use data injectors, see Resource Identifiers.

Data injectors can be put into two main categories: contextual data injectors and request data injectors.

Contextual Data Injectors

Annotation Description

Inject the currency, Currency.


Inject the current User ID String.


Inject the locale Locale.


Injects all scopes if the annotated type is Collection<String>.


Inject the scope Subject.

Request Data Injectors

Annotation Description

Inject a ResourceEntity that encapsulates the input data.


Inject a ResourceIdentifier.


Inject an IdentifierPart. This reference can be typed, such as IdentifierPart<String>.

Using @RequestForm Data Injectors

The @RequestForm data injector injects a ResourceEntity into a Prototype instance.

A ResourceEntity is a representation of the input form data submitted by the client. The @RequestForm data injector should be used in the context of a PUT or Create operation. In some cases a client may not submit any form data, thus the ResourceEntity to inject would not be present.

The default usage of the @RequestForm data injector is:

  private MyResourceEntity entity

If a client tries to submit an empty form, the injection will fail and a HTTP Bad Request (status code 400) response will be returned to the client.

If you would like to define their own empty form handling behavior, inject a ResourceEntity typed Optional. In the case of an empty form the Optional would be absent.

  private Optional<MyResourceEntity> maybeEntity