I like the idea,
and I suggest your second approach:
AttributeModifier.overwrite(String attribute, IModel<?> value);
AttributeModifier.overwrite(String attribute, String value);
AttributeModifier.prepend(String attribute, IModel<?> value);
AttributeModifier.prepend(String attribute, String value);
AttributeModifier.append(String attribute, IModel<?> value);
AttributeModifier.append(String attribute, String value);
Simple, Readable and Straightforward.
Regards
Martin Dilger
2011/6/8 Martijn Dashorst <[email protected]>
> Taken from the user@ list, where it might get snowed under...
>
> The SimpleAttributeModifier, AttributeAppender and AttributePrepender
> classes are in my opinion stop gap measures to work around issues with
> AttributeModifier's API.
>
> I think that we could do better API wise with three factory methods (or 6
> if
> we duplicate each method to take an IModel<?> and a String for
> convenience) on AttributeModifier, and deprecate SimpleAttributeModifier
> and AttributeAppender. I'd also merge the appender/prepender logic into
> attribute modifier, such that user specializations can make use of
> them.
>
> AttributeModifier.setAttribute(String attribute, IModel<?> value);
> AttributeModifier.setAttribute(String attribute, String value);
> AttributeModifier.prependAttribute(String attribute, String value);
> AttributeModifier.prependAttribute(String attribute, IModel<?> value);
> AttributeModifier.appendAttribute(String attribute, String value);
> AttributeModifier.appendAttribute(String attribute, IModel<?> value);
>
> Or perhaps:
>
> AttributeModifier.overwrite(String attribute, IModel<?> value);
> AttributeModifier.overwrite(String attribute, String value);
> AttributeModifier.prepend(String attribute, IModel<?> value);
> AttributeModifier.prepend(String attribute, String value);
> AttributeModifier.append(String attribute, IModel<?> value);
> AttributeModifier.append(String attribute, String value);
>
> I'd value input on the naming of things.
>
> Martijn
>
--
---------------------------------------------------------------------------------------------
Martin Dilger
Dietersheimerstraße 23
80805 München
Kontakt: [email protected]
---------------------------------------------------------------------------------------------