When there are special characters in linkText attribute, Java application using 2013 Tridion renders the link text and link without issues. When the same pageLink is being rendered in 8.5 Tridion, the link in java application is not rendered. There are no errors in micro service logs.

xhtml fragement with special characters in linkText field

 <tridion:PageLink pageURI="tcm:10-1008-64" linkText="&lt;span &gt;&lt;/span&gt; &lt;span class=&quot;total&quot;&gt;test&lt;/span&gt;" textOnFail="true" anchor="" linkAttributes=" id=&#34;dashboardTestLink&#34; data-rackvalue=&#34;Link - test&#34;"/>

Java code snippet

 PageLink myPageLink = new PageLink(publicationId);
 String strURL = getLink(myPageLink, pageURI, linkText, linkAttributes, textOnFail, parameters);

Using postman, we get back response for a


https://{contentmicroservice server name}client/v4/content.svc/GetPageLinkFunctionImport(PublicationId='10',TargetPageId='1008',Anchor='',LinkTagAttributes='',LinkText='&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;total&quot;&gt;Test&lt;/span&gt;',ShowTextOnFail='true') 


<content type="application/xml">
        <data:Parameters metadata:null="true"></data:Parameters>
  <data:Text>&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;total&amp;quot;&amp;gt;Test&amp;lt;/span&amp;gt;</data:Text>
        <data:TextOnFail metadata:type="Boolean">true</data:TextOnFail>

Question Can this be an issue with the Tridion API used in java application, fetching data with encoded special characters?

  • 1
    So the main difference from a Tridion perspective is that in 8.5 it's using the microservices to return this content. Have you tried using the same Java app code - but not using the Microservices? – Dylan .. Mark Saunders Mar 11 at 19:45
  • Enable the TRACE Logs in your web app to see what's happening for that link calls and DEBUG the application to get more informations what's going on? – Velmurugan Mar 11 at 20:41

I think the issue is only with the slash special character. Rest of the special characters are fine.

For instance, if I call the getLinkAsString method (getLink method in your Java code snippet will be calling getLinkAsString I suppose) like the below code snippet, I am able to get the page URL. Note the link text property has no backslash before the span tag.

PageLink pageLink = new PageLink(19);
String strUrl = pageLink.getLinkAsString(1016, "", "id=&#34;rewards&#34; data-trackvalue=&#34;rewards link&#34;",
     "&lt;span class=&quot;icon mIcon trophy full&quot;&gt;&lt;span&gt;&lt;span class=&quot;total&quot;&gt;Rewards&lt;span&gt;", true);

The output will be like this:

enter image description here

But when there is a slash in the link text property, an exception is thrown.

enter image description here

Option 1 (tested): Allow slashes

There is a way to allow for slashes and the answer to that is here: Web 8 DXA 1.5 Java web site failing with "Unable to get response from OData service". We basically have to update the JVM args of the content microservice to allow slashes. After uninstalling and installing the content service with the updated JVM options, the issue should be resolved.

enter image description here

Option 2 (not tested): Escape slashes in the link text

I am not sure if there are any hotfix for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.