Package org.apache.tapestry.spec

Examples of org.apache.tapestry.spec.IParameterSpecification


        assertEquals("java.lang.Object", ps.getType());
    }

    public void testCacheOff()
    {
        IParameterSpecification ps = attempt("nonCachedParameter", null);

        assertEquals(false, ps.getCache());
    }
View Full Code Here


        while (i.hasNext())
        {
            String name = (String) i.next();

            IParameterSpecification pspec = spec.getParameter(name);

            boolean isFormal = pspec != null;

            String parameterName = isFormal ? pspec.getParameterName() : name;

            IBindingSpecification bspec = contained.getBinding(name);

            // If not allowing informal parameters, check that each binding
            // matches
            // a formal parameter.

            if (formalOnly && !isFormal)
                throw new ApplicationRuntimeException(PageloadMessages.formalParametersOnly(
                        component,
                        name), component, bspec.getLocation(), null);

            // If an informal parameter that conflicts with a reserved name,
            // then skip it.

            if (!isFormal && spec.isReservedParameterName(name))
                continue;

            if (isFormal)
            {
                if (!name.equals(parameterName))
                {
                    _log.error(PageloadMessages.usedParameterAlias(
                            contained,
                            name,
                            parameterName,
                            bspec.getLocation()));
                }
                else if (pspec.isDeprecated())
                    _log.error(PageloadMessages.deprecatedParameter(
                            name,
                            bspec.getLocation(),
                            contained.getType()));
            }
View Full Code Here

                Map.Entry entry = (Map.Entry) i.next();

                String attributeName = (String) entry.getKey();
                String value = (String) entry.getValue();

                IParameterSpecification pspec = spec.getParameter(attributeName);
                String parameterName = pspec == null ? attributeName : pspec.getParameterName();

                if (!attributeName.equals(parameterName))
                    _log.error(ImplMessages.usedTemplateParameterAlias(
                            token,
                            attributeName,
View Full Code Here

        Iterator i = spec.getParameterNames().iterator();

        while (i.hasNext())
        {
            String name = (String) i.next();
            IParameterSpecification parameterSpec = spec.getParameter(name);

            // Skip aliases
           
            if (! name.equals(parameterSpec.getParameterName()))
                continue;
           
            String defaultValue = parameterSpec.getDefaultValue();
            if (defaultValue == null)
                continue;

            // the parameter has a default value, so it must not be required
            if (parameterSpec.isRequired())
                throw new ApplicationRuntimeException(PageloadMessages
                        .parameterMustHaveNoDefaultValue(component, name), component, parameterSpec
                        .getLocation(), null);

            // if there is no binding for this parameter, bind it to the default value.
            // In 3.0, default-value was always an OGNL expression, but now its a binding reference.

            if (component.getBinding(name) == null)
            {
                String description = PageloadMessages.defaultParameterName(name);

                String defaultBindingType = parameterSpec.getDefaultBindingType();
                if (defaultBindingType == null)
                    defaultBindingType = BindingConstants.OGNL_PREFIX;

                IBinding binding = _bindingSource.createBinding(
                        component,
                        description,
                        defaultValue,
                        defaultBindingType,
                        parameterSpec.getLocation());

                component.setBinding(name, binding);
            }
        }
    }
View Full Code Here

        Iterator i = spec.getParameterNames().iterator();
        while (i.hasNext())
        {
            String name = (String) i.next();

            IParameterSpecification ps = spec.getParameter(name);

            try
            {
                performEnhancement(op, name, ps);
            }
            catch (RuntimeException ex)
            {
                _errorLog.error(EnhanceMessages.errorAddingProperty(ps.getPropertyName(), op
                        .getBaseClass(), ex), ps.getLocation(), ex);
            }
        }
    }
View Full Code Here

                    LOG.debug("Not bound.");

                continue;
            }

            IParameterSpecification pspec = spec.getParameter(name);
            Direction direction = pspec.getDirection();

            if (direction != Direction.IN && direction != Direction.FORM)
            {
                if (debug)
                    LOG.debug("Parameter is " + pspec.getDirection().getName() + ".");

                continue;
            }

            String propertyName = pspec.getPropertyName();

            if (debug && !name.equals(propertyName))
                LOG.debug("Connecting to property " + propertyName + ".");

            // Next,verify that there is a writable property with the same
            // name as the parameter.

            PropertyInfo propertyInfo =
                PropertyFinder.getPropertyInfo(_component.getClass(), propertyName);

            if (propertyInfo == null)
            {
                throw new ConnectedParameterException(
                    Tapestry.format(
                        "ParameterManager.no-accessor",
                        _component.getExtendedId(),
                        propertyName),
                    _component,
                    name,
                    propertyName);
            }

            if (!propertyInfo.isReadWrite())
            {
                throw new ConnectedParameterException(
                    Tapestry.format(
                        "ParameterManager.property-not-read-write",
                        _component.getExtendedId(),
                        propertyName),
                    _component,
                    name,
                    propertyName);
            }

            // Check if the parameter type matches the property type

            Class propertyType = propertyInfo.getType();
            Class parameterType = getType(pspec.getType(), resolver);

            if (parameterType == null)
            {
                throw new ConnectedParameterException(
                    Tapestry.format(
View Full Code Here

        Iterator i = spec.getParameterNames().iterator();

        while (i.hasNext())
        {
            String name = (String) i.next();
            IParameterSpecification parameterSpec = spec.getParameter(name);

            if (parameterSpec.isRequired() && component.getBinding(name) == null)
                throw new ApplicationRuntimeException(
                    Tapestry.format(
                        "PageLoader.required-parameter-not-bound",
                        name,
                        component.getExtendedId()),
View Full Code Here

        for (int i = 0; i < count; i++)
        {
            String name = (String) names.get(i);

            IParameterSpecification ps = _specification.getParameter(name);

            scanForBindingProperty(name, ps);

            scanForParameterProperty(name, ps);
        }
View Full Code Here

        for (int i = 0; i < count; i++)
        {
            String name = (String) names.get(i);

            IParameterSpecification ps = _specification.getParameter(name);

            scanForBindingProperty(name, ps);

            scanForParameterProperty(name, ps);
        }
View Full Code Here

        String propertyName = AnnotationUtils.getPropertyName(method);

        boolean deprecated = method.isAnnotationPresent(Deprecated.class);

        IParameterSpecification ps = new ParameterSpecification();

        String parameterName = parameter.name();

        if (HiveMind.isBlank(parameterName))
            parameterName = propertyName;

        Class propertyType = op.getPropertyType(propertyName);

        ps.setAliases(parameter.aliases());
        ps.setCache(parameter.cache());

        if (HiveMind.isNonBlank(parameter.defaultBinding()))
            ps.setDefaultBindingType(parameter.defaultBinding());

        if (HiveMind.isNonBlank(parameter.defaultValue()))
            ps.setDefaultValue(parameter.defaultValue());

        ps.setDeprecated(deprecated);
        ps.setParameterName(parameterName);
        ps.setPropertyName(propertyName);
        ps.setRequired(parameter.required());
        ps.setType(propertyType.getName());
        ps.setLocation(location);

        spec.addParameter(ps);
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.spec.IParameterSpecification

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.