Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed links #976

Merged
merged 4 commits into from
Jun 6, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions java/event-handlers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Event handlers enable you to add custom business logic to your application by ei
Event handlers are a powerful means to extend CAP. Did you know, that most of the built-in features provided by CAP are implemented using event handlers?
:::

Common events are the CRUD events (`CREATE`, `READ`, `UPDATE`, `DELETE`), which are handled by the different kinds of [CQN-based services[(../cqn-services/#cdsservices).
Common events are the CRUD events (`CREATE`, `READ`, `UPDATE`, `DELETE`), which are handled by the different kinds of [CQN-based services](../cqn-services/#cdsservices).
These events are most typically triggered, when an HTTP-based protocol adapter (for example OData V4) executes a CQN statement on an Application Service to fulfill the HTTP request.
The CAP Java SDK provides a lot of built-in event handlers (also known as [Generic Providers](../../guides/providing-services)) that handle CRUD operations out of the box and implement the handling of many CDS annotations.
Applications most commonly use event handlers on CRUD events to _extend_ the event processing by using the [`Before`](#before) and [`After`](#after) phase.
Expand Down Expand Up @@ -113,10 +113,10 @@ Object result = context.get("result");

Using the `get` and `put` methods has several drawbacks: The API is neither type-safe nor is it clear what the correct keys for different event parameters are.
To solve these issues it is possible to overlay the general Event Context with an event-specific Event Context, which provides typed getters and setters for the parameters of a specific event.
For each event that the CAP Java SDK provides out-of-the-box (for example the [CRUD events[(../cqn-services/application-services#crudevents)) a corresponding Event Context is provided.
For each event that the CAP Java SDK provides out-of-the-box (for example the [CRUD events](../cqn-services/application-services#crudevents)) a corresponding Event Context is provided.
beckermarc marked this conversation as resolved.
Show resolved Hide resolved

Let's have a look at an example. The [CdsReadEventContext](https://www.javadoc.io/doc/com.sap.cds/cds-services-api/latest/com/sap/cds/services/cds/CdsReadEventContext.html) interface is the `READ` event-specific Event Context.
As one of the parameters of the `READ` event is a [CqnSelect](../../cds/cqn#select) it provides a `CqnSelect getCqn()` method. The return value of a `READ` event is a [Result[(../working-with-cql/query-execution#result).
As one of the parameters of the `READ` event is a [CqnSelect](../../cds/cqn#select) it provides a `CqnSelect getCqn()` method. The return value of a `READ` event is a [Result](../working-with-cql/query-execution#result).
The context therefore also provides a `Result getResult()` and a `setResult(Result r)` method. You can use the `as` method provided by the general Event Context to overlay it:

```java
Expand Down Expand Up @@ -361,7 +361,7 @@ public void changeBooks(List<Books> books) { }
The mapping between a data accessor interface and an entity, is based on the `@CdsName` annotation of the accessor interface.
:::

Entity data arguments only work on [CRUD events[(../cqn-services/application-services#crudevents) of [CQN-based services](../cqn-services/#cdsservices). In addition they work with the [draft-specific CRUD events[(../fiori-drafts#draftevents) provided by Draft Services.
Entity data arguments only work on [CRUD events](../cqn-services/application-services#crudevents) of [CQN-based services](../cqn-services/#cdsservices). In addition they work with the [draft-specific CRUD events](../fiori-drafts#draftevents) provided by Draft Services.

The origin from which the entity data is provided depends on the phase of the event processing.
During the `Before` and `On` phase it is obtained from the CQN statement. The CQN statement contains the entity data that was provided by the service client.
Expand Down Expand Up @@ -413,10 +413,10 @@ public List<Books> readBooks(CdsReadEventContext context) {
}
```

Event handler methods with return values only work on [CRUD events[(cqn-services/application-services#crudevents) of [CQN-based services[(cqn-services/#cdsservices) or the [draft-specific CRUD events[(../fiori-drafts#draftevents) provided by Draft Services.
Event handler methods with return values only work on [CRUD events[(cqn-services/application-services#crudevents) of [CQN-based services](cqn-services/#cdsservices) or the [draft-specific CRUD events](../fiori-drafts#draftevents) provided by Draft Services.
renejeglinsky marked this conversation as resolved.
Show resolved Hide resolved

::: tip
To learn how to build your own Result objects, have a look at the [Result Builder API[(../cqn-services/application-services#result-builder)
To learn how to build your own Result objects, have a look at the [Result Builder API](../cqn-services/application-services#result-builder)
:::

### Ordering of Event Handler Methods
Expand Down
Loading