Examples of IParameterSpecification


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

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

            // Skip aliases

            if (!name.equals(parameterSpec.getParameterName())) continue;

            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 was always an OGNL expression, but now its
            // a binding reference.

            if (component.getBinding(name) == null)
            {
                String description = PageloadMessages
                        .defaultParameterName(name);

                IBinding binding = _bindingSource.createBinding(component,
                        description, defaultValue,
                        BindingConstants.OGNL_PREFIX, 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 ps = spec.getParameter(name);

            try
            {
                performEnhancement(op, name, ps);
            }
            catch (RuntimeException ex)
            {
                _errorLog.error(EnhanceMessages.errorAddingProperty(ps.getPropertyName(), op
                        .getBaseClass(), ex), ps.getLocation(), ex);
            }
        }
    }
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 ps = spec.getParameter(name);

            try
            {
                performEnhancement(op, name, ps);
            }
            catch (RuntimeException ex)
            {
                _errorLog.error(EnhanceMessages.errorAddingProperty(ps
                        .getPropertyName(), op.getBaseClass(), ex), ps
                        .getLocation(), ex);
            }
        }
    }
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());
        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

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

        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

Examples of org.apache.tapestry.spec.IParameterSpecification

    }

    private IParameterSpecification newParameterSpec(String defaultBindingType)
    {
        MockControl control = newControl(IParameterSpecification.class);
        IParameterSpecification pspec = (IParameterSpecification) control.getMock();

        pspec.getDefaultBindingType();
        control.setReturnValue(defaultBindingType);

        return pspec;
    }
View Full Code Here

Examples of org.apache.tapestry.spec.IParameterSpecification

        verifyControls();
    }

    public void testFormalParameterWithDefault()
    {
        IParameterSpecification pspec = newParameterSpec("barney");
        IComponentSpecification spec = newSpec("formal", pspec);

        replayControls();

        assertEquals("barney", BindingUtils.getDefaultBindingType(spec, "formal", "fred"));
View Full Code Here

Examples of org.apache.tapestry.spec.IParameterSpecification

        verifyControls();
    }

    public void testFormalParameterWithoutDefault()
    {
        IParameterSpecification pspec = newParameterSpec(null);
        IComponentSpecification spec = newSpec("formal", pspec);

        replayControls();

        assertEquals("fred", BindingUtils.getDefaultBindingType(spec, "formal", "fred"));
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.