Search in sources :

Example 31 with ComponentModel

use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.

the class EmbeddedComponentAssemblerImpl method prescanMixins.

private String prescanMixins(boolean strictMixinParameters) {
    // Mixin id found to support informal parameters
    String supportsInformals = null;
    for (Map.Entry<String, Instantiator> entry : mixinIdToInstantiator.entrySet()) {
        String mixinId = entry.getKey();
        ComponentModel mixinModel = entry.getValue().getModel();
        updateParameterNameToQualified(mixinId, mixinModel, strictMixinParameters);
        if (supportsInformals == null && mixinModel.getSupportsInformalParameters())
            supportsInformals = mixinId;
    }
    // The component comes last and overwrites simple names from the others.
    updateParameterNameToQualified(null, componentModel, false);
    return supportsInformals;
}
Also used : ComponentModel(org.apache.tapestry5.model.ComponentModel) EmbeddedComponentModel(org.apache.tapestry5.model.EmbeddedComponentModel) Instantiator(org.apache.tapestry5.internal.services.Instantiator) Map(java.util.Map)

Example 32 with ComponentModel

use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.

the class PageLoaderImpl method copyInformalParameters.

private void copyInformalParameters(ComponentPageElement container, ComponentPageElement embedded) {
    // TODO: Much more, this is an area where we can make things a bit more efficient by tracking
    // what has and hasn't been bound in the EmbeddedComponentAssembler (and identifying what is
    // and isn't informal).
    ComponentModel model = embedded.getComponentResources().getComponentModel();
    Map<String, Binding> informals = container.getInformalParameterBindings();
    for (String name : informals.keySet()) {
        if (model.getParameterModel(name) != null)
            continue;
        Binding binding = informals.get(name);
        embedded.bindParameter(name, binding);
    }
}
Also used : LiteralBinding(org.apache.tapestry5.internal.bindings.LiteralBinding) Binding(org.apache.tapestry5.Binding) ComponentModel(org.apache.tapestry5.model.ComponentModel) EmbeddedComponentModel(org.apache.tapestry5.model.EmbeddedComponentModel)

Example 33 with ComponentModel

use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.

the class PageLoaderImpl method buildOverrideSearch.

private List<ComponentTemplate> buildOverrideSearch(ComponentAssembler assembler, ComponentTemplate template) {
    List<ComponentTemplate> result = CollectionFactory.newList();
    result.add(template);
    ComponentModel model = assembler.getModel();
    ComponentTemplate lastTemplate = template;
    while (lastTemplate.isExtension()) {
        ComponentModel parentModel = model.getParentModel();
        if (parentModel == null) {
            throw new RuntimeException(String.format("Component %s uses an extension template, but does not have a parent component.", model.getComponentClassName()));
        }
        ComponentTemplate parentTemplate = templateSource.getTemplate(parentModel, assembler.getSelector());
        result.add(parentTemplate);
        lastTemplate = parentTemplate;
        model = parentModel;
    }
    return result;
}
Also used : ComponentModel(org.apache.tapestry5.model.ComponentModel) EmbeddedComponentModel(org.apache.tapestry5.model.EmbeddedComponentModel)

Example 34 with ComponentModel

use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.

the class BlockInjectionProvider method provideInjection.

public boolean provideInjection(PlasticField field, ObjectLocator locator, MutableComponentModel componentModel) {
    if (!field.getTypeName().equals(BLOCK_TYPE_NAME)) {
        return false;
    }
    Id annotation = field.getAnnotation(Id.class);
    String blockId = getBlockId(field.getName(), annotation);
    FieldConduit<Object> conduit = createConduit(field, blockId);
    field.setConduit(conduit);
    // claim the field
    return true;
}
Also used : Id(org.apache.tapestry5.annotations.Id)

Example 35 with ComponentModel

use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.

the class ComponentTemplateSourceImpl method locateTemplateResource.

private Resource locateTemplateResource(ComponentModel initialModel, ComponentResourceSelector selector) {
    ComponentModel model = initialModel;
    while (model != null) {
        Resource localized = locator.locateTemplate(model, selector);
        if (localized != null)
            return localized;
        // Otherwise, this component doesn't have its own template ... lets work up to its
        // base class and check there.
        model = model.getParentModel();
    }
    return initialModel.getBaseResource().withExtension(TapestryConstants.TEMPLATE_EXTENSION);
}
Also used : ComponentModel(org.apache.tapestry5.model.ComponentModel) Resource(org.apache.tapestry5.commons.Resource)

Aggregations

ComponentModel (org.apache.tapestry5.model.ComponentModel)64 Test (org.testng.annotations.Test)48 ComponentResources (org.apache.tapestry5.ComponentResources)16 ComponentEventCallback (org.apache.tapestry5.ComponentEventCallback)15 Logger (org.slf4j.Logger)14 ComponentEvent (org.apache.tapestry5.runtime.ComponentEvent)12 Instantiator (org.apache.tapestry5.internal.services.Instantiator)11 MetaDataLocator (org.apache.tapestry5.services.MetaDataLocator)11 Resource (org.apache.tapestry5.commons.Resource)10 InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)10 Component (org.apache.tapestry5.runtime.Component)10 SymbolSource (org.apache.tapestry5.ioc.services.SymbolSource)9 EventContext (org.apache.tapestry5.EventContext)8 ClasspathResource (org.apache.tapestry5.ioc.internal.util.ClasspathResource)7 EmbeddedComponentModel (org.apache.tapestry5.model.EmbeddedComponentModel)7 ComponentTemplate (org.apache.tapestry5.internal.parser.ComponentTemplate)6 ComponentPageElementResources (org.apache.tapestry5.internal.structure.ComponentPageElementResources)6 ComponentResourceLocator (org.apache.tapestry5.services.pageload.ComponentResourceLocator)6 Messages (org.apache.tapestry5.commons.Messages)5 PersistentFieldStrategy (org.apache.tapestry5.services.PersistentFieldStrategy)5