Hi Thorsten,

adding a behavior to the tag is nothing you would want to do in your behavior, because it's too late to have any effect on the current rendering (see Component#renderComponentTag()).

Behaviors on markup tags are meant to be used to alter the markup independent of any component, see RelativePathPrefixHandler and WicketMessageTagHandler for inspiration.

> what should I do to let my AjaxBehavior change the "class" attribute?

The following is just fine:

    tag.append("class", "murks", " ");

Regards
Sven

On 27.01.2015 19:25, Thorsten Schöning wrote:
Hi all,

I have a class extending AbstractAjaxBehavior and overriding
onComponentTag(ComponentTag tag), because I need a custom css class
added. I thought this would be an easy task by simply adding an
AttributeAppender like the following:

tag.addBehavior(AttributeModifier.append("class", "murks2"));
But that doesn't work, the "class" attribute retains it's initial
value. If I add low level like the following the attribute's value
changes successfully:

tag.append("class", "murks", " ");
I googled a bit and found one thread about AjaxLink and the same
problem, but no description on why using AttributeModifier doesn't
work and I don't even use AjaxLink at all.

Am I doing something wrong or is this intended behavior? In the latter
case, what should I do to let my AjaxBehavior change the "class"
attribute?

Thanks for your help!

Mit freundlichen Grüßen,

Thorsten Schöning



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to