本文整理汇总了Java中info.magnolia.rendering.template.TemplateDefinition类的典型用法代码示例。如果您正苦于以下问题:Java TemplateDefinition类的具体用法?Java TemplateDefinition怎么用?Java TemplateDefinition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TemplateDefinition类属于info.magnolia.rendering.template包,在下文中一共展示了TemplateDefinition类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRenderingModel
import info.magnolia.rendering.template.TemplateDefinition; //导入依赖的package包/类
public RenderingModel getRenderingModel(Node node) throws ServletException {
TemplateDefinition templateDefinition = getTemplateDefinition(node);
RenderingModelBasedRenderer renderingModelBasedRenderer = getRenderingModelBasedRenderer(templateDefinition);
RenderingModel renderingModel;
try {
renderingModel = renderingModelBasedRenderer.newModel(node, templateDefinition, null);
}
catch (RenderException e) {
throw new ServletException(e.getMessage(), e);
}
return renderingModel;
}
示例2: getTemplateDefinition
import info.magnolia.rendering.template.TemplateDefinition; //导入依赖的package包/类
/**
* Returns the TemplateDefinition for the supplied content. Never returns null.
*/
private TemplateDefinition getTemplateDefinition(Node content) throws ServletException {
TemplateDefinition templateDefinition;
try {
templateDefinition = templateDefinitionAssignment.getAssignedTemplateDefinition(content);
} catch (RegistrationException e) {
throw new ServletException("No template set or template not available for node with identifier: " + NodeUtil.getNodeIdentifierIfPossible(content));
}
if (templateDefinition == null) {
throw new ServletException("Template not available for node with identifier: " + NodeUtil.getNodeIdentifierIfPossible(content));
}
return templateDefinition;
}
示例3: setComponents
import info.magnolia.rendering.template.TemplateDefinition; //导入依赖的package包/类
public void setComponents(Map<String, ComponentAvailability> components) {
try {
String[] areaNames = StringUtils.split(getTargetAreaName(),":");
final DefinitionProvider<TemplateDefinition> templateDefinitionProvider = templateDefinitionRegistry.getProvider("magnolia-templating-foundation:pages/genericPage");
AreaDefinition areaDefinition = templateDefinitionProvider.get().getAreas().get(areaNames[0]);
for (int i = 1; i < areaNames.length; i++) {
areaDefinition = areaDefinition.getAreas().get(areaNames[i]);
}
areaDefinition.getAvailableComponents().putAll(components);
} catch (IllegalArgumentException | Registry.NoSuchDefinitionException | Registry.InvalidDefinitionException e) {
log.debug("Error", e);
}
this.components = components;
}
示例4: getAreaHierarchy
import info.magnolia.rendering.template.TemplateDefinition; //导入依赖的package包/类
private Map<String, TemplateDefinition> getAreaHierarchy(Node parentArea) throws RepositoryException, RegistrationException {
Map<String, TemplateDefinition> areaHierarchy = new LinkedHashMap<String, TemplateDefinition>();
List<String> areaNamesHierarchy = new ArrayList<String> ();
Node parentParentArea = parentArea;
while (parentParentArea != null) {
String areaName = parentParentArea.getName();
areaNamesHierarchy.add(areaName);
parentParentArea = NodeUtil.getNearestAncestorOfType(parentParentArea, NodeTypes.Area.NAME);
}
Node parentPage = NodeUtil.getNearestAncestorOfType(parentArea, NodeTypes.Page.NAME);
templateId = parentPage.getProperty(NodeTypes.Renderable.TEMPLATE).getString();
TemplateDefinition templateDef = registry.getTemplateDefinition(templateId);
templateDef = mergeDefinition(templateDef);
ListIterator<String> iter = areaNamesHierarchy.listIterator(areaNamesHierarchy.size());
Node componentOrArea = parentPage;
while (iter.hasPrevious()) {
String name = iter.previous();
// subnode component is typically indication of having area type single
if (!componentOrArea.hasNode(name) && (componentOrArea.hasNode("component") || (templateDef instanceof AreaDefinition && "single".equals(((AreaDefinition) templateDef).getType())))) {
componentOrArea = componentOrArea.getNode("component/" + name);
// so we know component is single, and we neeed to look if it has any sub areas
String id = componentOrArea.getParent().getProperty(NodeTypes.Renderable.TEMPLATE).getString();
TemplateDefinition componentDef = registry.getTemplateDefinition(id);
if (componentDef != null) {
templateDef = componentDef;
}
} else {
componentOrArea = componentOrArea.getNode(name);
}
// do we really need to merge here already?
AreaDefinition area = templateDef.getAreas().get(name);
if (area != null) {
AreaDefinition areaDef = (AreaDefinition) mergeDefinition(area);
templateDef = areaDef;
} else {
AreaDefinition maybeHit = templateDef.getAreas().get(name);
if (maybeHit != null) {
areaHierarchy.put(name, maybeHit);
templateDef = maybeHit;
} else {
// get subareas of the area? what the hack was i thinking when writing this? How does it work anyway?
for (Entry<String, AreaDefinition> tempAreaEntry : templateDef.getAreas().entrySet()) {
AreaDefinition tempArea = tempAreaEntry.getValue();
maybeHit = tempArea.getAreas().get(name);
if (maybeHit != null) {
areaHierarchy.put(tempAreaEntry.getKey(), tempAreaEntry.getValue());
templateDef = maybeHit;
}
}
}
// noComponent area ... how do i read those?
}
areaHierarchy.put(name, templateDef);
}
return areaHierarchy;
}