Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.4
    • Security Level: Public (Public: Anyone can view)
    • Labels:
      None
    • Similar issues:
      KULRICE-10353Inline processing of FreeMarker templates
      KULRICE-11869FreeMarker error in testTransactionView
      KULRICE-10604Light table examples not rendering freemarker exception in logs
      KULRICE-12258AFT Failure DemoContainerTreeGroupAft doesn't render Freemarker Exception in logs spring.ftl
      KULRICE-11408Kitchen sink rendering error
      KULRICE-11791AFT Failure some pages don't render, Freemarker Incident Report (groupWrap.ftl) in view source
      KULRICE-7764Render template not being found in unexploded war
      KULRICE-10532KRAD Demo Library Freemarker Exception in header.ftl
      KULRICE-10421AFT Failure: DemoLibraryCollectionFeaturesLightTableSmokeTest inline freemarker exception
      KULRICE-13073AFT Failure: Pages not loading - freemarker exception in logs
    • Epic Link:
    • Rice Module:
      KRAD
    • KAI Review Status:
      Not Required
    • KTI Review Status:
      Not Required
    • Code Review Status:
      Not Required
    • Include in Release Notes?:
      Yes

      Description

      Freemarker rendering phase extension:
      Add an optional lifecycle phase after performComponentFinalize() to perform rendering via an embedded FreeMarker environment, then capture the output as renderedHtmlOutput and toggle selfRendered to true.

        Issue Links

          Activity

          Hide
          Mark Fyffe (Inactive) added a comment -

          Added performComponentRender() lifecycle phase, and simple unit test to prove correct operation. Will work through additional test cases and more complex scenarios tomorrow.

          The simple unit test demonstrating the component rendering phase is repeated below -

              @Test
              public void testMessageNoReflection() throws Throwable {
                  final Message m = ViewLifecycle.encapsulateInitialization(new Callable<Message>() {
                      @Override
                      public Message call() throws Exception {
                          Message m = new Message();
                          m.setTemplate("/krad/WEB-INF/ftl/components/element/message.ftl");
                          m.setTemplateName("uif_message");
                          m.setCssClasses(Arrays.asList("uif-message"));
                          m.setMessageText("foobar");
                          return m;
                      }
                  });
          
                  View view = mock(View.class);
                  ViewLifecycle.encapsulateLifecycle(view, new Runnable() {
                      @Override
                      public void run() {
                          Message msg = m.copy();
                          ViewLifecycle.getActiveLifecycle().performComponentRender(msg);
                          
                          assertTrue(msg.isSelfRendered());
                          assertEquals("<span id=\"_span\" class=\"uif-message\"   >\r\n" +
                                  "foobar    </span>", msg.getRenderedHtmlOutput().trim());
                      }
                  });
              }
          
          Show
          Mark Fyffe (Inactive) added a comment - Added performComponentRender() lifecycle phase, and simple unit test to prove correct operation. Will work through additional test cases and more complex scenarios tomorrow. The simple unit test demonstrating the component rendering phase is repeated below - @Test public void testMessageNoReflection() throws Throwable { final Message m = ViewLifecycle.encapsulateInitialization( new Callable<Message>() { @Override public Message call() throws Exception { Message m = new Message(); m.setTemplate( "/krad/WEB-INF/ftl/components/element/message.ftl" ); m.setTemplateName( "uif_message" ); m.setCssClasses(Arrays.asList( "uif-message" )); m.setMessageText( "foobar" ); return m; } }); View view = mock(View.class); ViewLifecycle.encapsulateLifecycle(view, new Runnable () { @Override public void run() { Message msg = m.copy(); ViewLifecycle.getActiveLifecycle().performComponentRender(msg); assertTrue(msg.isSelfRendered()); assertEquals( "<span id=\" _span\ " class=\" uif-message\ " >\r\n" + "foobar </span>" , msg.getRenderedHtmlOutput().trim()); } }); }
          Hide
          Mark Fyffe (Inactive) added a comment -

          Updated unit tests to use ComponentFactory instead of hand-built message components. Added rendering phase constants.

          Will complete rendering phase after refactoring other existing phases for KULRICE-10549, prior to conversion thread pool configuration.

          Show
          Mark Fyffe (Inactive) added a comment - Updated unit tests to use ComponentFactory instead of hand-built message components. Added rendering phase constants. Will complete rendering phase after refactoring other existing phases for KULRICE-10549 , prior to conversion thread pool configuration.
          Hide
          Mark Fyffe (Inactive) added a comment -

          Completed rendering phase extension and committed. This extension can be enabled using the config parameter "rice.krad.lifecycle.render".

          When enabled, the finalize phase will queue rendering tasks for bottom-up traversal. Components that define a template, and for which the template defines a macro with a single argument that matches the value of the componentType property will be rendered using the inline rendering extension added on KULRICE-10353.

          Once the rendering phase is complete, the rendered output is populated in the renderedHtmlOutput property on the component and selfRendered set to true. When parent components reach the pre-rendered component, whether rendered in the lifecycle or during the normal SpringMVC rendering phase, the previously rendered output will be inserted.

          Once the thread pool has been configured for KULRICE-10549, FreeMarker rendering will be multi-threaded along with the rest of the lifecycle as long as the rendering extension is enabled.

          Unless the extension is enabled, normal rendering behavior will be retained. Will work to identify issues with the extension enabled and clean up under KULRICE-10550.

          Show
          Mark Fyffe (Inactive) added a comment - Completed rendering phase extension and committed. This extension can be enabled using the config parameter "rice.krad.lifecycle.render". When enabled, the finalize phase will queue rendering tasks for bottom-up traversal. Components that define a template, and for which the template defines a macro with a single argument that matches the value of the componentType property will be rendered using the inline rendering extension added on KULRICE-10353 . Once the rendering phase is complete, the rendered output is populated in the renderedHtmlOutput property on the component and selfRendered set to true. When parent components reach the pre-rendered component, whether rendered in the lifecycle or during the normal SpringMVC rendering phase, the previously rendered output will be inserted. Once the thread pool has been configured for KULRICE-10549 , FreeMarker rendering will be multi-threaded along with the rest of the lifecycle as long as the rendering extension is enabled. Unless the extension is enabled, normal rendering behavior will be retained. Will work to identify issues with the extension enabled and clean up under KULRICE-10550 .
          Hide
          Mark Fyffe (Inactive) added a comment -
          Show
          Mark Fyffe (Inactive) added a comment - Added code review https://fisheye.kuali.org/cru/rice-307

            People

            • Assignee:
              Mark Fyffe (Inactive)
              Reporter:
              Jerry Neal (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 4 hours
                4h
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours
                4h

                  Structure Helper Panel