Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Modify dialog field value after submit

Avatar

Level 3

Hi All,

We are trying to achieve multifield dialog using TouchUI dialog where there will be two fields say Title and Link, which are part of multifield. 

We would like to store these two values as <titlevalue>:<linkvalue> againist a property under appropriate content node after submission.

 

Example:

I have two dialog fields, say Title (with name as ./title) and Link (with name as ./link). Under normal dialog submission, the values will be stored in title and link properties. But i would like to get them stored under new property 'titleandlink' with its value as <titlevalue>:<linkvalue>  where titlevalue and linkvalue are the values entered in the dialog.

 

Can you please advise me how to achieve this?

Thanks,

Veera

1 Accepted Solution

Avatar

Correct answer by
Level 10

Read this community article -look at the code that is referenced in Github. It builds a dialog that uses a multifield. In this article - it writes out the multifield values to the web page. However - you can extend it and write the data to the JCR:
 

http://helpx.adobe.com/experience-manager/using/creating-touchui-xtypes.html

I would follow this, get it working and then extend it. The code taken from Github has a lot of useful code examples for AEM. In your JSP, get the data from the dialog and then call an AEM service that writes the data to the JCR. Consider this logic that writes the multifield dialog values to an AEM web page:

<%@include file="/libs/foundation/global.jsp" %>
<cq:includeClientLib categories="cq.widgets" />
<%@ taglib prefix="wcmmode" uri="http://www.adobe.com/consulting/acs-aem-commons/wcmmode" %><%
%><%@ taglib prefix="widgets" uri="http://www.adobe.com/consulting/acs-aem-commons/widgets" %><%
%><%@ taglib prefix="xss" uri="http://www.adobe.com/consulting/acs-aem-commons/xss" %><%
%><%@ taglib prefix="wcm" uri="http://www.adobe.com/consulting/acs-aem-commons/wcm" %>
<c:set var="definitions" value="${widgets:getMultiFieldPanelValues(resource, 'definitions')}"/>
<c:choose>
    <c:when test="${empty definitions}">
        <wcm:placeholder classNames="cq-dl-placeholder cq-block-placeholder"/>
    </c:when>
    <c:otherwise>
        <dl>
            <c:forEach items="${definitions}" var="definition">
                <dt>${xss:encodeForHTML(xssAPI, definition['term'])}</dt>
                <dd>${xss:encodeForHTML(xssAPI, definition['definition'])}</dt>
            </c:forEach>
        </dl>
    </c:otherwise>
</c:choose>

Extend this and capture the values and pass to an AEM service. 

As far as writing data to the JCR using JCR API-- see this community example:

http://helpx.adobe.com/experience-manager/using/persisting-cq-data-java-content1.html

Hope this helps

View solution in original post

4 Replies

Avatar

Level 10

You can write a Sighty component that does this. You can use Java in the component and then in the Java side of the component - use the JCR API to write to a JCR node property to meet your needs. Read this document to learn how to use a Sightly component that uses Java:

http://helpx.adobe.com/experience-manager/using/creating-sightly-component.html

Avatar

Level 3

Thank you Scott, for your inputs.

I am more interested to manipulate the data at the dialog level itself (like using cq:listeners like afteredit etc..) as they will be perfect place to act upon dialog data as soon as they get submitted.

I can also try using Java side of the component, provided it will get triggered before dialog data is written to content/../jcr-content/.. node.

Can you please point me to any classes in the JCR API i can use for this purpose?

My requirement is to build multifield dialog for touchUI, i want to write the value as String array in below format.

[title1:link1,title2:link2,title3:link3] provided user entered these values in the dialog in 3 containers (multifield) each containing two fields "Title" and "Link"

 

Can you please point me to any classes in the JCR API i can use for this purpose? or any example code to achieve the same?

Avatar

Level 4
I have the similar requirement. Can you tell how have you done with afteredit or cq:listners?

Avatar

Correct answer by
Level 10

Read this community article -look at the code that is referenced in Github. It builds a dialog that uses a multifield. In this article - it writes out the multifield values to the web page. However - you can extend it and write the data to the JCR:
 

http://helpx.adobe.com/experience-manager/using/creating-touchui-xtypes.html

I would follow this, get it working and then extend it. The code taken from Github has a lot of useful code examples for AEM. In your JSP, get the data from the dialog and then call an AEM service that writes the data to the JCR. Consider this logic that writes the multifield dialog values to an AEM web page:

<%@include file="/libs/foundation/global.jsp" %>
<cq:includeClientLib categories="cq.widgets" />
<%@ taglib prefix="wcmmode" uri="http://www.adobe.com/consulting/acs-aem-commons/wcmmode" %><%
%><%@ taglib prefix="widgets" uri="http://www.adobe.com/consulting/acs-aem-commons/widgets" %><%
%><%@ taglib prefix="xss" uri="http://www.adobe.com/consulting/acs-aem-commons/xss" %><%
%><%@ taglib prefix="wcm" uri="http://www.adobe.com/consulting/acs-aem-commons/wcm" %>
<c:set var="definitions" value="${widgets:getMultiFieldPanelValues(resource, 'definitions')}"/>
<c:choose>
    <c:when test="${empty definitions}">
        <wcm:placeholder classNames="cq-dl-placeholder cq-block-placeholder"/>
    </c:when>
    <c:otherwise>
        <dl>
            <c:forEach items="${definitions}" var="definition">
                <dt>${xss:encodeForHTML(xssAPI, definition['term'])}</dt>
                <dd>${xss:encodeForHTML(xssAPI, definition['definition'])}</dt>
            </c:forEach>
        </dl>
    </c:otherwise>
</c:choose>

Extend this and capture the values and pass to an AEM service. 

As far as writing data to the JCR using JCR API-- see this community example:

http://helpx.adobe.com/experience-manager/using/persisting-cq-data-java-content1.html

Hope this helps