private void addMixin(String className, String... order) { Instantiator mixinInstantiator = instantiatorSource.getInstantiator(className); String mixinId = InternalUtils.lastTerm(className); if (mixinIdToInstantiator.containsKey(mixinId)) throw new TapestryException(String.format("Mixins applied to a component must be unique. Mixin '%s' has already been applied.", mixinId), location, null); mixinIdToInstantiator.put(mixinId, mixinInstantiator); mixinsIdToOrderConstraints.put(mixinId, order); }
public void validateEmbeddedIds(Map<String, Location> componentIds, Resource templateResource) { Map<String, Boolean> embeddedIds = CollectionFactory.newCaseInsensitiveMap(); for (String id : getModel().getEmbeddedComponentIds()) embeddedIds.put(id, true); for (String id : componentIds.keySet()) { allocator.allocateId(id); embeddedIds.remove(id); } if (!embeddedIds.isEmpty()) { String className = getModel().getComponentClassName(); throw new RuntimeException(String.format("Embedded component(s) %s are defined within component class %s (or a super-class of %s), but are not present in the component template (%s).", InternalUtils.joinSorted(embeddedIds.keySet()), className, InternalUtils.lastTerm(className), templateResource)); } }
public Resource locateTemplate(ComponentModel model, Locale locale) { if (!model.isPage()) { return null; } String className = model.getComponentClassName(); String logicalName = resolver.resolvePageClassNameToPageName(className); String simpleClassName = InternalUtils.lastTerm(className); int slashx = logicalName.lastIndexOf('/'); // Using the simple class name always accounts for the case where a "page" suffix was stripped off to form // the logical page name (and several other cases where the name was simplified in some way). String baseName = slashx < 0 ? simpleClassName : logicalName.substring(0, slashx + 1) + simpleClassName; String path = prefix + baseName + "." + TapestryConstants.TEMPLATE_EXTENSION; return contextRoot.forFile(path).forLocale(locale); }
private void addRootComponentMixins(PageAssembly assembly, ComponentPageElement element) { for (String className : instantiator.getModel().getMixinClassNames()) { assembly.weight++; Instantiator mixinInstantiator = instantiatorSource.getInstantiator(className); ComponentModel model = instantiator.getModel(); element.addMixin(InternalUtils.lastTerm(className), mixinInstantiator, model.getOrderForMixin(className)); } }
componentPsuedoMixinId = InternalUtils.lastTerm(componentClassName);