From 0a36db20ed406bb0e7acfd6d6dec90789f2cdbe6 Mon Sep 17 00:00:00 2001 From: Markus Ofterdinger Date: Mon, 19 May 2025 12:27:10 +0200 Subject: [PATCH 1/7] Removed chapter about exporting default messages. --- java/event-handlers/indicating-errors.md | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/java/event-handlers/indicating-errors.md b/java/event-handlers/indicating-errors.md index a0cd1fd6d..e6e70e875 100644 --- a/java/event-handlers/indicating-errors.md +++ b/java/event-handlers/indicating-errors.md @@ -129,27 +129,6 @@ CAP Java provides out-of-the-box translation for error messages that originate f The error messages are optimized for UI scenarios and avoid any technical references to entity names or element names. Message targets are used where appropriate to allow the UI to show the error message next to the affected UI element. You can enable these translated error messages by setting [cds.errors.defaultTranslations.enabled: true](../developing-applications/properties#cds-errors-defaultTranslations-enabled). -### Exporting the Default Messages - -As of CAP Java 1.10.0, you can extract the available default messages as a resource bundle file for further processing (for example, translation). Therefore, the delivery artifact [cds-services-utils](https://search.maven.org/artifact/com.sap.cds/cds-services-utils) contains a resource bundle `cds-messages-template.properties` with all available error codes and default messages. Application developers can use this template to customize error messages thrown by the CAP Java SDK in the application. - -1. [Download](https://search.maven.org/artifact/com.sap.cds/cds-services-utils) the artifact or get it from the local Maven repository in `~/.m2/repository/com/sap/cds/cds-services-utils//cds-services-utils-.jar`. -1. Extract the file. - ```sh - jar -f cds-services-utils-.jar -x cds-messages-template.properties - ``` - ::: tip - \ is the version of CAP Java you're using in your project. - ::: - -1. Rename the extracted file `cds-messages-template.properties` appropriately (for example, to `cds-messages.properties`) and move it to the resource directory of your application. -1. In your Spring Boot application, you have to register this additional [resource bundle](https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.internationalization) accordingly. - -> Now, you're able to customize the stack error messages in your application. - -With new CAP Java versions, there could be also new or changed error messages in the stack. To identify these changes, export `cds-messages-template.properties` from the new CAP Java version and compare it with the previous version using a diff tool. - - ## Target When SAP Fiori interprets messages it can handle an additional `target` property, which, for example, specifies which element of an entity the message refers to. SAP Fiori can use this information to display the message along the corresponding field on the UI. From 42d0e835f5730f897f39413992799eedec41d02e Mon Sep 17 00:00:00 2001 From: Markus Ofterdinger Date: Mon, 19 May 2025 13:30:15 +0200 Subject: [PATCH 2/7] Update indicating-errors.md --- java/event-handlers/indicating-errors.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/java/event-handlers/indicating-errors.md b/java/event-handlers/indicating-errors.md index e6e70e875..f09fc15d4 100644 --- a/java/event-handlers/indicating-errors.md +++ b/java/event-handlers/indicating-errors.md @@ -129,6 +129,11 @@ CAP Java provides out-of-the-box translation for error messages that originate f The error messages are optimized for UI scenarios and avoid any technical references to entity names or element names. Message targets are used where appropriate to allow the UI to show the error message next to the affected UI element. You can enable these translated error messages by setting [cds.errors.defaultTranslations.enabled: true](../developing-applications/properties#cds-errors-defaultTranslations-enabled). +### Provide custom error messages + +By default, CAP Java provides error messages in several languages. If these error messages or translation are not sufficient for an application, they can be overwritten with custom error messages. Therefore, an application has to provide a `errors_.proberties` resource bundle in the folder `srv/src/main/resources/com/sap/cds/i18n/`. +To know which error codes and messages are available by default, one can download the artifact `cds-services-impl--sources.jar` from the public Maven repository. Then extract the Java enumaration `com.sap.cds.services.utils.CdsErrorStatuses` from this source jar. This enumartion shows all available error codes and messages that are used by the CAP Java runtime. + ## Target When SAP Fiori interprets messages it can handle an additional `target` property, which, for example, specifies which element of an entity the message refers to. SAP Fiori can use this information to display the message along the corresponding field on the UI. From 778da53375fc47f701222c0ddb92c1f468a6e6bb Mon Sep 17 00:00:00 2001 From: Markus Ofterdinger Date: Mon, 19 May 2025 13:44:07 +0200 Subject: [PATCH 3/7] Update java/event-handlers/indicating-errors.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- java/event-handlers/indicating-errors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/event-handlers/indicating-errors.md b/java/event-handlers/indicating-errors.md index f09fc15d4..cd7411dcc 100644 --- a/java/event-handlers/indicating-errors.md +++ b/java/event-handlers/indicating-errors.md @@ -132,7 +132,7 @@ You can enable these translated error messages by setting [cds.erro ### Provide custom error messages By default, CAP Java provides error messages in several languages. If these error messages or translation are not sufficient for an application, they can be overwritten with custom error messages. Therefore, an application has to provide a `errors_.proberties` resource bundle in the folder `srv/src/main/resources/com/sap/cds/i18n/`. -To know which error codes and messages are available by default, one can download the artifact `cds-services-impl--sources.jar` from the public Maven repository. Then extract the Java enumaration `com.sap.cds.services.utils.CdsErrorStatuses` from this source jar. This enumartion shows all available error codes and messages that are used by the CAP Java runtime. +To know which error codes and messages are available by default, one can download the artifact `cds-services-impl--sources.jar` from the public Maven repository. Then extract the Java enumeration `com.sap.cds.services.utils.CdsErrorStatuses` from this source jar. This enumartion shows all available error codes and messages that are used by the CAP Java runtime. ## Target From 9ba48ffd1017af0977efedb40d717ccb43d752e7 Mon Sep 17 00:00:00 2001 From: Markus Ofterdinger Date: Tue, 20 May 2025 11:28:39 +0200 Subject: [PATCH 4/7] Update indicating-errors.md --- java/event-handlers/indicating-errors.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/event-handlers/indicating-errors.md b/java/event-handlers/indicating-errors.md index cd7411dcc..aff761469 100644 --- a/java/event-handlers/indicating-errors.md +++ b/java/event-handlers/indicating-errors.md @@ -131,8 +131,8 @@ You can enable these translated error messages by setting [cds.erro ### Provide custom error messages -By default, CAP Java provides error messages in several languages. If these error messages or translation are not sufficient for an application, they can be overwritten with custom error messages. Therefore, an application has to provide a `errors_.proberties` resource bundle in the folder `srv/src/main/resources/com/sap/cds/i18n/`. -To know which error codes and messages are available by default, one can download the artifact `cds-services-impl--sources.jar` from the public Maven repository. Then extract the Java enumeration `com.sap.cds.services.utils.CdsErrorStatuses` from this source jar. This enumartion shows all available error codes and messages that are used by the CAP Java runtime. +By default, CAP Java provides error messages in several languages. If these error messages or translation are not sufficient for an application, they can be overwritten with custom error messages. Therefore, an application can provide a `messages_.proberties` resource bundle in the folder `src/main/resources/`. +To know which error codes and messages are available by default, you can have a look at the Java enumaration `com.sap.cds.services.utils.CdsErrorStatuses` with your favorite IDE. This enumeration shows all available error codes and messages that are used by the CAP Java runtime. ## Target From 2679c12c14bfbdf5035a3c7bffbfd901f5f2b576 Mon Sep 17 00:00:00 2001 From: Markus Ofterdinger Date: Tue, 20 May 2025 11:30:53 +0200 Subject: [PATCH 5/7] Update java/event-handlers/indicating-errors.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- java/event-handlers/indicating-errors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/event-handlers/indicating-errors.md b/java/event-handlers/indicating-errors.md index aff761469..a94f9df77 100644 --- a/java/event-handlers/indicating-errors.md +++ b/java/event-handlers/indicating-errors.md @@ -132,7 +132,7 @@ You can enable these translated error messages by setting [cds.erro ### Provide custom error messages By default, CAP Java provides error messages in several languages. If these error messages or translation are not sufficient for an application, they can be overwritten with custom error messages. Therefore, an application can provide a `messages_.proberties` resource bundle in the folder `src/main/resources/`. -To know which error codes and messages are available by default, you can have a look at the Java enumaration `com.sap.cds.services.utils.CdsErrorStatuses` with your favorite IDE. This enumeration shows all available error codes and messages that are used by the CAP Java runtime. +To know which error codes and messages are available by default, you can have a look at the Java enumeration `com.sap.cds.services.utils.CdsErrorStatuses` with your favorite IDE. This enumeration shows all available error codes and messages that are used by the CAP Java runtime. ## Target From bdc85952a940d3d507c1a68fd7aaacca822bfb33 Mon Sep 17 00:00:00 2001 From: Markus Ofterdinger Date: Tue, 20 May 2025 13:57:45 +0200 Subject: [PATCH 6/7] Update java/event-handlers/indicating-errors.md Co-authored-by: Marc Becker --- java/event-handlers/indicating-errors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/event-handlers/indicating-errors.md b/java/event-handlers/indicating-errors.md index a94f9df77..484600d10 100644 --- a/java/event-handlers/indicating-errors.md +++ b/java/event-handlers/indicating-errors.md @@ -131,7 +131,7 @@ You can enable these translated error messages by setting [cds.erro ### Provide custom error messages -By default, CAP Java provides error messages in several languages. If these error messages or translation are not sufficient for an application, they can be overwritten with custom error messages. Therefore, an application can provide a `messages_.proberties` resource bundle in the folder `src/main/resources/`. +By default, CAP Java provides error messages in several languages. If these error messages or translation are not sufficient for an application, they can be overwritten with custom error messages. Applications can overwrite these texts by providing new error messages under the respective error code in the application's `messages.properties` resource bundle under `src/main/resources`. To know which error codes and messages are available by default, you can have a look at the Java enumeration `com.sap.cds.services.utils.CdsErrorStatuses` with your favorite IDE. This enumeration shows all available error codes and messages that are used by the CAP Java runtime. ## Target From 95db0410a905a6590b894911cd80ae7bd4e4996e Mon Sep 17 00:00:00 2001 From: Mahati Shankar <93712176+smahati@users.noreply.github.com> Date: Fri, 23 May 2025 09:40:26 +0200 Subject: [PATCH 7/7] Update java/event-handlers/indicating-errors.md --- java/event-handlers/indicating-errors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/event-handlers/indicating-errors.md b/java/event-handlers/indicating-errors.md index 2177acd77..d9980a356 100644 --- a/java/event-handlers/indicating-errors.md +++ b/java/event-handlers/indicating-errors.md @@ -130,7 +130,7 @@ You can enable these translated error messages by setting [cds.erro ### Provide custom error messages -By default, CAP Java provides error messages in several languages. If these error messages or translation are not sufficient for an application, they can be overwritten with custom error messages. Applications can overwrite these texts by providing new error messages under the respective error code in the application's `messages.properties` resource bundle under `src/main/resources`. +By default, CAP Java provides error messages in several languages. If an error message or translation isn't sufficient for an application, it can be overwritten with a custom error message. Applications can provide the new error message under the respective error code in the application's `messages.properties` resource bundle under `src/main/resources`. To know which error codes and messages are available by default, you can have a look at the Java enumeration `com.sap.cds.services.utils.CdsErrorStatuses` with your favorite IDE. This enumeration shows all available error codes and messages that are used by the CAP Java runtime. ## Target