Package org.apache.tapestry5.annotations

Examples of org.apache.tapestry5.annotations.Path


    @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


        this.assetSource = assetSource;
    }

    public boolean provideInjection(PlasticField field, ObjectLocator locator, MutableComponentModel componentModel)
    {
        Path path = field.getAnnotation(Path.class);

        if (path == null)
        {
            return false;
        }

        final String expanded = symbolSource.expandSymbols(path.value());

        final Resource baseResource = componentModel.getBaseResource();

        ComputedValue<Asset> computedAsset = new ComputedValue<Asset>()
        {
View Full Code Here

        this.assetSource = assetSource;
    }

    public boolean provideInjection(PlasticField field, ObjectLocator locator, MutableComponentModel componentModel)
    {
        Path path = field.getAnnotation(Path.class);

        if (path == null)
        {
            return false;
        }

        final String assetPath = path.value();
        final String libraryName = componentModel.getLibraryName();

        ComputedValue<Asset> computedAsset = new ComputedValue<Asset>()
        {
            public Asset get(InstanceContext context)
View Full Code Here

    public boolean provideInjection(String fieldName, Class fieldType, ObjectLocator locator,
            ClassTransformation transformation, MutableComponentModel componentModel)
    {
        TransformField field = transformation.getField(fieldName);

        Path path = field.getAnnotation(Path.class);

        if (path == null)
            return false;

        final String expanded = symbolSource.expandSymbols(path.value());

        final Resource baseResource = componentModel.getBaseResource();

        ComponentValueProvider<Asset> provider = new ComponentValueProvider<Asset>()
        {
View Full Code Here

        this.assetSource = assetSource;
    }

    public boolean provideInjection(PlasticField field, ObjectLocator locator, MutableComponentModel componentModel)
    {
        Path path = field.getAnnotation(Path.class);

        if (path == null)
        {
            return false;
        }

        final String assetPath = path.value();

        ComputedValue<Asset> computedAsset = new ComputedValue<Asset>()
        {
            public Asset get(InstanceContext context)
            {
View Full Code Here

    }

    public boolean provideInjection(String fieldName, Class fieldType, ObjectLocator locator,
                                    ClassTransformation transformation, MutableComponentModel componentModel)
    {
        Path path = transformation.getFieldAnnotation(fieldName, Path.class);

        if (path == null) return false;

        String expanded = symbolSource.expandSymbols(path.value());

        String sourceFieldName = transformation.addInjectedField(AssetSource.class, "assetSource", assetSource);

        String baseResourceFieldName = transformation.addInjectedField(Resource.class, "baseResource",
                                                                       componentModel.getBaseResource());
View Full Code Here

        SymbolSource symbolSource = mockSymbolSource();
        AssetSource assetSource = mockAssetSource();
        ObjectLocator locator = mockObjectLocator();
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();
        Path annotation = mockPath();
        Resource baseResource = mockResource();

        String fieldName = "myField";
        Class fieldType = Object.class;
        String value = "${foo}";
View Full Code Here

        Asset asset = mockAsset();
        String path = "${foo}";
        String expanded = "foo/bar/baz.gif";
        AnnotationProvider annotationProvider = mockAnnotationProvider();
        TypeCoercer typeCoercer = mockTypeCoercer();
        Path pathAnnotation = mockPath();
        SymbolSource symbolSource = mockSymbolSource();

        train_getAnnotation(annotationProvider, Path.class, pathAnnotation);
        train_value(pathAnnotation, path);
        train_expandSymbols(symbolSource, path, expanded);
View Full Code Here

     * @param objectType the type of object (which must be Object or Asset)
     * @param locator    not used
     */
    public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator)
    {
        Path path = annotationProvider.getAnnotation(Path.class);

        if (path == null) return null;

        String expanded = symbolSource.expandSymbols(path.value());

        Asset asset = source.getAsset(null, expanded, null);

        return typeCoercer.coerce(asset, objectType);
    }
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.Path

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.