Examples of IParameterSpecification


Examples of org.apache.tapestry.spec.IParameterSpecification

        expected.add("fred");

        assertEquals(expected, s.getReservedParameterNames());

        IParameterSpecification ps = new ParameterSpecification();

        ps.setAliases("wilma,barney");
        ps.setParameterName("bambam");

        s.addParameter(ps);

        expected.add("wilma");
        expected.add("barney");
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 propertyName = getValidatedAttribute(
                "property-name",
                PROPERTY_NAME_PATTERN,
                "invalid-property-name");

        if (propertyName == null)
            propertyName = name;

        ps.setPropertyName(propertyName);

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

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

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

        if (defaultValue != null && !_DTD_3_1)
            defaultValue = "ognl:" + defaultValue;

        ps.setDefaultValue(defaultValue);

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

        String type = getAttribute("type");

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

        IComponentSpecification cs = (IComponentSpecification) peekObject();

        cs.addParameter(name, ps);
View Full Code Here

Examples of org.apache.tapestry.spec.IParameterSpecification

    public void testValidParameterName() throws Exception
    {
        IComponentSpecification spec = parseComponent("ValidParameterName.jwc");

        IParameterSpecification ps = spec.getParameter("valid");

        assertNotNull("Parameter specification.", ps);
        checkLine(ps, 24);
    }
View Full Code Here

Examples of org.apache.tapestry.spec.IParameterSpecification

    public void testParameter_3_0() throws Exception
    {
        IComponentSpecification spec = parseComponent("Parameter_3_0.jwc");

        IParameterSpecification ps = spec.getParameter("noDefault");

        assertEquals("noDefault", ps.getPropertyName());
        assertEquals(true, ps.isRequired());
        assertEquals("bar", ps.getType());
        assertNull(ps.getDefaultValue());

        ps = spec.getParameter("withDefault");
        assertNull(ps.getType());
        assertEquals(false, ps.isRequired());

        // For 3.0 DTDs, where the default value was always an OGNL expression,
        // the parser will provide the "ognl:" prefix.

        assertEquals("ognl:an.expression", ps.getDefaultValue());

        ps = spec.getParameter("withDescription");
        assertEquals("A parameter with a description.", ps.getDescription());

        ps = spec.getParameter("altName");
        assertEquals("altNameParameter", ps.getPropertyName());
    }
View Full Code Here

Examples of org.apache.tapestry.spec.IParameterSpecification

    public void testParameters() throws Exception
    {
        IComponentSpecification spec = parseComponent("Parameter.jwc");

        IParameterSpecification ps = spec.getParameter("noDefault");

        assertNull(ps.getDefaultValue());

        ps = spec.getParameter("literalDefault");

        assertEquals("literal-value", ps.getDefaultValue());

        ps = spec.getParameter("expressionDefault");

        assertEquals("ognl:an.expression", ps.getDefaultValue());
    }
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 && component.getBinding(name) == null) {
                // there is no binding for this parameter. bind it to the default value
                IBinding binding = new ExpressionBinding(_resolver, component, defaultValue, parameterSpec.getLocation());
                component.setBinding(name, binding);
            }
               
        }
    }
View Full Code Here

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

            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,
                    null);
            }

            if (!propertyInfo.isReadWrite())
            {
                throw new ConnectedParameterException(
                    Tapestry.format(
                        "ParameterManager.property-not-read-write",
                        _component.getExtendedId(),
                        propertyName),
                    _component,
                    name,
                    propertyName,
                    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

        IComponentSpecification specification = getSpecification();

        if (specification.getParameter(ITemplateSource.TEMPLATE_TAG_PARAMETER_NAME) == null)
        {
            // Add a templateTag parameter
            IParameterSpecification parameter = new ParameterSpecification();
            parameter.setPropertyName(ITemplateSource.TEMPLATE_TAG_PARAMETER_NAME);
            parameter.setDirection(Direction.AUTO);
            parameter.setType("java.lang.String");
            parameter.setDefaultValue("null");
            parameter.setLocation(specification.getLocation());
            parameter.setRequired(false);
           
            specification.addParameter(ITemplateSource.TEMPLATE_TAG_PARAMETER_NAME, parameter);
        }
    }
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
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.