You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by "Bob Schellink (JIRA)" <ji...@apache.org> on 2009/03/08 22:40:10 UTC

[JIRA] Created: (CLK-501) Add first class support for HTML Head resources such as Javascript and CSS

Add first class support for HTML Head resources such as Javascript and CSS
--------------------------------------------------------------------------

                 Key: CLK-501
                 URL: http://issues.apache.org/click/browse/CLK-501
             Project: Click
          Issue Type: New Feature
          Components: core
            Reporter: Bob Schellink
            Assignee: Bob Schellink
             Fix For: 2.1.0


Currently Click supports HTML imports by overriding the method #getHtmlImports. 

This method is string based which makes it difficult to support advanced features such as templating, conditional imports, resource versioning etc.

This feature request proposes to introduce first class HTML header resource classes including Javascript, JavascriptImport, CssImport and Css.

Further a new method should be added to the Control interface: 'public List getHtmlHeaders' which returns a list of the Page or Control's HTML HEAD entries.

This makes it possible to modify the Javascript and CSS imports without overriding a Control.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[JIRA] Commented: (CLK-501) Add first class support for HTML Head resources such as Javascript and CSS

Posted by "Malcolm Edgar (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/click/browse/CLK-501?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11724#action_11724 ] 

Malcolm Edgar commented on CLK-501:
-----------------------------------

In terms of a design we could introduce a HTML Element class which can be used for:
* TitleElement
* CssStyleElement
* CssImportElement
* JsScriptElement
* JsImportElement

A Page could expose the methods:

List<Element> getHeadElements()

List<Element> getJsElements()

In the page template users would do something like:
<html>
<head>
#foreach ($element in $headElements)
$element
#end
</head>
<body>

<body>
#foreach ($element in $jsElements)
$element
#end




> Add first class support for HTML Head resources such as Javascript and CSS
> --------------------------------------------------------------------------
>
>                 Key: CLK-501
>                 URL: http://issues.apache.org/click/browse/CLK-501
>             Project: Click
>          Issue Type: New Feature
>          Components: core
>            Reporter: Bob Schellink
>            Assignee: Bob Schellink
>             Fix For: 2.1.0
>
>
> Currently Click supports HTML imports by overriding the method #getHtmlImports. 
> This method is string based which makes it difficult to support advanced features such as templating, conditional imports, resource versioning etc.
> This feature request proposes to introduce first class HTML header resource classes including Javascript, JavascriptImport, CssImport and Css.
> Further a new method should be added to the Control interface: 'public List getHtmlHeaders' which returns a list of the Page or Control's HTML HEAD entries.
> This makes it possible to modify the Javascript and CSS imports without overriding a Control.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[JIRA] Commented: (CLK-501) Add first class support for HTML Head resources such as Javascript and CSS

Posted by "Bob Schellink (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/click/browse/CLK-501?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11733#action_11733 ] 

Bob Schellink commented on CLK-501:
-----------------------------------

I also thought about leveraging onRender, however users can skip this phase by returning false from an action listener.

At least 3 approaches exist to add elements to the HeadElements List. 

# in the Page/Control constructor
# overriding getHeadElements using lazy loading
# in onInit and onProcess. However in this case the HeadElements List must be nullified in the onDestroy callback. This ensures no memory leaks exist with stateful pages

> The Container controls then iterate through their children doing the same

My current approach is not to let the Container return their child control Head elements. Instead PageImports recursively process each Control. The reason that each Control and Container return only their own List of Head Elements, is to introduce the ability to dynamically add/remove a Control's Javascript and CSS at runtime.

Introducing Element will also raise the question of how it ties in with Control. Should AbstractControl extend Element?

Another thing to keep in mind is that TitleElement and CacheElement can also be supported through a BorderPage and custom Velocity variables instead of HeadElements.


> Add first class support for HTML Head resources such as Javascript and CSS
> --------------------------------------------------------------------------
>
>                 Key: CLK-501
>                 URL: http://issues.apache.org/click/browse/CLK-501
>             Project: Click
>          Issue Type: New Feature
>          Components: core
>            Reporter: Bob Schellink
>            Assignee: Bob Schellink
>             Fix For: 2.1.0
>
>
> Currently Click supports HTML imports by overriding the method #getHtmlImports. 
> This method is string based which makes it difficult to support advanced features such as templating, conditional imports, resource versioning etc.
> This feature request proposes to introduce first class HTML header resource classes including Javascript, JavascriptImport, CssImport and Css.
> Further a new method should be added to the Control interface: 'public List getHtmlHeaders' which returns a list of the Page or Control's HTML HEAD entries.
> This makes it possible to modify the Javascript and CSS imports without overriding a Control.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[JIRA] Commented: (CLK-501) Add first class support for HTML Head resources such as Javascript and CSS

Posted by "Malcolm Edgar (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/click/browse/CLK-501?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11726#action_11726 ] 

Malcolm Edgar commented on CLK-501:
-----------------------------------

Another useful Element would be MetaElement for header meta data tags which are used by search engines.

This stuff should probably go into its own package:  ogr.apache.click.element

