Search in sources :

Example 11 with InternalComponentResources

use of org.apache.tapestry5.internal.InternalComponentResources in project tapestry-5 by apache.

the class InternalComponentResourcesImplTest method get_property_name.

@Test
public void get_property_name() {
    Component component = mockComponent();
    Instantiator ins = mockInstantiator(component);
    ComponentModel model = mockComponentModel();
    ComponentPageElement element = mockComponentPageElement();
    Page page = mockPage();
    Binding binding = mockBinding();
    train_getModel(ins, model);
    replay();
    InternalComponentResources resources = new InternalComponentResourcesImpl(page, element, null, null, null, null, ins, false);
    resources.bindParameter("bar", binding);
    assertNull(resources.getPropertyName("bar"));
    verify();
}
Also used : Binding(org.apache.tapestry5.Binding) InternalPropBinding(org.apache.tapestry5.internal.bindings.InternalPropBinding) InternalComponentResources(org.apache.tapestry5.internal.InternalComponentResources) ComponentModel(org.apache.tapestry5.model.ComponentModel) Instantiator(org.apache.tapestry5.internal.services.Instantiator) Component(org.apache.tapestry5.runtime.Component) Test(org.testng.annotations.Test)

Example 12 with InternalComponentResources

use of org.apache.tapestry5.internal.InternalComponentResources in project tapestry-5 by apache.

the class InternalComponentResourcesImplTest method render_informal_parameters_skips_formal_parameters.

@Test
public void render_informal_parameters_skips_formal_parameters() {
    ComponentPageElement element = mockComponentPageElement();
    Component component = mockComponent();
    Instantiator ins = mockInstantiator(component);
    MarkupWriter writer = mockMarkupWriter();
    ComponentModel model = mockComponentModel();
    ParameterModel pmodel = mockParameterModel();
    Binding binding = mockBinding();
    train_getModel(ins, model);
    train_getParameterModel(model, "fred", pmodel);
    replay();
    InternalComponentResources resources = new InternalComponentResourcesImpl(null, element, null, elementResources, null, null, ins, false);
    resources.bindParameter("fred", binding);
    resources.renderInformalParameters(writer);
    verify();
}
Also used : Binding(org.apache.tapestry5.Binding) InternalPropBinding(org.apache.tapestry5.internal.bindings.InternalPropBinding) ParameterModel(org.apache.tapestry5.model.ParameterModel) InternalComponentResources(org.apache.tapestry5.internal.InternalComponentResources) ComponentModel(org.apache.tapestry5.model.ComponentModel) Instantiator(org.apache.tapestry5.internal.services.Instantiator) Component(org.apache.tapestry5.runtime.Component) MarkupWriter(org.apache.tapestry5.MarkupWriter) Test(org.testng.annotations.Test)

Example 13 with InternalComponentResources

use of org.apache.tapestry5.internal.InternalComponentResources in project tapestry-5 by apache.

the class UnclaimedFieldWorker method createComputedFieldConduit.

private ComputedValue<FieldConduit<Object>> createComputedFieldConduit(PlasticField field) {
    final String fieldType = field.getTypeName();
    return new ComputedValue<FieldConduit<Object>>() {

        public FieldConduit<Object> get(InstanceContext context) {
            Object fieldDefaultValue = classCache.defaultValueForType(fieldType);
            InternalComponentResources resources = context.get(InternalComponentResources.class);
            return new UnclaimedFieldConduit(resources, perThreadManager.createValue(), fieldDefaultValue);
        }
    };
}
Also used : ComputedValue(org.apache.tapestry5.plastic.ComputedValue) InternalComponentResources(org.apache.tapestry5.internal.InternalComponentResources) InstanceContext(org.apache.tapestry5.plastic.InstanceContext)

Example 14 with InternalComponentResources

use of org.apache.tapestry5.internal.InternalComponentResources in project tapestry-5 by apache.

the class ComponentInstantiatorSourceImpl method implementComponentInterface.

private void implementComponentInterface(PlasticClass plasticClass) {
    plasticClass.introduceInterface(Component.class);
    final PlasticField resourcesField = plasticClass.introduceField(InternalComponentResources.class, "internalComponentResources").injectFromInstanceContext();
    plasticClass.introduceMethod(GET_COMPONENT_RESOURCES, new InstructionBuilderCallback() {

        public void doBuild(InstructionBuilder builder) {
            builder.loadThis().getField(resourcesField).returnResult();
        }
    });
}
Also used : InstructionBuilder(org.apache.tapestry5.plastic.InstructionBuilder) InternalComponentResources(org.apache.tapestry5.internal.InternalComponentResources) PlasticField(org.apache.tapestry5.plastic.PlasticField) InstructionBuilderCallback(org.apache.tapestry5.plastic.InstructionBuilderCallback)

Example 15 with InternalComponentResources

use of org.apache.tapestry5.internal.InternalComponentResources in project tapestry-5 by apache.

the class ComponentInstantiatorSourceImplTest method createComponent.

private Component createComponent(String classname) {
    InternalComponentResources resources = mockInternalComponentResources();
    replay();
    Instantiator inst = source.getInstantiator(classname);
    Component target = inst.newInstance(resources);
    verify();
    return target;
}
Also used : InternalComponentResources(org.apache.tapestry5.internal.InternalComponentResources) BasicComponent(org.apache.tapestry5.internal.t5internal.pages.BasicComponent) Component(org.apache.tapestry5.runtime.Component)

Aggregations

InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)22 Test (org.testng.annotations.Test)10 ComponentModel (org.apache.tapestry5.model.ComponentModel)9 Component (org.apache.tapestry5.runtime.Component)8 Instantiator (org.apache.tapestry5.internal.services.Instantiator)7 Binding (org.apache.tapestry5.Binding)5 TypeCoercer (org.apache.tapestry5.commons.services.TypeCoercer)4 InternalPropBinding (org.apache.tapestry5.internal.bindings.InternalPropBinding)4 MarkupWriter (org.apache.tapestry5.MarkupWriter)3 Request (org.apache.tapestry5.http.services.Request)3 ValueEncoderSource (org.apache.tapestry5.services.ValueEncoderSource)3 Messages (org.apache.tapestry5.commons.Messages)2 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)2 Platform (org.apache.tapestry5.corelib.components.SelectTest.Platform)2 LiteralBinding (org.apache.tapestry5.internal.bindings.LiteralBinding)2 ParameterModel (org.apache.tapestry5.model.ParameterModel)2 EnumSelectModel (org.apache.tapestry5.util.EnumSelectModel)2 ComponentResources (org.apache.tapestry5.ComponentResources)1 EventContext (org.apache.tapestry5.EventContext)1 Persist (org.apache.tapestry5.annotations.Persist)1