Turns any arbitrary (X)HTML element into a component. The element's start and end
tags are rendered, including any informal parameters and possibly an id
attribute. The id is provided by
JavaScriptSupport.allocateClientId(String)
(so it will be unique on the client side) and is available after the component
renders using
getClientId()
. The Any component has no template of its
own but does render its body, if any.
Some common uses are:
- Applying a mixin to an ordinary HTML element. For example,
the following turns an img element into a component that, via the
RenderNotification
mixin, triggers event
notifications when it enters the BeginRender and EndRender phases:
<img t:type="any" t:mixins="renderNotification">
And the following renders a td element with the
NotEmpty
mixin to ensure
that a non-breaking space ( ) is rendered if the td element would
otherwise be empty:
<td t:type="any" t:mixins="NotEmpty">
- Providing a dynamically-generated client ID for an HTML element
in a component rendered in a loop or zone (or more than once in a page), for
use from JavaScript. (The component class will typically use
InjectComponent
to get the component, then call getClientId()
to retrieve the ID.)
<table t:type="any" id="clientId">
As an alternative to calling getClientId, you can use the
RenderClientId
mixin to force the id attribute to appear in the HTML:
<table t:type="any" t:mixins="RenderClientId">
- Dynamically outputting a different HTML element depending on
the string value of a property. For example, the following renders an element
identified by the "element" property in the corresponding component class:
<t:any element="prop:element" ... >
- As the base component for a new custom component, especially convenient
when the new component should support informal parameters or needs a dynamically
generated client ID:
public class MyComponent extends Any { ... }