> Add first class support for HTML Head resources such as Javascript and CSS
> --------------------------------------------------------------------------
>
>                 Key: CLK-501
>                 URL: http://issues.apache.org/click/browse/CLK-501
>             Project: Click
>          Issue Type: New Feature
>          Components: core
>            Reporter: Bob Schellink
>            Assignee: Bob Schellink
>             Fix For: 2.1.0
>
>
> Currently Click supports HTML imports by overriding the method #getHtmlImports. 
> This method is string based which makes it difficult to support advanced features such as templating, conditional imports, resource versioning etc.
> This feature request proposes to introduce first class HTML header resource classes including Javascript, JavascriptImport, CssImport and Css.
> Further a new method should be added to the Control interface: 'public List getHtmlHeaders' which returns a list of the Page or Control's HTML HEAD entries.
> This makes it possible to modify the Javascript and CSS imports without overriding a Control.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[JIRA] Commented: (CLK-501) Add first class support for HTML Head resources such as Javascript and CSS

Posted by "Bob Schellink (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/click/browse/CLK-501?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11730#action_11730 ] 

Bob Schellink commented on CLK-501:
-----------------------------------

Hi Malcolm,

I like the idea of a more generic approach to HTML headers and housing these classes in their own package.

How do you see Page and Control imports integrate though? For example will #getHeadElements return the Control imports as well? Or will Control imports be specified separately with the $cssIncludes and jsIncludes variables?

kind regards

bob

> Add first class support for HTML Head resources such as Javascript and CSS
> --------------------------------------------------------------------------
>
>                 Key: CLK-501
>                 URL: http://issues.apache.org/click/browse/CLK-501
>             Project: Click
>          Issue Type: New Feature
>          Components: core
>            Reporter: Bob Schellink
>            Assignee: Bob Schellink
>             Fix For: 2.1.0
>
>
> Currently Click supports HTML imports by overriding the method #getHtmlImports. 
> This method is string based which makes it difficult to support advanced features such as templating, conditional imports, resource versioning etc.
> This feature request proposes to introduce first class HTML header resource classes including Javascript, JavascriptImport, CssImport and Css.
> Further a new method should be added to the Control interface: 'public List getHtmlHeaders' which returns a list of the Page or Control's HTML HEAD entries.
> This makes it possible to modify the Javascript and CSS imports without overriding a Control.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[JIRA] Commented: (CLK-501) Add first class support for HTML Head resources such as Javascript and CSS

Posted by "Malcolm Edgar (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/click/browse/CLK-501?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11732#action_11732 ] 

Malcolm Edgar commented on CLK-501:
-----------------------------------

I have this feeling, that what I am advocating is something you proposed earlier.

I haven't thought through the integration.  Off the top of my head I would imagine, controls would have the same methods:

List<Element> getHeadElements() 

List<Element> getJsElements() 

The ClickServlet processes the page controls calling their onRender() methods.  The Container controls then iterate through their children doing the same.  At this point it is up to the individual control to add its Elements (Head, JS) to the parent Page's corresponding HeadElements or JsElements. 

These page elements would automatically be added to the Velocity context / JSP request attributes before rendering.

We could introduce some sort of adaptor mechanism to support depreciated getHtmlImports()  methods.

regards Malcolm Edgar

> Add first class support for HTML Head resources such as Javascript and CSS
> --------------------------------------------------------------------------
>
>                 Key: CLK-501
>                 URL: http://issues.apache.org/click/browse/CLK-501
>             Project: Click
>          Issue Type: New Feature
>          Components: core
>            Reporter: Bob Schellink
>            Assignee: Bob Schellink
>             Fix For: 2.1.0
>
>
> Currently Click supports HTML imports by overriding the method #getHtmlImports. 
> This method is string based which makes it difficult to support advanced features such as templating, conditional imports, resource versioning etc.
> This feature request proposes to introduce first class HTML header resource classes including Javascript, JavascriptImport, CssImport and Css.
> Further a new method should be added to the Control interface: 'public List getHtmlHeaders' which returns a list of the Page or Control's HTML HEAD entries.
> This makes it possible to modify the Javascript and CSS imports without overriding a Control.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[JIRA] Commented: (CLK-501) Add first class support for HTML Head resources such as Javascript and CSS

Posted by "Bob Schellink (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/click/browse/CLK-501?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11734#action_11734 ] 

Bob Schellink commented on CLK-501:
-----------------------------------

Made the following changes:

# renamed method getHtmlHeaders to getHeadElements

# added new package 'element' and moved utility classes to this package

# the following elements were added: Element, ResourceElement, CssImport, CssStyle, JsImport, JsScript. ResourceElement is new and is the super class of Javascript and CSS elements. ResourceElement could also be used as the super class of an Image element.

# new PageImports variables $headElements and $jsElements. The other variables still exist for backward compatibility



> Add first class support for HTML Head resources such as Javascript and CSS
> --------------------------------------------------------------------------
>
>                 Key: CLK-501
>                 URL: http://issues.apache.org/click/browse/CLK-501
>             Project: Click
>          Issue Type: New Feature
>          Components: core
>            Reporter: Bob Schellink
>            Assignee: Bob Schellink
>             Fix For: 2.1.0
>
>
> Currently Click supports HTML imports by overriding the method #getHtmlImports. 
> This method is string based which makes it difficult to support advanced features such as templating, conditional imports, resource versioning etc.
> This feature request proposes to introduce first class HTML header resource classes including Javascript, JavascriptImport, CssImport and Css.
> Further a new method should be added to the Control interface: 'public List getHtmlHeaders' which returns a list of the Page or Control's HTML HEAD entries.
> This makes it possible to modify the Javascript and CSS imports without overriding a Control.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.