Hi All,

First of all, thnx for all the hard work put in the Tiles2 development. 
It's good to see old, good library with refreshed API.

Speaking about the API: I was trying to add a new attribute type to Tiles2 
and I've found that this is not a trivial task? I mean, I can find all the 
places to tweak, but I'm a little bit scared of changing 
BasicTilesContainer. For me, the problems comes from the:

 public void render(Attribute attr, Writer writer, Object... requestItems)

method. More specifically, this switch statement is kind of problematic:

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());
        }

It looks like I would need to change the AttributeType enum, definitions 
reader and the BasicTilesContainer? 

I was wondering if it would be possible to change an implementation in the 
way that each attribute is responsible for rendering itself. I know this 
is quite a change, but I was wondering if such a design was ever 
considered. Sorry if I'm blind and can't see obvious problems with such a 
design?. I would be really grateful for any feedback. Basically, my goal 
is to add a new type of attribute and not to rewrite to much chunks of 
Tiles2.

Thnx,
Pawel

Reply via email to