Package org.apache.tapestry.spec

Examples of org.apache.tapestry.spec.IParameterSpecification


                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


        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

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

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

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

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

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

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

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

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

    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 (HiveMind.isBlank(result))
            result = metaDefaultBindingType;

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

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

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

    public void testSimple()
    {
        Location l = newLocation();

        IParameterSpecification ps = attempt("simpleParameter", l);

        assertListsEqual(new Object[] {}, ps.getAliasNames().toArray());
        assertEquals(true, ps.getCache());
        assertEquals(null, ps.getDefaultBindingType());
        assertEquals(null, ps.getDefaultValue());
        assertEquals(null, ps.getDescription());
        assertSame(l, ps.getLocation());
        assertEquals("simpleParameter", ps.getParameterName());
        assertEquals("simpleParameter", ps.getPropertyName());
        assertEquals("java.lang.String", ps.getType());
    }
View Full Code Here

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

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

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

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

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

        assertEquals("bean", ps.getDefaultBindingType());
        assertEquals("java.lang.Object", ps.getType());
    }
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.