Skip to content

Commit 8475911

Browse files
authored
Merge branch 'main' into SITES-26758
2 parents da6a741 + ace15d9 commit 8475911

File tree

28 files changed

+429
-29
lines changed

28 files changed

+429
-29
lines changed

.github/workflows/maven-deploy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434

3535
# Set up dependency cache
3636
- name: Cache local Maven repository
37-
uses: actions/cache@v2
37+
uses: actions/cache@v4
3838
with:
3939
path: ~/.m2/repository
4040
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}

.github/workflows/maven-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545

4646
# Set up dependency cache
4747
- name: Cache local Maven repository
48-
uses: actions/cache@v2
48+
uses: actions/cache@v4
4949
with:
5050
path: ~/.m2/repository
5151
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}

.github/workflows/maven-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242

4343
# Set up dependency cache
4444
- name: Cache local Maven repository
45-
uses: actions/cache@v2
45+
uses: actions/cache@v4
4646
with:
4747
path: ~/.m2/repository
4848
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ For existing projects, take example from the [AEM Project Archetype](https://git
9191

9292
### System Requirements
9393

94-
Core Components | AEM as a Cloud Service | AEM 6.5 | Java SE | Maven
95-
----------------|------------------------|-----------|---------|---------
96-
[2.27.0+](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.23.4) | Continual | 6.5.21.0+ | 8, <br/>11 | 3.3.9+
94+
Core Components | AEM as a Cloud Service | AEM 6.5 | Java SE | Maven
95+
----------------|------------------------|--------------|-----------|---------
96+
[>= 2.26.x](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.23.4) | Continual | \>= 6.5.21.0 | 11 | \>= 3.3.9
97+
[<= 2.25.x](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.23.4) | Not applicable | \<= 6.5.21.0 | 8 <br/>11 | \<= 3.3.9
98+
9799

98100
For the requirements from previous Core Component releases, see [Historical System Requirements](VERSIONS.md).
99101

VERSIONS.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ See below for a full list of system requirements for historical versions of the
44

55
Core Components | Extension | AEM 6.5 | AEM 6.4 | AEM 6.3 | Java | Maven
66
----------------|-----------|-----------|---------|---------|-------|------
7-
[2.27.0](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.26.0) | - | 6.5.21.0+ | - | - | 8, 11 | 3.3.9+
8-
[2.26.0](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.26.0) | - | 6.5.21.0+ | - | - | 8, 11 | 3.3.9+
7+
[2.27.0](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.26.0) | - | 6.5.21.0+ | - | - | 11 | 3.3.9+
8+
[2.26.0](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.26.0) | - | 6.5.21.0+ | - | - | 11 | 3.3.9+
99
[2.25.4](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.25.4) | - | 6.5.21.0+ | - | - | 8, 11 | 3.3.9+
1010
[2.25.2](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.25.2) | - | 6.5.21.0+ | - | - | 8, 11 | 3.3.9+
1111
[2.25.0](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.25.0) | - | 6.5.21.0+ | - | - | 8, 11 | 3.3.9+

bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/form/TextImpl.java

+24-4
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@
1717

1818
import javax.annotation.PostConstruct;
1919

20+
import com.day.cq.wcm.api.designer.Style;
21+
import com.fasterxml.jackson.annotation.JsonIgnore;
2022
import org.apache.sling.api.SlingHttpServletRequest;
2123
import org.apache.sling.api.resource.Resource;
2224
import org.apache.sling.models.annotations.Default;
2325
import org.apache.sling.models.annotations.Exporter;
2426
import org.apache.sling.models.annotations.Model;
25-
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
26-
import org.apache.sling.models.annotations.injectorspecific.ScriptVariable;
27-
import org.apache.sling.models.annotations.injectorspecific.Self;
28-
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
27+
import org.apache.sling.models.annotations.injectorspecific.*;
2928

3029
import com.adobe.cq.export.json.ComponentExporter;
3130
import com.adobe.cq.export.json.ExporterConstants;
3231
import com.adobe.cq.wcm.core.components.internal.form.FormConstants;
3332
import com.adobe.cq.wcm.core.components.models.form.Text;
3433
import com.day.cq.wcm.foundation.forms.FormStructureHelperFactory;
3534
import com.day.cq.wcm.foundation.forms.FormsHelper;
35+
import org.jetbrains.annotations.Nullable;
3636

3737
@Model(adaptables = SlingHttpServletRequest.class,
3838
adapters = {Text.class, ComponentExporter.class},
@@ -54,6 +54,8 @@ public class TextImpl extends AbstractFieldImpl implements Text, ComponentExport
5454
private static final boolean PROP_USE_PLACEHOLDER_DEFAULT = false;
5555
private static final int PROP_ROWS_DEFAULT = 2;
5656
private static final boolean PROP_HIDE_TITLE_DEFAULT = false;
57+
public static final String PROP_DISPLAY_VALIDATION = "displayValidation";
58+
public static final boolean PROP_DISPLAY_VALIDATION_DEFAULT = false;
5759

5860
@Self
5961
private SlingHttpServletRequest slingRequest;
@@ -103,6 +105,16 @@ public class TextImpl extends AbstractFieldImpl implements Text, ComponentExport
103105
@Default(booleanValues = PROP_HIDE_TITLE_DEFAULT)
104106
private boolean hideTitle;
105107

108+
/**
109+
* The current style for this component.
110+
*/
111+
@ScriptVariable(injectionStrategy = InjectionStrategy.OPTIONAL)
112+
@JsonIgnore
113+
@Nullable
114+
protected Style currentStyle;
115+
116+
private boolean displayValidationMassages;
117+
106118
@PostConstruct
107119
private void initModel() {
108120
slingRequest.setAttribute(FormsHelper.REQ_ATTR_FORM_STRUCTURE_HELPER,
@@ -114,6 +126,10 @@ private void initModel() {
114126
if (usePlaceholder) {
115127
placeholder = helpMessage;
116128
}
129+
130+
if (currentStyle !=null) {
131+
displayValidationMassages = currentStyle.get(PROP_DISPLAY_VALIDATION, PROP_DISPLAY_VALIDATION_DEFAULT);
132+
}
117133
}
118134

119135
@Override
@@ -190,4 +206,8 @@ public boolean hideTitle() {
190206
return hideTitle;
191207
}
192208

209+
@Override
210+
public boolean displayValidation() {
211+
return displayValidationMassages;
212+
}
193213
}

bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/servlets/CoreFormHandlingServlet.java

+5
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ protected void activate(Configuration configuration) {
110110
@Override
111111
protected void doPost(@NotNull SlingHttpServletRequest request, @NotNull final SlingHttpServletResponse response)
112112
throws ServletException, IOException {
113+
// response will have content type text/html since it is represented by a JSP without another content type set
114+
// JSPs have this content type by default
115+
// So set this content type in advance inside response, in order to avoid breaking request dispatcher contract
116+
// More info https://jakarta.ee/specifications/servlet/4.0/apidocs/javax/servlet/requestdispatcher#include-javax.servlet.ServletRequest-javax.servlet.ServletResponse-
117+
response.setContentType("text/html");
113118
formsHandlingServletHelper.doPost(request, response);
114119
}
115120

bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/servlets/DownloadServlet.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ private void sendResponse(InputStream stream, long size, String mimeType, String
191191
response.setContentLength((int) size);
192192
}
193193
if (inline) {
194-
response.setHeader(CONTENT_DISPOSITION_HEADER, "inline");
194+
response.setHeader(CONTENT_DISPOSITION_HEADER, "inline; filename=\"" + filename + "\"");
195195
response.setHeader(CSP_HEADER, "sandbox");
196196
} else {
197197
response.setHeader(CONTENT_DISPOSITION_HEADER, "attachment; filename=\"" + filename + "\"");

bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/form/Text.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
public interface Text extends Field {
2727

2828
/**
29-
* Checks if the this text field is mandatory.
29+
* Checks if the text field is mandatory.
3030
*
3131
* @return {@code true} if the field must have a input, {@code false} otherwise
3232
* @since com.adobe.cq.wcm.core.components.models.form 13.0.0; marked <code>default</code> in 14.1.0
@@ -107,4 +107,14 @@ default int getRows() {
107107
default boolean hideTitle() {
108108
return false;
109109
}
110+
111+
/**
112+
* Checks if the validation messages should be displayed.
113+
*
114+
* @return {@code true} if the validation messages should be displayed, {@code false} otherwise
115+
* @since com.adobe.cq.wcm.core.components.models.form 14.5.0
116+
*/
117+
default boolean displayValidation() {
118+
return false;
119+
}
110120
}

bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/form/package-info.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* version, is bound to this proxy component resource type.
3535
* </p>
3636
*/
37-
@Version("14.4.0")
37+
@Version("14.5.0")
3838
package com.adobe.cq.wcm.core.components.models.form;
3939

4040
import org.osgi.annotation.versioning.Version;

bundles/core/src/test/java/com/adobe/cq/wcm/core/components/internal/models/v1/form/TextImplTest.java

+21
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public class TextImplTest {
3939
private static final String TEXTINPUT1_PATH = CONTAINING_PAGE + "/jcr:content/root/responsivegrid/container/text";
4040
private static final String TEXTINPUT2_PATH = CONTAINING_PAGE + "/jcr:content/root/responsivegrid/container/text_185087333";
4141
private static final String TEXTINPUT3_PATH = CONTAINING_PAGE + "/jcr:content/root/responsivegrid/container/text-v2";
42+
private static final String TEXTINPUT4_PATH = CONTAINING_PAGE + "/jcr:content/root/responsivegrid/container/text-v2-2";
43+
private static final String TEXTINPUT5_PATH = CONTAINING_PAGE + "/jcr:content/root/responsivegrid/container/text-v2-3";
4244

4345

4446
public final AemContext context = CoreComponentTestContext.newAemContext();
@@ -79,6 +81,7 @@ public void testInputWithCustomDataAndAttributes() {
7981
assertEquals(3, text.getRows());
8082
assertEquals("Custom help/placeholder message", text.getHelpMessage());
8183
assertTrue(text.hideTitle());
84+
assertFalse(text.displayValidation());
8285
Utils.testJSONExport(text, Utils.getTestExporterJSONPath(TEST_BASE, TEXTINPUT2_PATH));
8386
}
8487

@@ -88,6 +91,24 @@ public void testV2JSONExport() {
8891
Utils.testJSONExport(text, Utils.getTestExporterJSONPath(TEST_BASE, TEXTINPUT3_PATH));
8992
}
9093

94+
@Test
95+
public void testInputWithPolicyDisplayValidationFalse() {
96+
context.contentPolicyMapping("core/wcm/components/form/text/v2/text", "displayValidation", false);
97+
Text text = getTextUnderTest(TEXTINPUT4_PATH);
98+
assertEquals("Custom Name", text.getName());
99+
assertEquals("Custom title", text.getTitle());
100+
assertFalse(text.displayValidation());
101+
}
102+
103+
@Test
104+
public void testInputWithPolicyDisplayValidationTrue() {
105+
context.contentPolicyMapping("core/wcm/components/form/text/v2/text", "displayValidation", true);
106+
Text text = getTextUnderTest(TEXTINPUT5_PATH);
107+
assertEquals("Custom Name", text.getName());
108+
assertEquals("Custom title", text.getTitle());
109+
assertTrue(text.displayValidation());
110+
}
111+
91112
private Text getTextUnderTest(String resourcePath) {
92113
context.currentResource(Objects.requireNonNull(context.resourceResolver().getResource(resourcePath)));
93114
return context.request().adaptTo(Text.class);

bundles/core/src/test/java/com/adobe/cq/wcm/core/components/internal/servlets/DownloadServletTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void testInlineAssetDownload() throws Exception {
8585
context.requestPathInfo().setExtension("pdf");
8686
downloadServlet.doGet(context.request(), context.response());
8787
assertTrue(context.response().containsHeader("Content-Disposition"));
88-
assertEquals("inline", context.response().getHeader("Content-Disposition"));
88+
assertEquals("inline; filename=\"Download_Test_PDF.pdf\"", context.response().getHeader("Content-Disposition"));
8989
assertTrue(context.response().containsHeader("Content-Security-Policy"));
9090
assertEquals("sandbox", context.response().getHeader("Content-Security-Policy"));
9191
assertEquals(8192, context.response().getBufferSize());

bundles/core/src/test/resources/com/adobe/cq/wcm/core/components/internal/servlets/contentfragment/test-content.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@
8484
},
8585
"1538637399370": {
8686
"jcr:primaryType": "nt:unstructured",
87-
"valueFormat": "YYYY-MM-DD[T]HH:mm:ss.000Z",
88-
"emptyText": "YYYY-MM-DD HH:mm",
87+
"valueFormat": "yyyy-MM-dd[T]HH:mm:ss.000Z",
88+
"emptyText": "yyyy-MM-dd HH:mm",
8989
"listOrder": "5",
9090
"valueType": "calendar",
91-
"displayedFormat": "YYYY-MM-DD HH:mm",
91+
"displayedFormat": "yyyy-MM-dd HH:mm",
9292
"showEmptyInReadOnly": "true",
9393
"metaType": "date",
9494
"name": "dateAndTimeField",

bundles/core/src/test/resources/form/text/test-content.json

+37-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,43 @@
100100
"usePlaceholder": "true",
101101
"rows": 3,
102102
"hideTitle": true
103-
}
103+
},
104+
"text-v2-2": {
105+
"jcr:primaryType": "nt:unstructured",
106+
"jcr:title": "Custom title",
107+
"constraintMessage": "The value should be a valid email address",
108+
"showHideExpression": "((givenName.equals(\"\"Referees\"\")))",
109+
"readOnly": true,
110+
"helpMessage": "Custom help/placeholder message",
111+
"required": true,
112+
"name": "Custom Name",
113+
"type": "email",
114+
"useTextarea": true,
115+
"value": "Prefilled Sample Input",
116+
"sling:resourceType": "core/wcm/components/form/text/v2/text",
117+
"requiredMessage": "please fill the field",
118+
"usePlaceholder": "true",
119+
"rows": 3,
120+
"hideTitle": true
121+
},
122+
"text-v2-3": {
123+
"jcr:primaryType": "nt:unstructured",
124+
"jcr:title": "Custom title",
125+
"constraintMessage": "The value should be a valid email address",
126+
"showHideExpression": "((givenName.equals(\"\"Referees\"\")))",
127+
"readOnly": true,
128+
"helpMessage": "Custom help/placeholder message",
129+
"required": true,
130+
"name": "Custom Name",
131+
"type": "email",
132+
"useTextarea": true,
133+
"value": "Prefilled Sample Input",
134+
"sling:resourceType": "core/wcm/components/form/text/v2/text",
135+
"requiredMessage": "please fill the field",
136+
"usePlaceholder": "true",
137+
"rows": 3,
138+
"hideTitle": true
139+
}
104140
}
105141
}
106142
}

content/src/content/jcr_root/apps/core/wcm/components/contentfragment/v1/contentfragment/calendar.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
1616
<template data-sly-template.element="${@ date='The date', format='The format'}">
1717
<!--/* set a default format if none was provided */-->
18-
<sly data-sly-test.format="${format ? format : 'YYYY-MM-dd HH:mm'}"></sly>
18+
<sly data-sly-test.format="${format ? format : 'yyyy-MM-dd HH:mm'}"></sly>
1919
<!--/* i18n will allow to customise format based on locale as it's applied to the formatting string before the actual date formatting is done */-->
2020
${format @ format=date, type='date', i18n}
2121
</template>

content/src/content/jcr_root/apps/core/wcm/components/form/text/v2/text/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ Text form field component written in HTL.
3232
### Use Object
3333
The Form Text component uses the `com.adobe.cq.wcm.core.components.models.form.Text` Sling Model for its Use-object.
3434

35+
### Component Policy Configuration Properties
36+
The following configuration properties are used:
37+
38+
1. `./displayValidation` - defines whether the text field should display a label for the validation messages.
39+
3540
### Edit Dialog Properties
3641
The following properties are written to JCR for this Form Text component and are expected to be available as `Resource` properties:
3742

@@ -63,6 +68,7 @@ BLOCK cmp-form-text
6368
ELEMENT cmp-form-text__help-block
6469
ELEMENT cmp-form-text__textarea
6570
ELEMENT cmp-form-text__text
71+
ELEMENT cmp-form-text__validation-message
6672
```
6773

6874
## JavaScript Data Attribute Bindings

content/src/content/jcr_root/apps/core/wcm/components/form/text/v2/text/_cq_design_dialog/.content.xml

+17
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,23 @@
3030
sling:resourceType="granite/ui/components/coral/foundation/tabs"
3131
maximized="{Boolean}true">
3232
<items jcr:primaryType="nt:unstructured">
33+
<properties
34+
jcr:primaryType="nt:unstructured"
35+
jcr:title="Properties"
36+
sling:resourceType="granite/ui/components/coral/foundation/container"
37+
margin="{Boolean}true">
38+
<items jcr:primaryType="nt:unstructured">
39+
<displayvalidation
40+
jcr:primaryType="nt:unstructured"
41+
sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
42+
checked="false"
43+
fieldDescription="If checked, validation messages are displayed permanently under the field."
44+
name="./displayValidation"
45+
text="Display validation messages"
46+
uncheckedValue="false"
47+
value="true"/>
48+
</items>
49+
</properties>
3350
<styletab
3451
jcr:primaryType="nt:unstructured"
3552
sling:resourceType="granite/ui/components/coral/foundation/include"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
###############################################################################
2+
# Copyright 2019 Adobe
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
###############################################################################
16+
17+
#base=css
18+
19+
text.less
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2025 Adobe
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
.cmp-form-text .cmp-form-text__validation-message {
17+
visibility: hidden;
18+
}
19+
20+
.cmp-form-text :invalid + .cmp-form-text__validation-message {
21+
visibility: visible;
22+
}

0 commit comments

Comments
 (0)