Methods ending with 'html' whose return value is passed to a Soy template, renders an unexpected String value

XMLWordPrintable

    • Severity 3 - Minor
    • RtB - Service ops & Tech entropy

      Issue Summary

      The contributing factors to this bug have not yet been isolated. Please refer to the reproduction steps below.

      Steps to Reproduce

      In General:

      1. Create a plugin
      2. Define a Struts Action which maps to a Velocity Result
      3. Define a getter method on Action class whose name ends with 'html' and returns a String
      4. Have the Velocity template render a Soy template, where the 'value' parameter is obtained from the aforementioned method
        #set($templateParameters = {
            "type": "textarea",
            "labelContent": "$i18n.getText('user.macro.template')",
            "name": "userMacro.template",
            "id": "userMacro_template",
            "value": $!action.templateHtml,
            "rows": "20",
            "cols": "80",
            "extraFieldClasses": "max-textarea",
            "description": "$i18n.getText('user.macro.template.desc', [$docBean.getLink('help.user.macro.templates')])",
            "required": "$i18n.getText('required.field')"})
        $soyTemplateRendererHelper.getRenderedTemplateHtml("com.atlassian.auiplugin:aui-experimental-soy-templates", "aui.form.field.soy", $templateParameters) 
      5. Browse to the Action and trigger rendering of template

      OR

      In Confluence Core codebase:

      1. Edit confluence-core/confluence-webapp/src/main/webapp/admin/macros/usermacro-form.vm
      2. Replace $!templateHtml with $!action.templateHtml
      3. Visit /admin/addusermacro-start.action

      Expected Results

      A form input field whose default value is the String returned by the previously defined method.

      Actual Results

      Expected value is prepended by

      {annotationCollection: [{}], annotations: [{}], collectionInheritableAnnotations: [{}], declaredAnnotations: [{}], description: Annotated value: 

       and appended by

      ; Annotations: [@com.atlassian.velocity.htmlsafe.HtmlSafe()]} 

      Workaround

      Instead of passing the value using:

      $action.methodNameHtml

      Use the OGNL shortcut:

      $methodNameHtml

            Assignee:
            Unassigned
            Reporter:
            Kusal Kithul-Godage
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: