Class ExternalImage

    • Constructor Detail

      • ExternalImage

        public ExternalImage​(String id)
        Creates an external image
        Parameters:
        id - the component id
      • ExternalImage

        public ExternalImage​(String id,
                             Serializable src)
        Creates an external image
        Parameters:
        id - the component id
        src - the source URL
      • ExternalImage

        public ExternalImage​(String id,
                             Serializable src,
                             List<Serializable> srcSet)
        Creates an external image
        Parameters:
        id - the component id
        src - the source URL
        srcSet - a list of URLs placed in the srcSet attribute
      • ExternalImage

        public ExternalImage​(String id,
                             IModel<Serializable> srcModel)
        Creates an external image
        Parameters:
        id - the component id
        srcModel - the model source URL
      • ExternalImage

        public ExternalImage​(String id,
                             IModel<Serializable> srcModel,
                             IModel<List<Serializable>> srcSetModel)
        Creates an external image
        Parameters:
        id - the component id
        srcModel - the model source URL
        srcSetModel - a model list of URLs placed in the srcSet attribute
    • Method Detail

      • onComponentTag

        protected void onComponentTag​(ComponentTag tag)
        Description copied from class: Component
        Processes the component tag. Overrides of this method most likely should call the super implementation.
        Overrides:
        onComponentTag in class Component
        Parameters:
        tag - Tag to modify
      • buildSrcAttribute

        protected void buildSrcAttribute​(ComponentTag tag,
                                         IModel<?> srcModel)
        Builds the src attribute
        Parameters:
        tag - the component tag
        srcModel - the model containing the src URL
      • buildSrcSetAttribute

        protected void buildSrcSetAttribute​(ComponentTag tag,
                                            IModel<List<Serializable>> srcSetModel)
        Builds the srcset attribute if multiple models are found as varargs
        Parameters:
        tag - the component tag
        srcSetModel - the models containing the src set URLs
      • buildSizesAttribute

        protected void buildSizesAttribute​(ComponentTag tag)
        builds the sizes attribute of the img tag
        Parameters:
        tag - the component tag
      • setXValues

        public void setXValues​(String... values)
        Parameters:
        values - the x values to be used in the srcset
      • removeSizes

        public void removeSizes()
        Removes all sizes values. The corresponding tag will not be rendered anymore.
      • setSizes

        public void setSizes​(String... sizes)
        Parameters:
        sizes - the sizes to be used in the size
      • removeXValues

        public void removeXValues()
        Removes all x values from the image src set.
      • getCrossOrigin

        public CrossOrigin getCrossOrigin()
        Gets the cross origin settings
        Returns:
        the cross origins settings
      • setCrossOrigin

        public void setCrossOrigin​(CrossOrigin crossOrigin)
        Sets the cross origin settings
        Parameters:
        crossOrigin - the cross origins settings to set
      • getSrcSetModel

        public IModel<List<Serializable>> getSrcSetModel()
        Gets a list of models containing the src set values
        Returns:
        a list of models containing the src set values
      • setSrcSetModel

        public void setSrcSetModel​(IModel<List<Serializable>> srcSetModel)
        Sets the source set model
        Parameters:
        srcSetModel - the model of a list of src set entries
      • onDetach

        protected void onDetach()
        Detaches the srcSetModels
        Overrides:
        onDetach in class Component