Uploaded image for project: 'Click'
  1. Click
  2. CLK-288

Consider making getStyleBlock and getScriptBlock first class citizens

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 1.5 M1
    • None
    • core
    • None
    • Click 1.5

    Description

      Javascript and stylesheets can either be external or embedded in the html.

      Currently Click support getHtmlImports which can return both external and embeded code. However there is a restriction: each line from getHtmlImport must be unique for the page.

      For external files this works out quite well. But <script> and <style> blocks makes for some messy strings in java. Custom controls especially AJAX ones, could really benefit from this. Also it is extremely hard to debug javascript code which appear on one line.

      Since Velocity can render javacsript and css equally well it would be nice to write these blocks in Velocity. Javascript id's and css paths could be passed into the template. Off course one can still use HtmlStringBuffer, but without the restriction of having the block in one line.

      Another advantage is the separation of embedded vs external code. Placing the embedded code below the external code means the javascript libraries will be available when the embedded code are executed.

      Thinking about implementation we need methods getStyleBlock and getScriptBlock that PageImports can slurp up. Adding these to Control might be asking too much, so perhaps AbstractControl? PageImports can check for AbstractControl instances just like it does for Form,Table etc and append the blocks from those controls.

      It might be worth thinking about exposing these methods on Page as well. Since Page maps one-to-one to the html page, it seems quite logical that a Page could contribute and customize <style> and <script> blocks.

      Attachments

        Activity

          People

            sabob Bob Schellink
            sabob Bob Schellink
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: