Package org.apache.tapestry.spec

Examples of org.apache.tapestry.spec.IParameterSpecification


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

    public void testRequired()
    {
        IParameterSpecification ps = attempt("requiredParameter");

        assertEquals(true, ps.isRequired());
    }
View Full Code Here


        assertEquals(true, ps.isRequired());
    }

    public void testDefaultBinding()
    {
        IParameterSpecification ps = attempt("beanDefaultParameter");

        assertEquals("bean", ps.getDefaultBindingType());
        assertEquals("java.lang.Object", ps.getType());
    }
View Full Code Here

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

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

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

        assertEquals(false, ps.getCache());
    }

    public void testAliases()
    {
        IParameterSpecification ps = attempt("aliasedParameter");

        assertListsEqual(new String[]
        { "fred" }, ps.getAliasNames().toArray());
    }
View Full Code Here

        { "fred" }, ps.getAliasNames().toArray());
    }

    public void testDeprecated()
    {
        IParameterSpecification ps = attempt("deprecatedParameter");
        assertEquals(true, ps.isDeprecated());
    }
View Full Code Here

        assertEquals(true, ps.isDeprecated());
    }

    public void testNamed()
    {
        IParameterSpecification ps = attempt("namedParameter", "fred");

        assertEquals("fred", ps.getParameterName());
        assertEquals("namedParameter", ps.getPropertyName());
    }
View Full Code Here

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

        ps.setDefaultBindingType(getAttribute("default-binding"));

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

        IComponentSpecification cs = (IComponentSpecification) peekObject();

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

    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

    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());
        assertNull(ps.getDefaultBindingType());

        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());

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

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

    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());

        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());
    }
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.