Class MoveComponent

All Implemented Interfaces:
ClientBehaviorHolder, PartialStateHolder, StateHolder, TransientStateHolder, ComponentSystemEventListener, FacesListener, SystemEventListener, SystemEventListenerHolder, EventListener

public class MoveComponent extends UtilFamily implements SystemEventListener, ClientBehaviorHolder

The <o:moveComponent> component is a utility component via which components, facets and behaviors can be moved at runtime to a target component in various ways. This allows for simple programmatic composition of components using a declarative page author centric approach.

The destination of a move operation is specified in terms of a location that's relative to a given target component. The following shows a list of supported destinations:

  • BEFORE - Component is moved right before target component, i.e. as a sibling with an index that's 1 position lower.
  • ADD_FIRST - Component is added as the first child of the target component, any other children will have their index increased by 1.
  • ADD_LAST - Component is added as the last child of the target component, any other children will stay at their original location.
  • FACET - Component will be moved to the facet section of the target component under the name denoted by "facet".
  • BEHAVIOR - A Behavior will be moved to the behavior section of the target component.
  • AFTER - Component is moved right after target component, i.e. as a sibling with an index that's 1 position higher.
Since:
2.0
Author:
Arjan Tijms
See Also:
  • Field Details

    • COMPONENT_TYPE

      public static final String COMPONENT_TYPE
      The component type, which is "org.omnifaces.component.util.MoveComponent".
      See Also:
    • DEFAULT_SCOPE

      public static final String DEFAULT_SCOPE
      The default scope, which is "facelet".
      See Also:
  • Constructor Details

    • MoveComponent

      public MoveComponent()
      Constructs the component.
  • Method Details

    • isListenerForSource

      public boolean isListenerForSource(Object source)
      Specified by:
      isListenerForSource in interface SystemEventListener
    • processEvent

      public void processEvent(SystemEvent event)
      Specified by:
      processEvent in interface SystemEventListener
    • addClientBehavior

      public void addClientBehavior(String eventName, ClientBehavior behavior)
      Specified by:
      addClientBehavior in interface ClientBehaviorHolder
      Overrides:
      addClientBehavior in class UIComponentBase
    • getDefaultEventName

      public String getDefaultEventName()
      Specified by:
      getDefaultEventName in interface ClientBehaviorHolder
      Overrides:
      getDefaultEventName in class UIComponentBase
    • getEventNames

      public Collection<String> getEventNames()
      Specified by:
      getEventNames in interface ClientBehaviorHolder
      Overrides:
      getEventNames in class UIComponentBase
    • getFor

      public String getFor()
      Returns ID of the target component for which the component moving will be done.
      Returns:
      ID of the target component for which the component moving will be done.
    • setFor

      public void setFor(String forValue)
      Sets ID of the target component for which the component moving will be done.
      Parameters:
      forValue - ID of the target component for which the component moving will be done.
    • getDestination

      public MoveComponent.Destination getDestination()
      Returns the destination relative to the target component where the source component(s) are moved to. Default is ADD_LAST.
      Returns:
      The destination relative to the target component where the source component(s) are moved to.
    • setDestination

      public void setDestination(MoveComponent.Destination destinationValue)
      Sets the destination relative to the target component where the source component(s) are moved to. Valid values are
      • BEFORE - Component is moved right before target component, i.e. as a sibling with an index that's 1 position lower
      • ADD_FIRST - Component is added as the first child of the target component, any other children will have their index increased by 1
      • ADD_LAST - Component is added as the last child of the target component, any other children will stay at their original location
      • FACET - Component will be moved to the facet section of the target component under the name denoted by "facet"
      • BEHAVIOR - A Behavior will be moved to the behavior section of the target component
      • AFTER - Component is moved right after target component, i.e. as a sibling with an index that's 1 position higher
      Parameters:
      destinationValue - The destination relative to the target component where the source component(s) are moved to.
    • getFacet

      public String getFacet()
      Returns in case the destination is set to FACET, the name of the facet in the target component to which the components should be moved.
      Returns:
      In case the destination is set to FACET, the name of the facet in the target component to which the components should be moved.
    • setFacet

      public void setFacet(String facetValue)
      Sets in case the destination is set to FACET, the name of the facet in the target component to which the components should be moved.
      Parameters:
      facetValue - In case the destination is set to FACET, the name of the facet in the target component to which the components should be moved.
    • getBehaviorDefaultEvent

      public String getBehaviorDefaultEvent()
      Returns in case the destination is set to BEHAVIOR, the name of the default event that the target component is 'supposed' to have.
      Returns:
      In case the destination is set to BEHAVIOR, the name of the default event that the target component is 'supposed' to have.
    • setBehaviorDefaultEvent

      public void setBehaviorDefaultEvent(String behaviorDefaultEventValue)
      Sets in case the destination is set to BEHAVIOR, the name of the default event that the target component is 'supposed' to have. This normally does not need to be set, but might be needed for some over-eager tag handlers associated with a behavior that in advance try to check whether the behavior event matches with what the component supports.
      Parameters:
      behaviorDefaultEventValue - In case the destination is set to BEHAVIOR, the name of the default event that the target component is 'supposed' to have.
    • getBehaviorEvents

      public String getBehaviorEvents()
      Returns in case the destination is set to BEHAVIOR, the comma separated list events that the target component is 'supposed' to support.
      Returns:
      In case the destination is set to BEHAVIOR, the comma separated list events that the target component is 'supposed' to support.
    • setBehaviorEvents

      public void setBehaviorEvents(String behaviorEventsValue)
      Sets in case the destination is set to BEHAVIOR, the comma separated list events that the target component is 'supposed' to support. This normally does not need to be set, but might be needed for some over-eager tag handlers associated with a behavior that in advance try to check whether the behavior event matches with what the component supports.
      Parameters:
      behaviorEventsValue - In case the destination is set to BEHAVIOR, the comma separated list events that the target component is 'supposed' to support.