Search in sources :

Example 1 with PropertyOutputContext

use of org.apache.tapestry5.services.PropertyOutputContext 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)

Aggregations

PropertyOutputContext (org.apache.tapestry5.services.PropertyOutputContext)1