Package org.apache.tapestry5

Examples of org.apache.tapestry5.Binding


                    InternalComponentResources containerResources = pageAssembly.activeElement.peek().getComponentResources();

                    ComponentPageElement embeddedElement = pageAssembly.createdElement.peek();
                    InternalComponentResources embeddedResources = embeddedElement.getComponentResources();

                    Binding binding = elementFactory.newBinding(parameterName,
                                                                containerResources,
                                                                embeddedResources,
                                                                defaultBindingPrefix,
                                                                parameterValue,
                                                                location);
View Full Code Here


                                           String containerParameterName)
    {
        // TODO: This assumes that the two parameters are both on the core component and not on
        // a mixin. I think this could be improved with more static analysis.

        Binding containerBinding = container.getBinding(containerParameterName);

        if (containerBinding == null) return;

        // This helps with debugging, and re-orients any thrown exceptions
        // to the location of the inherited binding, rather than the container component's
View Full Code Here

    @Test
    public void expression_has_no_prefix()
    {
        BindingFactory factory = mockBindingFactory();
        Binding binding = mockBinding();
        ComponentResources container = mockComponentResources();
        ComponentResources component = mockComponentResources();
        Location l = mockLocation();

        String defaultPrefix = "def";
        String description = "descrip";
        String expression = "full expression";

        train_newBinding(factory, description, container, component, expression, l, binding);

        replay();

        Map<String, BindingFactory> map = newMap();

        map.put(defaultPrefix, factory);

        BindingSource source = new BindingSourceImpl(map, interner);

        Binding actual = source.newBinding(
                description,
                container,
                component,
                defaultPrefix,
                expression,
View Full Code Here

    @Test
    public void expression_prefix_not_in_configuration()
    {
        BindingFactory factory = mockBindingFactory();
        Binding binding = mockBinding();
        ComponentResources container = mockComponentResources();
        ComponentResources component = mockComponentResources();
        Location l = mockLocation();

        String defaultPrefix = "def";
        String description = "descrip";
        String expression = "javascript:not-a-known-prefix";

        train_newBinding(factory, description, container, component, expression, l, binding);

        replay();

        Map<String, BindingFactory> map = newMap();

        map.put(defaultPrefix, factory);

        BindingSource source = new BindingSourceImpl(map, interner);

        Binding actual = source.newBinding(
                description,
                container,
                component,
                defaultPrefix,
                expression,
View Full Code Here

    @Test
    public void known_prefix()
    {
        BindingFactory factory = mockBindingFactory();
        Binding binding = mockBinding();
        ComponentResources container = mockComponentResources();
        ComponentResources component = mockComponentResources();
        Location l = mockLocation();

        String defaultPrefix = "literal";
        String description = "descrip";

        // The "prop:" prefix is stripped off ...
        train_newBinding(factory, description, container, component, "myproperty", l, binding);

        replay();

        Map<String, BindingFactory> map = newMap();

        map.put("prop", factory);

        BindingSource source = new BindingSourceImpl(map, interner);

        Binding actual = source.newBinding(
                description,
                container,
                component,
                defaultPrefix,
                "prop:myproperty",
View Full Code Here

        {
            public void advise(MethodInvocation invocation)
            {
                ComponentResources resources = invocation.getInstanceContext().get(ComponentResources.class);

                Binding binding = bindingSource.newBinding("@Cached watch", resources,
                        BindingConstants.PROP, watch);

                bindingFieldHandle.set(invocation.getInstance(), binding);

                invocation.proceed();
            }
        });

        return new MethodResultCacheFactory()
        {
            public MethodResultCache create(Object instance)
            {
                Binding binding = (Binding) bindingFieldHandle.get(instance);

                return new WatchedBindingMethodResultCache(binding);
            }
        };
    }
View Full Code Here

        {
            public String map(DynamicDelegate delegate)
            {
                try
                {
                    Binding binding = bindingSource.newBinding("dynamic template binding", delegate
                            .getComponentResources().getContainerResources(), delegate.getComponentResources(),
                            BindingConstants.PROP, expression, location);

                    Object boundValue = binding.get();

                    return boundValue == null ? null : boundValue.toString();
                } catch (Throwable t)
                {
                    throw new TapestryException(InternalUtils.toMessage(t), location, t);
View Full Code Here

                            }

                            // Otherwise, construct a default binding, or use one provided from
                            // the component.

                            Binding binding = getDefaultBindingForParameter();

                            if (logger.isDebugEnabled())
                            {
                                logger.debug(String.format("%s parameter %s bound to default %s", icr.getCompleteId(),
                                        parameterName, binding));
View Full Code Here

        ComponentResources resources = newComponentResources(bean);
        Location l = mockLocation();

        replay();

        Binding binding = factory.newBinding("test binding", resources, null, "objectValue", l);

        assertSame(binding.getBindingType(), String.class);

        bean.setObjectValue("first");

        assertEquals(binding.get(), "first");

        binding.set("second");

        assertEquals(bean.getObjectValue(), "second");
        assertEquals(InternalUtils.locationOf(binding), l);

        assertEquals(binding.toString(), "PropBinding[test binding foo.Bar:baz(objectValue)]");

        verify();
    }
View Full Code Here

        ComponentResources resources = newComponentResources(bean);
        Location l = mockLocation();

        replay();

        Binding binding = factory.newBinding("test binding", resources, null, "readOnly", l);

        assertEquals(binding.getAnnotation(Validate.class).value(), "readonly");

        verify();
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.Binding

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.