public void render(Attribute attr, Writer writer, Object... requestItems)
throws TilesException, IOException {
TilesRequestContext request = getRequestContext(requestItems);
if (attr == null) {
throw new TilesException("Cannot render a null attribute");
}
if (!isPermitted(request, attr.getRole())) {
LOG.info("Access to attribute '" + attr.getName()
+ "' denied. User not in role '" + attr.getRole());
return;
}
AttributeType type = attr.getType();
if (type == null) {
type = calculateType(attr, request);
attr.setType(type);
}
switch (type) {
case OBJECT:
throw new TilesException(
"Cannot insert an attribute of 'object' type");
case STRING:
writer.write(attr.getValue().toString());
break;
case DEFINITION:
render(request, attr.getValue().toString());
break;
case TEMPLATE:
request.dispatch(attr.getValue().toString());
break;
default: // should not happen
throw new TilesException(
"Unrecognized type for attribute value "
+ attr.getValue());
}
}