Class WRepeater

    • Constructor Detail

      • WRepeater

        public WRepeater()
        Creates a WRepeater without any repeated component. The method setRepeatedComponent(WComponent) must be called to configure the repeater.
      • WRepeater

        public WRepeater​(WComponent repeatedComponent)
        Creates a WRepeater which will repeat the given component.
        Parameters:
        repeatedComponent - the component to repeat.
    • Method Detail

      • setRepeatedComponent

        public void setRepeatedComponent​(WComponent repeatedComponent)
        Set the wcomponent instance capable of handling a row. The component must implement at least one of the DataBound, BeanBound or BeanProviderBound interfaces. The data entries in the bean list passed to this repeater must be compatible with the component.
        Parameters:
        repeatedComponent - the component to repeat.
      • setBeanList

        public void setBeanList​(List beanList)
        Remember the list of beans that hold the data object for each row.
        Parameters:
        beanList - the list of data objects for each row.
      • clearScratchMaps

        protected void clearScratchMaps​(WComponent node)
        Recursively clears cached component scratch maps. This is called when the bean list changes, as the beans may have changed.
        Parameters:
        node - the component branch to clear cached data in.
      • getBeanList

        public List getBeanList()
        Retrieves the list of dataBeans that holds the data object for each row. The list returned will be the same instance as the one supplied via the setBeanList method. Will never return null, but it can return an empty list.
        Returns:
        the list of dataBeans that holds the data object for each row
      • setData

        public void setData​(Object dataBean)
        Remember the list of dataBeans that holds the data object for each row.
        Specified by:
        setData in interface DataBound
        Overrides:
        setData in class WBeanComponent
        Parameters:
        dataBean - Must be a java.util.List of dataBeans.
      • cleanupStaleContexts

        protected void cleanupStaleContexts​(Set<?> rowIds)
        Removes any stale contexts from the row context map.
        Parameters:
        rowIds - the current set of row Ids.
      • tidyUpUIContext

        public void tidyUpUIContext()
        Removes any component models that are in their default state.

        The subContexts are held onto as they hold the "render id" for the row. This is needed to be able to match the rendered row back to the subcontext.

        Overrides:
        tidyUpUIContext in class AbstractWComponent
      • preparePaintComponent

        protected void preparePaintComponent​(Request request)
        Override preparePaintComponent to prepare each row for painting.
        Overrides:
        preparePaintComponent in class AbstractWComponent
        Parameters:
        request - the request being responded to.
      • prepareRow

        protected void prepareRow​(Request request,
                                  int rowIndex)
        Prepares a single row for painting.
        Parameters:
        request - the request being responded to.
        rowIndex - the row index.
      • getRowIdName

        protected String getRowIdName​(Object rowBean,
                                      Object rowId)
        Allows a subclass to provide the ID used in the row naming context.

        The returned ID must only contain letters, digits or underscores.

        Parameters:
        rowBean - the row's bean
        rowId - the row id
        Returns:
        the unique row id or null to use the row context id
      • setRowIdProperty

        public void setRowIdProperty​(String rowIdProperty)
        Sets the bean property that can be used to obtain each row's unique id.
        Parameters:
        rowIdProperty - the row id property, using jakarta PropertyUtils notation
      • getComponentModel

        protected WRepeater.RepeaterModel getComponentModel()
        Returns the effective component model for this component. Subclass may override this method to narrow the return type to their specific model type.
        Overrides:
        getComponentModel in class WBeanComponent
        Returns:
        the effective component model
      • getOrCreateComponentModel

        protected WRepeater.RepeaterModel getOrCreateComponentModel()
        Retrieves the model for this component so that it can be modified. If this method is called during request processing, and a session specific model does not yet exist, then a new model is created. Subclasses may override this method to narrow the return type to their specific model type.
        Overrides:
        getOrCreateComponentModel in class WBeanComponent
        Returns:
        the model for this component
      • getRowContext

        public UIContext getRowContext​(Object rowBean)
        Retrieves the UIContext for a row, where the row index is not known.
        Parameters:
        rowBean - the row's bean.
        Returns:
        The context for the given row.
      • getRowContext

        public UIContext getRowContext​(Object rowBean,
                                       int rowIndex)
        Retrieves the UIContext for a row.
        Parameters:
        rowBean - the row's bean.
        rowIndex - the row index.
        Returns:
        The context for the given row.
      • getRowBeanForSubcontext

        public Object getRowBeanForSubcontext​(WRepeater.SubUIContext subContext)
        Returns the row data for the given row context.
        Parameters:
        subContext - the row context.
        Returns:
        the data bean for the given row context.
      • getRowId

        protected Object getRowId​(Object rowBean)
        Retrieves the row id for the given row.
        Parameters:
        rowBean - the row's data.
        Returns:
        the id for the given row. Defaults to the row data.
      • getRowContexts

        public List<UIContext> getRowContexts()
        Retrieves the row contexts for all rows.
        Returns:
        A list containing a UIContext for each row. Will never return null, but it can return an empty list.
      • getRepeatRoot

        protected WRepeater.WRepeatRoot getRepeatRoot()
        Retrieves the repeat root, creating one if necessary.
        Returns:
        the repeat root.
      • getRepeatedComponent

        public WComponent getRepeatedComponent()
        Retrieves the repeated component, that is used to render each row.
        Returns:
        the repeated component
      • getRepeatedComponent

        public WComponent getRepeatedComponent​(int row)
        Retrieves the repeated component for the specified row.
        Parameters:
        row - the row number.
        Returns:
        the repeated component for the specified row.
      • getChildCount

        public int getChildCount()
        Specified by:
        getChildCount in interface Container
        Returns:
        the number of child components currently contained within this component.
      • getChildAt

        public WComponent getChildAt​(int index)
        Retrieves a child component by its index.
        Specified by:
        getChildAt in interface Container
        Parameters:
        index - the index of the child component to be retrieved.
        Returns:
        the child component at the given index.
      • getIndexOfChild

        public int getIndexOfChild​(WComponent childComponent)
        Retrieves the index of the given child.
        Specified by:
        getIndexOfChild in interface Container
        Parameters:
        childComponent - the child component to retrieve the index for.
        Returns:
        the index of the given child component, or -1 if the component is not a child of this component.
      • getChildren

        public List<WComponent> getChildren()
        Retrieves a list of this Container's.
        Specified by:
        getChildren in interface Container
        Returns:
        an immutable list of this Container.
      • toString

        public String toString()
        Description copied from class: AbstractWComponent
        Creates a String representation of this component; usually for debugging purposes.
        Overrides:
        toString in class AbstractWComponent
        Returns:
        a String representation of this component, for debugging purposes.
      • isNamingContext

        public boolean isNamingContext()
        A naming context is only considered active if an Id name has been set.
        Specified by:
        isNamingContext in interface NamingContextable
        Returns:
        true if active naming context.