Examples of IParameterSpecification


Examples of org.apache.tapestry.spec.IParameterSpecification

        _parameterName = parameterName;
        _binding = binding;

        _resolver = component.getPage().getEngine().getResourceResolver();

        IParameterSpecification pspec = _component.getSpecification().getParameter(_parameterName);
        _required = pspec.isRequired();
        _propertyName = pspec.getPropertyName();
        _direction = pspec.getDirection();

        _clearValue = readCurrentPropertyValue();
    }
View Full Code Here

Examples of org.apache.tapestry.spec.IParameterSpecification

                    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;
            }

            if (!direction.getAllowInvariant() && binding.isInvariant())
                throw new ConnectedParameterException(
                    Tapestry.format(
                        "ParameterManager.incompatible-direction-and-binding",
                        new Object[] {
                            name,
                            _component.getExtendedId(),
                            direction.getDisplayName(),
                            binding }),
                    _component,
                    name,
                    null,
                    binding.getLocation(),
                    null);

            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,
                    binding.getLocation(),
                    null);
            }

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

            // 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

Examples of org.apache.tapestry.spec.IParameterSpecification

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

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

            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(
                Tapestry.format(
                    "EstablishDefaultParameterValuesVisitor.parameter-must-have-no-default-value",
                    component.getExtendedId(),
                    name),
                component,
                parameterSpec.getLocation(),
                null);
           
            // if there is no binding for this parameter, bind it to the default value
            if (component.getBinding(name) == null) {
                IBinding binding = new ExpressionBinding(_resolver, component, defaultValue, parameterSpec.getLocation());
                component.setBinding(name, binding);
            }
               
        }
    }
View Full Code Here

Examples of org.apache.tapestry.spec.IParameterSpecification

        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

Examples of org.apache.tapestry.spec.IParameterSpecification

        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.warn(PageloadMessages.usedParameterAlias(
                            contained,
                            name,
                            parameterName,
                            bspec.getLocation()));
                }
                else if (pspec.isDeprecated())
                    _log.warn(PageloadMessages.deprecatedParameter(
                            name,
                            bspec.getLocation(),
                            contained.getType()));
            }
View Full Code Here

Examples of org.apache.tapestry.spec.IParameterSpecification

        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(
                    PageloadMessages.requiredParameterNotBound(name, component),
                    component,
                    component.getLocation(),
                    null);
View Full Code Here

Examples of org.apache.tapestry.spec.IParameterSpecification

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

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

            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 as always an OGNL expression, but now its a locator.

            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

Examples of org.apache.tapestry.spec.IParameterSpecification

    public static String getDefaultBindingType(IComponentSpecification specification,
            String parameterName, String metaDefaultBindingType)
    {
        String result = null;

        IParameterSpecification ps = specification.getParameter(parameterName);

        if (ps != null)
            result = ps.getDefaultBindingType();

        if (result == null)
            result = metaDefaultBindingType;

        return result;
View Full Code Here

Examples of org.apache.tapestry.spec.IParameterSpecification

        push(_elementName, null, STATE_NO_CONTENT);
    }

    private void enterParameter()
    {
        IParameterSpecification ps = _factory.createParameterSpecification();

        String name = getValidatedAttribute(
                "name",
                PARAMETER_NAME_PATTERN,
                "invalid-parameter-name");

        String attributeName = _dtd40 ? "property" : "property-name";

        String propertyName = getValidatedAttribute(
                attributeName,
                PROPERTY_NAME_PATTERN,
                "invalid-property-name");

        if (propertyName == null)
            propertyName = name;

        ps.setParameterName(name);
        ps.setPropertyName(propertyName);

        ps.setRequired(getBooleanAttribute("required", false));

        // In the 3.0 DTD, default-value was always an OGNL expression.
        // Starting with 4.0, it's like a binding (prefixed). For a 3.0
        // DTD, we supply the "ognl:" prefix.

        String defaultValue = getAttribute("default-value");

        if (defaultValue != null && !_dtd40)
            defaultValue = BindingConstants.OGNL_PREFIX + ":" + defaultValue;

        ps.setDefaultValue(defaultValue);

        if (!_dtd40)
        {
            // When direction=auto (in a 3.0 DTD), turn caching off

            String direction = getAttribute("direction");
            ps.setCache(!"auto".equals(direction));
        }
        else
        {
            boolean cache = getBooleanAttribute("cache", true);
            ps.setCache(cache);
        }

        // type will only be specified in a 3.0 DTD.

        String type = getAttribute("type");

        if (type != null)
            ps.setType(type);

        // aliases is new in the 4.0 DTD

        String aliases = getAttribute("aliases");

        ps.setAliases(aliases);
        ps.setDeprecated(getBooleanAttribute("deprecated", false));

        IComponentSpecification cs = (IComponentSpecification) peekObject();

        cs.addParameter(ps);
View Full Code Here

Examples of org.apache.tapestry.spec.IParameterSpecification

        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.warn(PageloadMessages.usedParameterAlias(contained,
                            name, parameterName, bspec.getLocation()));
                }
                else if (pspec.isDeprecated())
                    _log.warn(PageloadMessages.deprecatedParameter(name, bspec
                            .getLocation(), contained.getType()));
            }

            // The type determines how to interpret the value:
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.