Class Any

  • All Implemented Interfaces:
    ClientElement

    @SupportsInformalParameters
    public class Any
    extends Object
    implements ClientElement
    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 (&nbsp;) 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 { ... }
    Component Parameters 
    NameTypeFlagsDefaultDefault Prefix
    clientIdString prop:componentResources.idliteral
    The desired client id, which defaults to the component's id.
    elementString  literal
    The name of the element to be rendered, typically one of the standard (X)HTML elements, "div", "span", "a", etc., although practically any string will be accepted. The default comes from the template, or is "div" if the template does not specify an element.
    • Constructor Detail

      • Any

        public Any()
    • Method Detail

      • getClientId

        public String getClientId()
        Returns the client id. This has side effects: this first time this is called (after the Any component renders its start tag), a unique id is allocated (based on, and typically the same as, the clientId parameter, which defaults to the component's id). The rendered element is updated, with its id attribute set to the unique client id, which is then returned.
        Specified by:
        getClientId in interface ClientElement
        Returns:
        unique client id for this component