Well, if you really want to have the attributes editable, I think the
map should be bit smarter.
something like
class AttributeMap
{
private Map customAttributes = null
private Map getMarkupAttributes()
{
// return attributes from the markup (read only)
}
public String get(String key)
{
if (customAttributes != null &&
customAttributes.containsKey(key))
return customAttributes.get(key);
else
return getMarkupAttributes().get(key);
}
public String set(String key, String value)
{
if (customAttributes == null)
customAttributes = new HashMap(); // better not hashmap, but
something smaller
customAttributes.put(key, value);
}
}
wouldn't this work better?
-Matej
Johan Compagner wrote:
-1 for removing it
We just have to make it a bit smarter for markup reloading ( i will look
into that)
I just want to be able to do this:
getAttributes().put("attribute", "blabla") or
getAttributes().put("attribute", new Model(){////});
that is so much more easy and self explainable for newbies then the current
add attribute modifier stuff.
johan
On 10/2/06, Matej Knopp <[EMAIL PROTECTED]> wrote:
+1 to remove it. I never liked this copy on write value map. It's
nothing I can't do in onComponentTag or using a behavior.
I think method to retrieve tag attributes from markup would be
sufficient.
Btw. what would be the purpose of id variable?
-Matej
Juergen Donnerstag wrote:
> Currently Component.java maintains a copy-on-write ValueMap for markup
> attributes which user might want to change, such as getMarkupId()
> which adds the id="xxx" attribute to the tag.
>
> However, the current implementation doesn't work properly as the
> Component owned attribute map keep the "old" value even when the
> markup has been re-loaded because of locale, style or variation
> changes (see FormExample)
>
> I wonder if this general use case of being able to modify any tag
> attribute in the constructor realy exists or if "id" is the only case.
> If the latter is true, than I would like to suggest to remove
> markupAttribute from Component as it requires some realy hackish code
> later on. I'd much rather add a "id" variable to the component for the
> specific purpose of MarkupId()..
>
> What do think?
>
> Juergen
>