It is possible to use placeholder tokens in External Link content and external links within a Rich Text editor in Studio. For example: an external link that contains a hostname for the Perfect Chef shop which is linked from the corporate site can be written as follows:
http://{perfectchef.host}/blueprint/servlet/perfectchef
The tokens are enclosed with curly braces. The TokenReplacingLinkTransformer
class acts as a
LinkTransformer
class to replace these tokens in URLs.
A list of token resolvers can be registered and each resolver is called per token.
The first token Resolver that returns a replacement (value != null)
wins. After that no other
token resolver will be asked anymore for the current token.
The following token resolvers are preconfigured in the given order:
SettingsTokenResolver
This token resolver is used to resolve tokens with values coming from setting documents.
For example: the following URL
http://localhost?connectionId={livecontext.connectionId}
will be transformed to the URL
http://localhost?connectionId=wcs1
The
SettingsTokenResolver
resolves the token of the URL to the value "wcs1" because the propertylivecontext.connectionId
is defined aswcs1
in a Setting document, which is accessible via the settings service starting from the current External Link content.StoreContextTokenResolver
This token resolver is used to resolve tokens with values coming from the LiveContext Store Context.
For example: the following URL
http://localhost/wcs/resources/store/{storeId}
in the PerfectChef page will be transformed to the URL
http://localhost/wcs/resources/store/10302
The
StoreContextTokenResolver
is only available if the livecontext extension is active.SpringPropertyTokenResolver
This token resolver is used to resolve tokens with values coming from Spring properties.
The placeholder and their values can be defined by using the prefix "
urlToken.
" in a properties file as follows:urlToken.perfectchef.host=${blueprint.host.helios} urlToken.aurora.host=${livecontext.apache.wcs.host} urlToken.aurorab2b.host=${livecontext.apache.wcs.host}
Within the URL attribute of an External Link content the token will be defined without the "
urlToken.
" prefix. It will be replaced with the defined value. For example: the following URL//{perfectchef.host}/blueprint/servlet/perfectchef
will be transformed to the PerfectChef homepage.