Search in sources :

Example 96 with Block

use of org.apache.tapestry5.Block in project tapestry-5 by apache.

the class AbstractConditional method beginRender.

/**
 * Returns null if the {@link #test()} is true, which allows normal rendering (of the body). If the test parameter
 * is false, returns the else parameter (this may also be null).
 */
Object beginRender(MarkupWriter writer) {
    boolean enabled = test();
    Block toRender = enabled ? (thenBlock == null ? resources.getBody() : thenBlock) : elseBlock;
    String elementName = resources.getElementName();
    if (enabled && elementName != null) {
        renderTag = true;
        writer.element(elementName);
        resources.renderInformalParameters(writer);
    }
    return toRender;
}
Also used : Block(org.apache.tapestry5.Block)

Example 97 with Block

use of org.apache.tapestry5.Block in project tapestry-5 by apache.

the class AbstractPropertyOutput method renderPropertyValue.

/**
 * Invoked from subclasses to do the rendering. The subclass controls the naming convention for locating an
 * overriding Block parameter (it is the name of the property possibly suffixed with a value).
 * @param writer a MarkupWriter
 * @param overrideBlockId the override block id
 * @return a Block
 */
protected Object renderPropertyValue(MarkupWriter writer, String overrideBlockId) {
    Block override = overrides.getOverrideBlock(overrideBlockId);
    if (override != null)
        return override;
    String datatype = model.getDataType();
    if (beanBlockSource.hasDisplayBlock(datatype)) {
        PropertyOutputContext context = new PropertyOutputContext() {

            public Messages getMessages() {
                return overrides.getOverrideMessages();
            }

            public Object getPropertyValue() {
                return readPropertyForObject();
            }

            public String getPropertyId() {
                return model.getId();
            }

            public String getPropertyName() {
                return model.getPropertyName();
            }
        };
        environment.push(PropertyOutputContext.class, context);
        mustPopEnvironment = true;
        return beanBlockSource.getDisplayBlock(datatype);
    }
    Object value = readPropertyForObject();
    String text = value == null ? "" : value.toString();
    if (InternalUtils.isNonBlank(text)) {
        writer.write(text);
    }
    return false;
}
Also used : PropertyOutputContext(org.apache.tapestry5.services.PropertyOutputContext)

Example 98 with Block

use of org.apache.tapestry5.Block in project tapestry-5 by apache.

the class BeanBlockSourceImplTest method conflicting_bean_block_overrides.

@Test
public // TAP5-2506
void conflicting_bean_block_overrides() {
    RequestPageCache cache = mockRequestPageCache();
    Collection<BeanBlockContribution> configuration = CollectionFactory.newList();
    configuration.add(new DisplayBlockContribution("foo", "page1", "bar"));
    configuration.add(new DisplayBlockContribution("foo", "page2", "baz"));
    try {
        new BeanBlockOverrideSourceImpl(cache, configuration);
        unreachable();
    } catch (IllegalArgumentException ex) {
        assertEquals(ex.getMessage(), "The BeanBlockOverrideSource configuration contains multiple display block overrides for data type 'foo'.");
    }
}
Also used : DisplayBlockContribution(org.apache.tapestry5.services.DisplayBlockContribution) BeanBlockContribution(org.apache.tapestry5.services.BeanBlockContribution) Test(org.testng.annotations.Test)

Example 99 with Block

use of org.apache.tapestry5.Block in project tapestry-5 by apache.

the class BeanBlockSourceImplTest method train_getBlock.

protected final void train_getBlock(Page page, String blockId, Block block) {
    ComponentPageElement element = mockComponentPageElement();
    train_getRootElement(page, element);
    expect(element.getBlock(blockId)).andReturn(block);
}
Also used : ComponentPageElement(org.apache.tapestry5.internal.structure.ComponentPageElement)

Example 100 with Block

use of org.apache.tapestry5.Block 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

Test (org.testng.annotations.Test)12 Block (net.minecraft.server.v1_12_R1.Block)9 Block (org.apache.tapestry5.Block)9 ByteString (com.google.protobuf.ByteString)8 ArrayList (java.util.ArrayList)8 Block (net.minecraft.server.v1_10_R1.Block)8 Block (net.minecraft.server.v1_11_R1.Block)8 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)8 Block (net.minecraft.server.v1_8_R3.Block)8 FallingBlock (org.bukkit.entity.FallingBlock)8 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)7 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)7 AnnotateImageResponse (com.google.cloud.vision.v1.AnnotateImageResponse)6 Block (com.google.cloud.vision.v1.Block)6 Feature (com.google.cloud.vision.v1.Feature)6 ImageAnnotatorClient (com.google.cloud.vision.v1.ImageAnnotatorClient)6 Page (com.google.cloud.vision.v1.Page)6 Paragraph (com.google.cloud.vision.v1.Paragraph)6 Symbol (com.google.cloud.vision.v1.Symbol)6 Word (com.google.cloud.vision.v1.Word)6