Search in sources :

Example 16 with FieldConduit

use of org.apache.tapestry5.plastic.FieldConduit 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

InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)6 ComponentResources (org.apache.tapestry5.ComponentResources)5 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)3 InstanceContext (org.apache.tapestry5.plastic.InstanceContext)3 PlasticField (org.apache.tapestry5.plastic.PlasticField)2 Binding (org.apache.tapestry5.Binding)1 BindParameter (org.apache.tapestry5.annotations.BindParameter)1 Environmental (org.apache.tapestry5.annotations.Environmental)1 Id (org.apache.tapestry5.annotations.Id)1 InjectComponent (org.apache.tapestry5.annotations.InjectComponent)1 InjectContainer (org.apache.tapestry5.annotations.InjectContainer)1 PageActivationContext (org.apache.tapestry5.annotations.PageActivationContext)1 Parameter (org.apache.tapestry5.annotations.Parameter)1 Persist (org.apache.tapestry5.annotations.Persist)1 UnknownValueException (org.apache.tapestry5.commons.util.UnknownValueException)1 Predicate (org.apache.tapestry5.func.Predicate)1 LiteralBinding (org.apache.tapestry5.internal.bindings.LiteralBinding)1 MethodNode (org.apache.tapestry5.internal.plastic.asm.tree.MethodNode)1 ReadOnlyComponentFieldConduit (org.apache.tapestry5.internal.transform.ReadOnlyComponentFieldConduit)1 ComputedValue (org.apache.tapestry5.plastic.ComputedValue)1