public interface ComponentLink
ComponentLink interface provides functionality to validate
and resolve links to ComponentPresentations on Pages. After a link has been resolved,
the PageLink class is used to link to the targeted page.
The goal of the ComponentLink is to create a link to another (published) instance of a component, having a different template ID than the one supplied as a parameter.
From all candidates, the one with the highest priority is selected. If more than one is left, the first one on the same page as the page parameter is selected: if there is no one on the same with the same page, then the first one having the same path as supplied page is selected.
If still no link is found, the link which is nearest the current page is returned. Otherwise, the latest published Component Presentation with the highest priority is selected. If no other published instance of the supplied component is found, then the link can't resolve.
| Modifier and Type | Method and Description |
|---|---|
Link |
getLink(int targetComponentId)
Gets a URL to the first page that is found containing the requested
targetComponentId.
|
Link |
getLink(int sourcePageId,
int targetComponentId,
int excludeComponentTemplateId,
String linkTagAttributes,
String linkText,
boolean showTextOnFail,
boolean addAnchor)
Tries to create a link to a suitable component presentation on a page
and returns this as a
Link object. |
Link |
getLink(String targetComponentURI)
Gets a URL to the first page that is found containing the requested
targetComponentId.
|
Link |
getLink(String sourcePageURI,
String targetComponentURI,
String excludeTemplateURI,
String linkTagAttributes,
String linkText,
boolean showTextOnFail,
boolean showAnchor)
Tries to create a link to a suitable component presentation on a page
and returnes this as a
Link object. |
String |
getLinkAsString(int sourcePageId,
int targetComponentId,
int excludeTemplateId,
String linkTagAttributes,
String linkText,
boolean showTextOnFail)
Calls the public method getLinkAsString with an additional
parameter for the anchor with the value false.
|
String |
getLinkAsString(int sourcePageId,
int targetComponentId,
int excludeTemplateId,
String linkTagAttributes,
String linkText,
boolean showTextOnFail,
boolean showAnchor)
Creates a new Link instance and returnes this as a
String. |
String |
getLinkAsString(String pageURI,
String componentURI,
String templateURI,
String linkTagAttributes,
String linkText,
boolean showTextOnFail)
Tries to create a link to a suitable component presentation on a page
and returns this as a
Link object. |
String |
getLinkAsString(String sourcePageURI,
String targetComponentURI,
String excludeTemplateURI,
String linkTagAttributes,
String linkText,
boolean showTextOnFail,
boolean showAnchor)
Creates a new Link instance and returns this as a
String. |
String getLinkAsString(int sourcePageId, int targetComponentId, int excludeTemplateId, String linkTagAttributes, String linkText, boolean showTextOnFail)
sourcePageId - The ID of the page where this link is inserted on.targetComponentId - The ID of the component to link to.excludeTemplateId - The ID of the component template used in this
component presentation. Component presentations having the component template
specified here are not used as a target for this link. This is why you
usually specify the template id of the source component presentation here.linkTagAttributes - Attributes to include in the link.linkText - The text that builds up the link.showTextOnFail - Indicates if the linkText needs to be returned .
in case no link can be build: an empty string is returned if false.String the link (<a href="..">... </a>),
linktext or empty string.String getLinkAsString(int sourcePageId, int targetComponentId, int excludeTemplateId, String linkTagAttributes, String linkText, boolean showTextOnFail, boolean showAnchor)
String.sourcePageId - The ID of the page where this link is inserted on.targetComponentId - The ID of the component to link to.excludeTemplateId - The ID of the component template used in this
component presentation. Component presentations having the component template
specified here are not used as a target for this link. This is why you
usually specify the template id of the source component presentation here.linkTagAttributes - Attributes to include in the link.linkText - The text that builds up the link.showTextOnFail - Indicates if the linkText needs to be returned .
in case no link can be build: an empty string is returned if false.showAnchor - Indicates if an showAnchor should be used to point to the position of
the targetted component presentation on a page.String the link (<a href="..">... </a>),
linktext or empty string.String getLinkAsString(String sourcePageURI, String targetComponentURI, String excludeTemplateURI, String linkTagAttributes, String linkText, boolean showTextOnFail, boolean showAnchor)
String.sourcePageURI - The TCM:URI of the page where this link is inserted on.targetComponentURI - The TCM:URI of the component to link to.excludeTemplateURI - The TCM:URI of the component template used in this
component presentation. Component presentations having the component template
specified here are not used as a target for this link. This is why you
usually specify the template TCM:URI of the source component presentation here.linkTagAttributes - Attributes to include in the link.linkText - The text that builds up the link.showTextOnFail - Indicates if the linkText needs to be returned .
in case no link can be build: an empty string is returned if false.showAnchor - Indicates if an showAnchor should be used to point to the position of
the targetted component presentation on a page.String the link (<a href="..">... </a>),
linktext or empty string.String getLinkAsString(String pageURI, String componentURI, String templateURI, String linkTagAttributes, String linkText, boolean showTextOnFail)
Link object.pageURI - The TCM:URI of the page where this link is inserted on.componentURI - The TCM:URI of the component to link to.templateURI - The TCM:URI of the component template used in this
component presentation.linkTagAttributes - Attributes to include in the link.linkText - The text that builds up the link.showTextOnFail - Indicates if the linkText needs to be returned .
in case no link can be build: an empty string is returned if false.String the link (<a href="..">... </a>),
linktext or empty string.Link getLink(String sourcePageURI, String targetComponentURI, String excludeTemplateURI, String linkTagAttributes, String linkText, boolean showTextOnFail, boolean showAnchor)
Link object.sourcePageURI - The TCM:URI of the page where this link is inserted on.targetComponentURI - The TCM:URI of the component to link to.excludeTemplateURI - The TCM:URI of the component template used in this
component presentation. Component presentations having the component template
specified here are not used as a target for this link. This is why you
usually specify the template id of the source component presentation here.linkTagAttributes - Attributes to include in the link.linkText - The text that builds up the link.showTextOnFail - Indicates if the linkText needs to be returned .
in case no link can be build: an empty string is returned if false.showAnchor - Indicates if an showAnchor should be used to point to the position of
the targetted component presentation on a page.Link object that resolves if the link was resolved.Link getLink(int targetComponentId)
targetComponentId - Component ID for the component that needs to found.Link object that resolves if the link was resolved.Link getLink(String targetComponentURI)
targetComponentURI - Component URI for the component that needs to found.Link object that resolves if the link was resolved.Link getLink(int sourcePageId, int targetComponentId, int excludeComponentTemplateId, String linkTagAttributes, String linkText, boolean showTextOnFail, boolean addAnchor)
Link object. Component Presentations using the Component
with the ID passed as the componentID parameter and the Component Template with the ID
passed in the componentTemplateID parameter will NOT be linked to.>a href
element.sourcePageId - The ID of the page you want to create a link from.targetComponentId - The ID of the component you want to link to.excludeComponentTemplateId - The ID of the component template used in this
Component Presentation. Component presentations having the component template
specified here are not used as a target for this link. This is why you
usually specify the template id of the source component presentation here.linkTagAttributes - Attributes to add to the >a href element.linkText - The text that will be displayed in the link
(the text between the >a tags).showTextOnFail - Sets whether or not the link text will be displayed
if no suitable link can be resolved.addAnchor - Sets whether or not the addAnchor to the component will be added to the link.Link object that resolves if the link was resolved.Copyright © 2016 SDL Group. All rights reserved.