2

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

Request

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') 

Response

<content type="application/xml">
    <metadata:properties>
        <data:LinkUUID>22c10e4c-88c2-8aeff034c23f</data:LinkUUID>
        <data:Url>/test/Page.xhtml</data:Url>
        <data:Anchor></data:Anchor>
        <data:Parameters metadata:null="true"></data:Parameters>
        <data:TargetURI>tcm:10-1008-64</data:TargetURI>
  <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:Attributes></data:Attributes>
        <data:TextOnFail metadata:type="Boolean">true</data:TextOnFail>
    </metadata:properties>
</content>

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

2
  • 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? Commented Mar 11, 2019 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
    Commented Mar 11, 2019 at 20:41

1 Answer 1

5

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 and acknowledge you have read our privacy policy.

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