Package org.apache.tapestry5.annotations

Examples of org.apache.tapestry5.annotations.InjectComponent


    @SuppressWarnings("unchecked")
    @Test
    public void validator_with_constraint() throws Exception
    {
        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
        Validator validator = mockValidator();
        TypeCoercer coercer = mockTypeCoercer();
        FieldComponent field = newFieldComponent();
        Messages messages = mockMessages();
        MessageFormatter formatter = mockMessageFormatter();
        Object inputValue = new Object();
        ComponentResources resources = mockComponentResources();
        Messages containerMessages = mockMessages();
        Integer five = 5;
        FormSupport fs = mockFormSupport();

        Map<String, Validator> map = singletonMap("minLength", validator);

        train_getConstraintType(validator, Integer.class);

        train_getFormValidationId(fs, "myform");

        train_coerce(coercer, "5", Integer.class, five);

        train_getComponentResources(field, resources);
        train_getId(resources, "fred");
        train_getContainerMessages(resources, containerMessages);
        train_contains(containerMessages, "myform-fred-minLength-message", false);
        train_contains(containerMessages, "fred-minLength-message", false);

        train_getLocale(resources, Locale.FRENCH);

        train_getValidationMessages(messagesSource, Locale.FRENCH, messages);

        train_getMessageKey(validator, "key");
        train_getMessageFormatter(messages, "key", formatter);

        train_isRequired(validator, false);
        train_getValueType(validator, Object.class);
        validator.validate(field, five, formatter, inputValue);

        replay();

        FieldValidatorSource source = new FieldValidatorSourceImpl(messagesSource, coercer, fs, map, null);
View Full Code Here


    public void transform(PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model)
    {
        for (PlasticField field : plasticClass.getFieldsWithAnnotation(InjectComponent.class))
        {
            InjectComponent annotation = field.getAnnotation(InjectComponent.class);

            field.claim(annotation);

            final String type = field.getTypeName();
View Full Code Here

    public void transform(ClassTransformation transformation, MutableComponentModel model)
    {
        for (TransformField field : transformation.matchFieldsWithAnnotation(InjectComponent.class))
        {
            InjectComponent annotation = field.getAnnotation(InjectComponent.class);

            field.claim(annotation);

            final String type = field.getType();
View Full Code Here

    public void transform(PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model)
    {
        for (PlasticField field : plasticClass.getFieldsWithAnnotation(InjectComponent.class))
        {
            InjectComponent annotation = field.getAnnotation(InjectComponent.class);

            field.claim(annotation);

            final String type = field.getTypeName();
View Full Code Here

    public void transform(ClassTransformation transformation,
                          MutableComponentModel model)
    {
        for (String fieldName : transformation.findFieldsWithAnnotation(InjectComponent.class))
        {
            InjectComponent annotation = transformation.getFieldAnnotation(fieldName, InjectComponent.class);

            String type = transformation.getFieldType(fieldName);

            String resourcesFieldName = transformation.getResourcesFieldName();

            String componentId = annotation.value();
            if (InternalUtils.isBlank(componentId))
                componentId = InternalUtils.stripMemberPrefix(fieldName);

            transformation.makeReadOnly(fieldName);
View Full Code Here

    @Test
    public void default_id_from_field_name()
    {
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();
        InjectComponent annotation = newMock(InjectComponent.class);
        ComponentClassTransformWorker worker = new InjectComponentWorker();

        train_findFieldsWithAnnotation(ct, InjectComponent.class, "myfield");
        train_getFieldAnnotation(ct, "myfield", InjectComponent.class, annotation);
        train_getFieldType(ct, "myfield", CLASS_NAME);
        train_getResourcesFieldName(ct, "resources");
        expect(annotation.value()).andReturn("");
        ct.makeReadOnly("myfield");

        ct.extendMethod(same(TransformConstants.CONTAINING_PAGE_DID_LOAD_SIGNATURE),
                        contains(
                                "myfield = (" + CLASS_NAME + ") resources.getEmbeddedComponent(\"myfield\");"));
View Full Code Here

    @Test
    public void explicit_component_id_provided_as_annotation()
    {
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();
        InjectComponent annotation = newMock(InjectComponent.class);
        ComponentClassTransformWorker worker = new InjectComponentWorker();

        train_findFieldsWithAnnotation(ct, InjectComponent.class, "myfield");
        train_getFieldAnnotation(ct, "myfield", InjectComponent.class, annotation);
        train_getFieldType(ct, "myfield", CLASS_NAME);
        train_getResourcesFieldName(ct, "resources");
        expect(annotation.value()).andReturn("id_provided_as_annotation").atLeastOnce();
        ct.makeReadOnly("myfield");

        ct.extendMethod(same(TransformConstants.CONTAINING_PAGE_DID_LOAD_SIGNATURE),
                        contains(
                                "myfield = (" + CLASS_NAME + ") resources.getEmbeddedComponent(\"id_provided_as_annotation\");"));
View Full Code Here

    public void transform(PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model)
    {
        for (PlasticField field : plasticClass.getFieldsWithAnnotation(InjectComponent.class))
        {
            InjectComponent annotation = field.getAnnotation(InjectComponent.class);

            field.claim(annotation);

            final String type = field.getTypeName();
View Full Code Here

    public void transform(ClassTransformation transformation,
                          MutableComponentModel model)
    {
        for (String fieldName : transformation.findFieldsWithAnnotation(InjectComponent.class))
        {
            InjectComponent annotation = transformation.getFieldAnnotation(fieldName, InjectComponent.class);

            String type = transformation.getFieldType(fieldName);

            String resourcesFieldName = transformation.getResourcesFieldName();

            String componentId = annotation.value();
            if (InternalUtils.isBlank(componentId))
                componentId = InternalUtils.stripMemberName(fieldName);

            transformation.makeReadOnly(fieldName);
View Full Code Here

                {
                    setupRequestFromLink(link);
                    continue;
                }

                Document result = response.getRenderedDocument();

                if (result == null)
                    throw new RuntimeException(String.format("Render of page '%s' did not result in a Document.",
                            pageName));
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.annotations.InjectComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.