Search in sources :

Example 1 with LiteralBindingFactory

use of org.apache.tapestry5.internal.bindings.LiteralBindingFactory in project tapestry-5 by apache.

the class BindingFactoryTest method literal_binding.

@Test
public void literal_binding() {
    ComponentResources res = mockInternalComponentResources();
    Location l = mockLocation();
    replay();
    BindingFactory factory = new LiteralBindingFactory();
    Binding b = factory.newBinding("test binding", res, null, "Tapestry5", l);
    assertSame(InternalUtils.locationOf(b), l);
    assertEquals(b.get(), "Tapestry5");
    assertTrue(b.isInvariant());
    assertSame(b.getBindingType(), String.class);
    try {
        b.set(null);
        unreachable();
    } catch (TapestryException ex) {
        assertSame(ex.getLocation(), l);
    }
    verify();
}
Also used : Binding(org.apache.tapestry5.Binding) TapestryException(org.apache.tapestry5.commons.internal.util.TapestryException) ComponentResources(org.apache.tapestry5.ComponentResources) Location(org.apache.tapestry5.commons.Location) BindingFactory(org.apache.tapestry5.services.BindingFactory) Test(org.testng.annotations.Test)

Example 2 with LiteralBindingFactory

use of org.apache.tapestry5.internal.bindings.LiteralBindingFactory in project tapestry-5 by apache.

the class TapestryModule method contributeBindingSource.

// ========================================================================
// 
// Service Builder Methods (static)
// 
// ========================================================================
// ========================================================================
// 
// Service Contribution Methods (static)
// 
// ========================================================================
/**
 * Contributes the factory for several built-in binding prefixes ("asset",
 * "block", "component", "literal", prop",
 * "nullfieldstrategy", "message", "validate", "translate", "var").
 */
public static void contributeBindingSource(MappedConfiguration<String, BindingFactory> configuration, @InjectService("PropBindingFactory") BindingFactory propBindingFactory, @InjectService("MessageBindingFactory") BindingFactory messageBindingFactory, @InjectService("ValidateBindingFactory") BindingFactory validateBindingFactory, @InjectService("TranslateBindingFactory") BindingFactory translateBindingFactory, @InjectService("AssetBindingFactory") BindingFactory assetBindingFactory, @InjectService("NullFieldStrategyBindingFactory") BindingFactory nullFieldStrategyBindingFactory, @InjectService("ContextBindingFactory") BindingFactory contextBindingFactory, @InjectService("SymbolBindingFactory") BindingFactory symbolBindingFactory) {
    configuration.add(BindingConstants.LITERAL, new LiteralBindingFactory());
    configuration.add(BindingConstants.COMPONENT, new ComponentBindingFactory());
    configuration.add(BindingConstants.VAR, new RenderVariableBindingFactory());
    configuration.add(BindingConstants.BLOCK, new BlockBindingFactory());
    configuration.add(BindingConstants.PROP, propBindingFactory);
    configuration.add(BindingConstants.MESSAGE, messageBindingFactory);
    configuration.add(BindingConstants.VALIDATE, validateBindingFactory);
    configuration.add(BindingConstants.TRANSLATE, translateBindingFactory);
    configuration.add(BindingConstants.ASSET, assetBindingFactory);
    configuration.add(BindingConstants.NULLFIELDSTRATEGY, nullFieldStrategyBindingFactory);
    configuration.add(BindingConstants.CONTEXT, contextBindingFactory);
    configuration.add(BindingConstants.SYMBOL, symbolBindingFactory);
}
Also used : LiteralBindingFactory(org.apache.tapestry5.internal.bindings.LiteralBindingFactory) BlockBindingFactory(org.apache.tapestry5.internal.bindings.BlockBindingFactory) RenderVariableBindingFactory(org.apache.tapestry5.internal.bindings.RenderVariableBindingFactory) ComponentBindingFactory(org.apache.tapestry5.internal.bindings.ComponentBindingFactory)

Aggregations

Binding (org.apache.tapestry5.Binding)1 ComponentResources (org.apache.tapestry5.ComponentResources)1 Location (org.apache.tapestry5.commons.Location)1 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)1 BlockBindingFactory (org.apache.tapestry5.internal.bindings.BlockBindingFactory)1 ComponentBindingFactory (org.apache.tapestry5.internal.bindings.ComponentBindingFactory)1 LiteralBindingFactory (org.apache.tapestry5.internal.bindings.LiteralBindingFactory)1 RenderVariableBindingFactory (org.apache.tapestry5.internal.bindings.RenderVariableBindingFactory)1 BindingFactory (org.apache.tapestry5.services.BindingFactory)1 Test (org.testng.annotations.Test)1