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);
}
}
};
}
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));
}
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?");
}
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;
}
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);
}
}
Aggregations