Interface PersonalizationAttributes


  • public interface PersonalizationAttributes
    The PersonalizationAttributes models all required data to personalize an element. A personalization is defined by This interface is implemented by PersonalizationAttributesImpl which also has utility methods to read the attributes from a Node. For example a <p> node might look like
     <p data-wm-personalization-group="group1" 
              data-wm-personalization-variant="variant1"
              data-wm-personalization-variant-name="My variant"
              data-wm-personalization="12 42"
              data-wm-personalization-group="and" >...</p>
     

    A personalization has a group iff it has a variant. The default operator is PersonalizationModel.Operator.AND. An element with an empty list of personalization items should be considered true and be rendered.

    The personalization items are referenced by id, Wrapper.getId(). The method loadPersonalizationItems(Session) loads the PersonalizationItems by their ids from the Session. getPersonalizationItems() throws an IllegalStateException if the personalization items have not been loaded or set.

    • Field Detail

      • WM_PERSONALIZATION_GROUP_ATTR

        static final String WM_PERSONALIZATION_GROUP_ATTR
        HTML attribute containing the group id
        See Also:
        Constant Field Values
      • WM_PERSONALIZATION_VARIANT_ATTR

        static final String WM_PERSONALIZATION_VARIANT_ATTR
        HTML attribute containing the variant id
        See Also:
        Constant Field Values
      • WM_PERSONALIZATION_VARIANT_NAME_ATTR

        static final String WM_PERSONALIZATION_VARIANT_NAME_ATTR
        HTML attribute containing the variant name
        See Also:
        Constant Field Values
      • WM_PERSONALIZATION_ATTR

        static final String WM_PERSONALIZATION_ATTR
        HTML attribute containing the list of personalization ids
        See Also:
        Constant Field Values
      • WM_PERSONALIZATION_OPERATOR_ATTR

        static final String WM_PERSONALIZATION_OPERATOR_ATTR
        HTML attribute containing the personalization operator
        See Also:
        Constant Field Values
    • Method Detail

      • toHTMLGroupVariantAttributes

        String toHTMLGroupVariantAttributes()
        Returns the group and variant attributes (key and value). This can be inserted in a HTML tag. For example:

        data-wm-personalization-group="group1" data-wm-personalization-variant="var1" data-wm-personalization-variant-name="My variant"

        Returns:
        HTML group and variant attributes sepeared by space
        See Also:
        toHTMLAttributes()
      • toHTMLAttributes

        String toHTMLAttributes()
        Returns all attributes (key and value). This can be inserted in a HTML tag. For example:

         data-wm-personalization-group="group1" 
                  data-wm-personalization-variant="variant1"
                  data-wm-personalization-variant-name="My variant"
                  data-wm-personalization="12 42"
                  data-wm-personalization-group="and"
                  
        Returns:
      • getOperatorAttribute

        String getOperatorAttribute()
        Returns the operator as HTML attribute value
        Returns:
        the operator as HTML attribute value
      • writeGroupVariantTo

        void writeGroupVariantTo​(org.jsoup.nodes.Node node)
        Sets the group and variant attributes in the given node
        Parameters:
        node - Node to set attributes
        See Also:
        writeAttributesTo(Node)
      • writeAttributesTo

        void writeAttributesTo​(org.jsoup.nodes.Node node)
        Sets all personalization attributes in the given node
        Parameters:
        node - Node to set attributes
        See Also:
        writeGroupVariantTo(Node)
      • hasGroupAndVariant

        boolean hasGroupAndVariant()
        Returns true if group and variant have been definied.
        Returns:
        True iff group ids and variant ids are not empty
      • hasPersonalization

        boolean hasPersonalization()
        Returns true if personalization items have been definied.
        Returns:
        True iff personalization items is not empty
      • getGroupId

        String getGroupId()
        Returns the group id.
        Returns:
        the group id or empty string
      • getVariantId

        String getVariantId()
        Returns the variant id.
        Returns:
        the variant id or empty string
      • getVariantName

        String getVariantName()
        Returns the variant name
        Returns:
        the variant name or empty string
      • getPersonalizationIds

        List<Integer> getPersonalizationIds()
        Returns the ids of all personalization items.
        Returns:
        List of all personalization item ids.