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.getRoles())) {
if (LOG.isDebugEnabled()) {
LOG.debug("Access to attribute denied. User not in role '"
+ attr.getRoles() + "'");
}
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());
}
}