Examples of IParameterSpecification


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("noDefault", ps.getParameterName());
        assertEquals(true, ps.isRequired());
        assertEquals("bar", ps.getType());
        assertNull(ps.getDefaultValue());
        assertNull(ps.getDefaultBindingType());
        assertEquals(false, ps.isDeprecated());

        ps = spec.getParameter("withDefault");
        assertEquals("withDefault", ps.getParameterName());
        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());

        ps = spec.getParameter("directionIn");
        assertEquals(true, ps.getCache());

        ps = spec.getParameter("directionAuto");
        assertEquals(false, ps.getCache());
    }
View Full Code Here

Examples of org.apache.tapestry.spec.IParameterSpecification

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

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

        assertNull(ps.getDefaultValue());
        assertNull(ps.getDefaultBindingType());
        assertEquals(true, ps.getCache());
        assertTrue(ps.getAliasNames().isEmpty());
        assertEquals(false, ps.isDeprecated());

        ps = spec.getParameter("literalDefault");

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

        ps = spec.getParameter("expressionDefault");

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

        ps = spec.getParameter("defaultBindingType");

        assertEquals("ognl", ps.getDefaultBindingType());

        ps = spec.getParameter("noCache");
        assertEquals(false, ps.getCache());

        ps = spec.getParameter("withAliases");
        assertListsEqual(new String[]
        { "fred", "barney" }, ps.getAliasNames().toArray());

        assertSame(ps, spec.getParameter("fred"));
        assertSame(ps, spec.getParameter("barney"));

        ps = spec.getParameter("deprecated");
        assertEquals(true, ps.isDeprecated());
    }
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

    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("noDefault", ps.getParameterName());
        assertEquals(true, ps.isRequired());
        assertEquals("bar", ps.getType());
        assertNull(ps.getDefaultValue());
        assertEquals(false, ps.isDeprecated());

        ps = spec.getParameter("withDefault");
        assertEquals("withDefault", ps.getParameterName());
        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());

        ps = spec.getParameter("directionIn");
        assertEquals(true, ps.getCache());

        ps = spec.getParameter("directionAuto");
        assertEquals(false, ps.getCache());
    }
View Full Code Here

Examples of org.apache.tapestry.spec.IParameterSpecification

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

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

        assertNull(ps.getDefaultValue());
        assertEquals(true, ps.getCache());
        assertTrue(ps.getAliasNames().isEmpty());
        assertEquals(false, ps.isDeprecated());

        ps = spec.getParameter("literalDefault");

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

        ps = spec.getParameter("expressionDefault");

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

        ps = spec.getParameter("noCache");
        assertEquals(false, ps.getCache());

        ps = spec.getParameter("withAliases");
        assertListsEqual(new String[]
        { "fred", "barney" }, ps.getAliasNames().toArray());

        assertSame(ps, spec.getParameter("fred"));
        assertSame(ps, spec.getParameter("barney"));

        ps = spec.getParameter("deprecated");
        assertEquals(true, ps.isDeprecated());
    }
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.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

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

        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 = _DTD_4_0 ? "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 && !_DTD_4_0)
            defaultValue = BindingConstants.OGNL_PREFIX + ":" + defaultValue;

        ps.setDefaultValue(defaultValue);

        if (!_DTD_4_0)
        {
            // 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
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.