Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Version Difference Functionality for my Custom components for the Custom Artcles I am creating


Level 2

Hi All,

I am creating Article, In which I am creation custom component Section. In which Every Section has Title and Description.

I need Version Difference functionality for this.

I added <cq:text> tag  but only Text Added is coming. Text Removed is not coming.

I tried with DiffInfo and DiffService code also, but in the Value Map I am not getting values. I am getting values {jcr:frozenUuid, sling:resourceType, jcr:uuid, jcr:frozenPrimaryType, jcr:primaryType. So my DiffText is coming Empty. Below is the code which I am using inside my Sections.jsp. Also Headline is Variable which is giving me Section Title corresponidng to Section .

  String diffOutput = null;

DiffInfo diffInfo = resource.adaptTo(DiffInfo.class);

            if (diffInfo != null) {
        DiffService diffService = sling.getService(DiffService.class);
        ValueMap map = ResourceUtil.getValueMap(diffInfo.getContent());  
        String diffText = map.get("title", "");

        diffOutput = diffService.diff(headLine, diffText, false);
        if (headLine.equals(diffOutput)) {
            diffOutput = null;
            if (diffOutput != null) {
                headLine = diffOutput;



Also I am creating section like section 1, 2. so each section has its Title and Description.


So since DiffText is coming empty and also adding <cq:text> is giving only text added, so is this mean I am creating components in a wrong way. If yes then how should I create components. My requirement is to have Version Difference Functionality for my article. please suggest me about way I should go.


0 Replies