Touching the AEM component dialog by Mateusz Chromiński

17
Touching the AEM component dialog Mateusz Chromiński

Transcript of Touching the AEM component dialog by Mateusz Chromiński

Page 1: Touching the AEM component dialog by Mateusz Chromiński

Touching the AEM component dialogMateusz Chromiński

Page 2: Touching the AEM component dialog by Mateusz Chromiński

Curiousity

Page 3: Touching the AEM component dialog by Mateusz Chromiński

Pre-AEM 6.0

Page 4: Touching the AEM component dialog by Mateusz Chromiński

Pre-AEM 6.0

Page 5: Touching the AEM component dialog by Mateusz Chromiński

/content/page/jcr:content/parsys/component.infinity.json

{    "jcr:primaryType":"nt:unstructured",   "property1":"value1",   "nested":{       "jcr:primaryType":"nt:unstructured",      "property2":"value2",

{    "jcr:primaryType":"cq:Dialog",   "title":"My Component",   "xtype":"tabpanel",   "items":{       "jcr:primaryType":"cq:WidgetCollection",

/apps/myApp/myComponent/dialog.infinity.json

Pre-AEM 6.0

Page 6: Touching the AEM component dialog by Mateusz Chromiński

"xtype":"cqinclude"

Pre-AEM 6.0

Page 7: Touching the AEM component dialog by Mateusz Chromiński

/apps/components/list/_cq_dialog.html

/content/page/jcr:content/list

granite/ui/components/foundation/form/select

TouchUI

Page 8: Touching the AEM component dialog by Mateusz Chromiński

GET /apps/components/list/_cq_dialog

.html/content/page/jcr:content/list

?resourceType=components%2Farticle

query parameter

suffix

extension

resource path

content link

dialog rendering

component resource type

request.getRequestPathInfo().getSuffixResource()

URL decomposition

Page 9: Touching the AEM component dialog by Mateusz Chromiński

Stores user data

Widget

AEM authoring

sling:resourceType

Content

Defines form field HTML markup

DialogLists all dialog field types with content links

Page 10: Touching the AEM component dialog by Mateusz Chromiński

• @SlingServlet(resourceType=...

Sling servlets• /bin/app/myServlet.json

Resource scripts• /apps/myApp/component/component.jsp

Resource Resolution

Page 11: Touching the AEM component dialog by Mateusz Chromiński

<selection jcr:primaryType=”nt:unstructured” sling:resourcetype=”granite/ui/components/foundation/form/select” fieldLabel=”Select one”> <items jcr:primaryType=”nt:unstructured”> <item_0 jcr:primaryType=”nt:unstructured” text=”Option 1” value=”value1”/> <item_1 jcr:primaryType=”nt:unstructured” text=”Option 2” value=”value2”/>

Datasource - static

Page 12: Touching the AEM component dialog by Mateusz Chromiński

<selection jcr:primaryType=”nt:unstructured” sling:resourcetype=”granite/ui/components/foundation/form/select” fieldLabel=”Select one”> <datasource jcr:primaryType=”nt:unstructured” sling:resourceType=”cq/gui/components/projects/admin/datasource/gadgetdatasource”>

/libs/cq/gui/components/projects/admin/datasource/gadgetdatasource/gadgetdatasource.jsp

<%@include file=”/libs/foundation/global.jsp”%><%

...

request.setAttribute(DataSource.class.getName(), ds);%>

Datasource – dynamic

Page 13: Touching the AEM component dialog by Mateusz Chromiński

@SlingServlet(resourceTypes = { ”touch/components/datasource” })public class DataSourceServlet extends SlingSafeMethodsServlet {

@Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {

List<Resource> resources = new ArrayList<>(); List<MyItemModel> items = getItems(); for (MyItemModel item : items) { ValueMap valueMap = new ValueMapDecorator(new HashMap<>()); valueMap.put(”value”, item.getValue()); valueMap.put(”text”, item.getText());

resources.add(new ValueMapResource(request.getResourceResolver(), new ResourceMetadata(), JcrConstants.NT_UNSTRUCTURED, valueMap); } DataSource dataSource = new SimpleDataSource(resources.iterator()); request.setAttribute(DataSource.class.getName(), dataSource); }}

Datasource on servlet

Page 14: Touching the AEM component dialog by Mateusz Chromiński

@SlingServlet(resourceTypes = { ”touch/components/widgetInclude” })public class WidgetIncludeServlet extends SlingSafeMethodsServlet {

@Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {

Resource finalResource = getFinalResource(request); if(finalRequest == null) { response.sendError(404); } else { RequestDispatcher dispatcher = request.getRequestDispatcher(finalResource); dispatcher.include(request, response); }

}}

Include through servlet

Page 15: Touching the AEM component dialog by Mateusz Chromiński

Front-end

CoralUIStyling

jQueryDynamic

Page 16: Touching the AEM component dialog by Mateusz Chromiński

Classic UI Touch UI

Data return format JSON HTML

Data rendering way infinity.json JSP / Sling rendering

HTTP dialog calls 2+ 1

Processing side Front-side Back-end

Styling ExtJS Coral

Dynamic ExtJS hooks jQuery

Comparison

Page 17: Touching the AEM component dialog by Mateusz Chromiński

Mateusz ChromińskiSenior Software Engineer @ Cognifide

[email protected] mateusz_chrominski

Thank you