Search in sources :

Example 91 with Block

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

the class DynamicTemplateSaxParser method createBlockElement.

private static DynamicTemplateElement createBlockElement(final String blockId, final Location location) {
    return new DynamicTemplateElement() {

        public void render(MarkupWriter writer, RenderQueue queue, DynamicDelegate delegate) {
            try {
                Block block = delegate.getBlock(blockId);
                queue.push((RenderCommand) block);
            } catch (Exception ex) {
                throw new TapestryException(String.format("Exception rendering block '%s' as part of dynamic template: %s", blockId, ExceptionUtils.toMessage(ex)), location, ex);
            }
        }
    };
}
Also used : RenderQueue(org.apache.tapestry5.runtime.RenderQueue) Block(org.apache.tapestry5.Block) DynamicDelegate(org.apache.tapestry5.services.dynamic.DynamicDelegate) MarkupWriter(org.apache.tapestry5.MarkupWriter) TapestryException(org.apache.tapestry5.commons.internal.util.TapestryException) TapestryException(org.apache.tapestry5.commons.internal.util.TapestryException)

Example 92 with Block

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

the class SaxTemplateParser method parameterElement.

/**
 * Tapestry 5.1 uses a special namespace (usually mapped to "p:") and the
 * name becomes the parameter element.
 */
private void parameterElement(TemplateParserState state) {
    ensureParameterWithinComponent(state);
    if (tokenStream.getAttributeCount() > 0)
        throw new TapestryException("A block parameter element does not allow any additional attributes. The element name defines the parameter name.", getLocation(), null);
    tokenAccumulator.add(new ParameterToken(tokenStream.getLocalName(), getLocation()));
    processBody(state.insideComponent(false));
}
Also used : TapestryException(org.apache.tapestry5.commons.internal.util.TapestryException)

Example 93 with Block

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

the class PropertyConduitSourceImplTest method object_methods_can_be_invoked.

/**
 * TAP5-330
 */
@Test
public void object_methods_can_be_invoked() {
    PropertyConduit conduit = source.create(Block.class, "toString()");
    Block b = new Block() {

        @Override
        public String toString() {
            return "Do You Grok Ze Block?";
        }
    };
    assertEquals(conduit.get(b), "Do You Grok Ze Block?");
}
Also used : Block(org.apache.tapestry5.Block) PropertyConduit(org.apache.tapestry5.beanmodel.PropertyConduit) InternalPropertyConduit(org.apache.tapestry5.beanmodel.internal.InternalPropertyConduit) PropBindingFactoryTest(org.apache.tapestry5.internal.bindings.PropBindingFactoryTest) Test(org.testng.annotations.Test)

Example 94 with Block

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

the class ProgressiveDisplay method beginRender.

Block beginRender(MarkupWriter writer) {
    String clientId = jsSupport.allocateClientId(resources);
    String elementName = resources.getElementName("div");
    writer.element(elementName, "id", clientId, "data-container-type", "zone");
    resources.renderInformalParameters(writer);
    Link link = resources.createEventLink(EventConstants.ACTION, context);
    jsSupport.require("t5/core/zone").invoke("deferredZoneUpdate").with(clientId, link.toURI());
    // of the component.
    return initial;
}
Also used : Link(org.apache.tapestry5.http.Link)

Example 95 with Block

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

the class PropertyEditor method beginRender.

/**
 * Returns a Block for rendering the property. The Block will be able to access the {@link PropertyEditContext} via
 * the {@link Environmental} annotation.
 */
Block beginRender() {
    Block override = overrides.getOverrideBlock(propertyModel.getId());
    if (override != null) {
        return override;
    }
    String dataType = propertyModel.getDataType();
    if (dataType == null)
        throw new RuntimeException(String.format("The data type for property '%s' of %s is null.", propertyModel.getPropertyName(), object));
    try {
        return beanBlockSource.getEditBlock(dataType);
    } catch (RuntimeException ex) {
        String message = messages.format("core-block-error", propertyModel.getPropertyName(), dataType, object, ex);
        throw new TapestryException(message, resources.getLocation(), ex);
    }
}
Also used : TapestryException(org.apache.tapestry5.commons.internal.util.TapestryException)

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