Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-10101

Can't list all properties of a Document in Freemarker (ClassCastException on doc?keys)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.5
    • Fix Version/s: 5.7.1
    • Component/s: WebEngine

      Description

      When trying to list all properties of a Document in a Freemarker template view (for loggin purpose) using the ?keys builtin (since a Document is a Hash in Freemarker), there is a ClassCastException (see below).

      To patch it, reimplement DocumentTemplate.keys()
      from
      return (TemplateCollectionModel) wrapper.wrap(getRawKeys());
      to
      return new CollectionAndSequence(new SimpleSequence(getRawKeys(), wrapper));
      and it should do the trick.

      Caused by: java.lang.ClassCastException: 
      freemarker.template.SimpleSequence cannot be cast to freemarker.template.TemplateCollectionModel 
       at org.nuxeo.ecm.platform.rendering.fm.adapters.DocumentTemplate.keys(DocumentTemplate.java:89) 
        at freemarker.core.BuiltIn$keysBI._getAsTemplateModel(BuiltIn.java:588) 
         at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) 
          at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94) 
           at freemarker.core.Environment.visit(Environment.java:208) 
            at freemarker.core.MixedContent.accept(MixedContent.java:92) 
             at freemarker.core.Environment.visit(Environment.java:208) 
              at freemarker.core.Environment.process(Environment.java:188) 
               at org.nuxeo.ecm.platform.rendering.fm.FreemarkerEngine.render(FreemarkerEngine.java:183) ... 66 more 
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: