You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Ability to manipulate HTML imports.

There are scenarios where manipulating a Control's HTML imports would be beneficial, especially for Ajax components.

Ajax libraries such as Prototype, JQuery, YUI etc promotes Unobtrusive JavaScript, which is basically the ability to add functionality and events to HTML markup without mixing the JavaScript and markup. In other words all the JavaScript can be added to the Page HEAD section.

The only thing a Control needs to do is render the necessary markup, and append the JavaScript to the HTML imports.

Because one cannot manipulate a Control's HTML imports the only way to write JavaScript/Ajax controls currently, is to create subclasses of a specific control and override the method getHtmlImports to return the required JavaScript.

If we provide the ability to manipulate the HTML imports from outside the Control, it becomes possible to write Ajax helpers that can add the necessary JavaScript without having to subclass Controls. It might even be possible to write a single generic Ajax helper to manipulate all of the Controls.

As far as implementation goes, the Control interface could provide the methods public boolean hasImports and public List getImports.

getImports can be used to add new HTML imports to the Controls, while hasImports indicates whether imports are available.

JIRA Issues

This issue is also being discussed in https://issues.apache.org/jira/browse/CLK-501

  • No labels