Search in sources :

Example 11 with ComputedValue

use of org.apache.tapestry5.plastic.ComputedValue in project tapestry-5 by apache.

the class InjectContainerWorker method transformField.

private void transformField(PlasticField field) {
    InjectContainer annotation = field.getAnnotation(InjectContainer.class);
    field.claim(annotation);
    ComputedValue<FieldConduit<Object>> provider = createFieldValueConduitProvider(field);
    field.setComputedConduit(provider);
}
Also used : InjectContainer(org.apache.tapestry5.annotations.InjectContainer)

Example 12 with ComputedValue

use of org.apache.tapestry5.plastic.ComputedValue in project tapestry-5 by apache.

the class PersistWorker method makeFieldPersistent.

private void makeFieldPersistent(PlasticField field, MutableComponentModel model) {
    Persist annotation = field.getAnnotation(Persist.class);
    field.claim(annotation);
    final String logicalFieldName = model.setFieldPersistenceStrategy(field.getName(), annotation.value());
    final Object defaultValue = determineDefaultValueFromFieldType(field);
    ComputedValue<FieldConduit<Object>> computed = new ComputedValue<FieldConduit<Object>>() {

        public FieldConduit<Object> get(InstanceContext context) {
            InternalComponentResources resources = context.get(InternalComponentResources.class);
            return new PersistentFieldConduit(resources, logicalFieldName, defaultValue);
        }
    };
    field.setComputedConduit(computed);
}
Also used : InternalComponentResources(org.apache.tapestry5.internal.InternalComponentResources) Persist(org.apache.tapestry5.annotations.Persist)

Aggregations

ComponentResources (org.apache.tapestry5.ComponentResources)5 InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)5 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)2 ComputedValue (org.apache.tapestry5.plastic.ComputedValue)2 InstanceContext (org.apache.tapestry5.plastic.InstanceContext)2 Asset (org.apache.tapestry5.Asset)1 Binding (org.apache.tapestry5.Binding)1 BindParameter (org.apache.tapestry5.annotations.BindParameter)1 Cached (org.apache.tapestry5.annotations.Cached)1 Environmental (org.apache.tapestry5.annotations.Environmental)1 InjectComponent (org.apache.tapestry5.annotations.InjectComponent)1 InjectContainer (org.apache.tapestry5.annotations.InjectContainer)1 Parameter (org.apache.tapestry5.annotations.Parameter)1 Path (org.apache.tapestry5.annotations.Path)1 Persist (org.apache.tapestry5.annotations.Persist)1 UnknownValueException (org.apache.tapestry5.commons.util.UnknownValueException)1 LiteralBinding (org.apache.tapestry5.internal.bindings.LiteralBinding)1 PerThreadValue (org.apache.tapestry5.ioc.services.PerThreadValue)1 Component (org.apache.tapestry5.runtime.Component)1