Class Behavior

    • Constructor Detail

      • Behavior

        public Behavior()
    • Method Detail

      • beforeRender

        public void beforeRender​(Component component)
        Called when a component is about to render.
        component - the component that has this behavior coupled
      • afterRender

        public void afterRender​(Component component)
        Called when a component that has this behavior coupled was rendered.
        component - the component that has this behavior coupled
      • bind

        public void bind​(Component component)
        Bind this handler to the given component. This method is called by the host component immediately after this behavior is added to it. This method is useful if you need to do initialization based on the component it is attached and you can't wait to do it at render time. Keep in mind that if you decide to keep a reference to the host component, it is not thread safe anymore, and should thus only be used in situations where you do not reuse the behavior for multiple components.
        component - the component to bind to
      • unbind

        public void unbind​(Component component)
        Notifies the behavior it is removed from the specified component
        component - the component this behavior is unbound from
      • detach

        public void detach​(Component component)
        Allows the behavior to detach any state it has attached during request processing.
        component - the component that initiates the detachment of this behavior
      • getStatelessHint

        public boolean getStatelessHint​(Component component)
        This method returns false if the behavior generates a callback url (for example ajax behaviors)
        component - the component that has this behavior coupled.
        boolean true or false.
      • isEnabled

        public boolean isEnabled​(Component component)
        Called when a components is rendering and wants to render this behavior. If false is returned this behavior will be ignored.
        component - the component that has this behavior coupled
        true if this behavior must be executed/rendered
      • onComponentTag

        public void onComponentTag​(Component component,
                                   ComponentTag tag)
        Called any time a component that has this behavior registered is rendering the component tag.
        component - the component that renders this tag currently
        tag - the tag that is rendered
      • isTemporary

        public boolean isTemporary​(Component component)
        Specifies whether or not this behavior is temporary. Temporary behaviors are removed at the end of request and never reattached. Such behaviors are useful for modifying component rendering only when it renders next. Usecases include javascript effects, initial clientside dom setup, etc.
        component -
        true if this behavior is temporary
      • canCallListener

        public boolean canCallListener​(Component component)
        Checks whether or not an IRequestListener can be invoked on this behavior. For further information please read the javadoc on Component.canCallListener(), this method has the same semantics. WARNING: Read the javadoc of Component.canCallListener() for important security-related information.
        component - component this behavior is attached to
        true iff the listener method can be invoked
      • onConfigure

        public void onConfigure​(Component component)
        Called immediately after the onConfigure method in a component. Since this is before the rendering cycle has begun, the behavior can modify the configuration of the component (i.e. setVisible(false))
        component - the component being configured
      • onRemove

        public void onRemove​(Component component)
        Called to notify that the component is being removed from its parent
        component - the removed component
      • onTag

        public static Behavior onTag​(<Component,​ComponentTag> onTagConsumer)
        Creates a Behavior that uses the given SerializableConsumer consumer to do something with the component's tag.

        component.add(onTag(tag -> tag.put(key, value)));

        onTagConsumer - the SerializableConsumer that accepts the ComponentTag
        The created behavior
      • onAttribute

        public static Behavior onAttribute​(String name,
                                 <String,​CharSequence> onAttribute)
        Creates a Behavior that uses the given SerializableFunction function to do something with a component's attribute.

        component.add(onAttribute("class", currentValue -> condition(currentValue) ? "positive" : "negative"));

        name - the name of the attribute to manipulate
        onAttribute - the SerializableFunction that accepts the old value of the attribute and returns a new value
        The created behavior