T - type parameter for the template fragment implementation.@Exported public interface TemplateFragment<T extends TemplateFragment<T>> extends Fragment
TemplateFragment<?> fragment = FragmentFactory.newTemplateFragment()
.useTemplate("/HomePage")
.forAsset("MyAssetType", "1934567890")
If the asset is not specifically set into the fragment using TemplateFragment.forAsset(String, String),
then it looks up the page context for c and cid.
These variable names refer to the asset type and asset id respectively in the page context.
If the template name is not specifically set into the fragment using TemplateFragment.useTemplate(String),
then the default template is looked up for the asset set into the fragment.
There are multiple ways arguments may be set into the fragment:
TemplateFragment.addArgument(String, String)name1=value1&name2=value2...) using TemplateFragment.setArguments(String)TemplateFragment.useArguments(String, String...)Fragment.Scope, Fragment.Style| Modifier and Type | Method and Description |
|---|---|
T |
addArgument(String name,
String value)
Adds a name-value pair as an argument.
|
T |
forAsset(AssetId asset)
Sets the asset type and id for the asset to be rendered by the template that this fragment invokes.
|
T |
forAsset(String assetType,
Long assetId)
Sets the asset type and id for the asset to be rendered by the template that this fragment invokes.
|
T |
forAsset(String assetType,
String assetId)
Sets the asset type and id for the asset to be rendered by the template that this fragment invokes.
|
T |
inSite(String siteName)
Sets the name of the site containing the template to be invoked.
|
T |
invokeFrom(String id)
Sets the id of the element from which this fragment is invoked.
|
T |
resolveDevice(boolean resolve)
Set to
false to ignore the parameter 'd' and not try to re-direct to device group specific template. |
T |
setArguments(String arguments)
Sets a query string containing URL-encoded name-value pairs.
|
T |
useArguments(String variable,
String... more)
Sets Sites variables as arguments.
|
T |
useDevice(String deviceSuffix)
Sets a string that is the common suffix of all the templates written for a device group.
|
T |
useStyle(Fragment.Style style)
Sets whether the template invoked by this fragment should be invoked as an element or as a pagelet
If invoked as a pagelet, it may be embedded in the parent for Satellite Server or should it be an independent pagelet.
|
T |
useTemplate(String templateName)
Sets the template name used by this fragment.
|
T forAsset(String assetType, String assetId)
assetType - the asset typeassetId - the asset idT forAsset(String assetType, Long assetId)
assetType - the asset typeassetId - the asset idT forAsset(AssetId asset)
asset - the id of the asset for which this fragment should work.T useTemplate(String templateName)
/.templateName - the name of the template used by this fragment.T useDevice(String deviceSuffix)
deviceSuffix - the device group suffixT resolveDevice(boolean resolve)
false to ignore the parameter 'd' and not try to re-direct to device group specific template.
Default value: true.resolve - the flag to dictate if the 'd' parameter will be ignored in resolving the template name.T useStyle(Fragment.Style style)
Fragment.Style.PAGELET.style - the invocation strategy.StyleT useArguments(String variable, String... more)
c and cid are set, then it is not necessary to set asset type and asset id using the TemplateFragment.forAsset(String, String) method.
These will be looked up from the page context.variable - a Site variable to add as argumentmore - optional more Site variables to add as argumentsT setArguments(String arguments)
name1=value1&name2=value2...
Note: This method does not validate the above form of the string.
arguments - the URL encoded argument string to setT inSite(String siteName)
siteName - the name of the siteT invokeFrom(String id)
tid variable provides this value.
For a CSElement, the eid variable provides this value.id - the id of the element from which this fragment is invoked.