/** * @BindParameter should only be used inside a mixin; should get an intelligible exception when trying to use this component. */ public class BindParameterComponent { @BindParameter private Object value; }
private void convertFieldIntoContainerBoundParameter(PlasticField field) { BindParameter annotation = field.getAnnotation(BindParameter.class); field.claim(annotation); final String[] possibleNames = annotation.value(); final String fieldTypeName = field.getTypeName(); final String fieldName = field.getName(); ComputedValue<FieldConduit<Object>> computedConduit = new ComputedValue<FieldConduit<Object>>() { public FieldConduit<Object> get(InstanceContext context) { ComponentResources resources = context.get(ComponentResources.class); try { return createConduit(resources, fieldTypeName, fieldName, possibleNames); } catch (Exception ex) { throw new TapestryException(String.format( "Failure binding parameter field '%s' of mixin %s (type %s): %s", fieldName, resources .getCompleteId(), resources.getComponentModel().getComponentClassName(), ExceptionUtils.toMessage(ex)), ex); } } }; field.setComputedConduit(computedConduit); }
/** * Mixin demonstrating the use of BindParameter, using explicit naming of the parent parameter. */ public class EchoValue3 { @BindParameter(value = {"object","value"}) private Object boundParameter; @InjectContainer private ClientElement element; private Object temp; void beginRender(MarkupWriter writer) { writer.element("div","id",element.getClientId() + "_before3"); writer.writeRaw("echo3-" + boundParameter + "-before"); writer.end(); temp = boundParameter; boundParameter = "world"; } void afterRender(MarkupWriter writer) { boundParameter = temp; writer.element("div","id",element.getClientId() + "_after3"); writer.writeRaw("echo3-" + boundParameter + "-after"); writer.end(); } }
@BindParameter(value = "value") private Object boundParameter;
@BindParameter private Object value; @BindParameter private boolean disabled; @BindParameter private FieldTranslator translate;
private String id; @BindParameter private String value;
private ThreadLocale locale; @BindParameter private Object format;