public class ComponentsNotInTemplateDemo { @Component private BeanEditForm form; }
private void transformField(PlasticClass transformation, MutableComponentModel model, PlasticField field) { Component annotation = field.getAnnotation(Component.class); field.claim(annotation); String annotationId = annotation.id(); String fieldName = field.getName(); String id = InternalUtils.isNonBlank(annotationId) ? annotationId : InternalUtils.stripMemberName(fieldName); String type = field.getTypeName(); Location location = new StringLocation(String.format("%s.%s", transformation.getClassName(), fieldName), 0); MutableEmbeddedComponentModel embedded = model.addEmbeddedComponent(id, annotation.type(), type, annotation .inheritInformalParameters(), location); addParameters(embedded, annotation.parameters()); updateModelWithPublishedParameters(embedded, annotation); convertAccessToField(field, id); addMixinClasses(field, embedded); addMixinTypes(field, embedded); }
private void updateModelWithPublishedParameters(MutableEmbeddedComponentModel embedded, Component annotation) { String names = annotation.publishParameters(); if (InternalUtils.isNonBlank(names)) { List<String> published = CollectionFactory.newList(TapestryInternalUtils.splitAtCommas(names)); embedded.setPublishedParameters(published); } }
public class EmbeddedComponentTypeConflict { @Component(type = "textfield") private Field input; }
public class BadPublishUnknown { @Component(publishParameters = "xyzzyx") private Publish1 publish1; }
public class Publish1 { @Component(publishParameters = "value", parameters = "number=6") private Publish2 publish2; }
public class ParameterConflict { @SuppressWarnings("unused") @Component(parameters = "value=literal:ClassValue") private Echo echo; }
public class Publish2 { @Component(publishParameters = "value,number") private Publish3 publish3; }
public class CleanCacheDemo { @Component private Zone aZone; Object onActionFromUpdateZone() { return aZone; } @Cached public long getTimeNanos() { return System.nanoTime(); } }
/** * @since 5.3 */ public class InvalidFormalParameterDemo { // This has to be done using @Component, because non-matching attributes // in the template are quietly dropped. By placing it here, in the @Component annotation, // there's no ambiguity ... the developer expects there to be a parameter with the given name. @Component(parameters = { "start=5", "end=100", "value=var:index", "step=5" // not a formal parameter }) private Count counter; }
public class Countdown { @SuppressWarnings("unused") @Component(parameters = { "start=10", "end=1", "value=countValue" }) private Count count; private int countValue; public int getCountValue() { return countValue; } public void setCountValue(int countValue) { this.countValue = countValue; } }
/** * Page containing <i>kaptcha</i> edit blocks contributed into the * {@link org.apache.tapestry5.services.BeanBlockSource} service configuration. * * @see org.apache.tapestry5.services.BeanBlockContribution * @see org.apache.tapestry5.corelib.components.BeanEditForm * @since 5.3 */ public class KaptchaEditBlocks { @Environmental @Property(write = false) private PropertyEditContext context; @Component private KaptchaImage kaptchaImage; @Component(parameters = { "label=prop:context.label", "clientId=prop:context.propertyId", "image=kaptchaImage"}) private KaptchaField kaptchaField; }
@Component( parameters = {"value=context.propertyValue", "label=prop:context.label", "translate=prop:textFieldTranslator", "validate=prop:textFieldValidator", @Component( parameters = {"value=context.propertyValue", "label=prop:context.label", "translate=prop:numberFieldTranslator", "validate=prop:numberFieldValidator", @Component( parameters = {"value=context.propertyValue", "label=prop:context.label", "encoder=valueEncoderForProperty", "model=selectModelForProperty", "validate=prop:selectValidator", @Component( parameters = {"value=context.propertyValue", "label=prop:context.label", "clientId=prop:context.propertyId", "ensureClientIdUnique=true"}) @Component( parameters = {"value=context.propertyValue", "label=prop:context.label", "clientId=prop:context.propertyid", "validate=prop:dateFieldValidator", "ensureClientIdUnique=true"}) @Component( parameters = {"value=context.propertyValue", "label=prop:context.label", "clientId=prop:context.propertyid", "validate=prop:calendarFieldValidator", "ensureClientIdUnique=true"}) private DateField calendarField; @Component( parameters = {"value=context.propertyValue", "label=prop:context.label", "translate=prop:passwordFieldTranslator", "validate=prop:passwordFieldValidator",
@SupportsInformalParameters public class OuterAny { // Also, leave a few parameters here and there in the old naming style, with a // leading underscore. @Component(inheritInformalParameters = true) private Any innerAny; }
public class BeanEditorBeanEditContext { @Component private Form form; @Component(parameters = { "object=registrationData" }) private BeanEditor editor; @SessionState private RegistrationData data; public RegistrationData getRegistrationData() { return data; } Object onSuccess() { return ViewRegistration.class; } void onActionFromClear() { data = null; form.clearErrors(); } }
public class BeanEditorOverride { @Component private Form form; @Component(parameters = { "object=registrationData" }) private BeanEditor editor; @SessionState private RegistrationData data; public RegistrationData getRegistrationData() { return data; } Object onSuccess() { return ViewRegistration.class; } void onActionFromClear() { data = null; form.clearErrors(); } }
public class BaseLayoutPage { @Inject private ComponentResources resources; @Component(parameters = "to=titleRenderer") private Delegate titleDelegate; public Renderable getTitleRenderer() { return new Renderable() { public void render(MarkupWriter writer) { writer.write(TapestryInternalUtils.toUserPresentable(resources.getPageName())); } }; } }
private DataTableModel dataTableModel; @Component(parameters = { "index=inherit:columnIndex", "lean=inherit:lean", "overrides=overrides", "model=dataModel", "mode=true" }) private GridColumns headers; @Component(parameters = { "index=inherit:columnIndex", "lean=inherit:lean", "overrides=overrides", "model=dataModel", "mode=false" }) private GridColumns footers;