AttributeAppender seems to be ignored in AbstractAjaxBehavior.onComponentTag

2015-01-27 Thread Thorsten Schöning
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

-- 
Thorsten Schöning   E-Mail: thorsten.schoen...@am-soft.de
AM-SoFT IT-Systeme  http://www.AM-SoFT.de/

Telefon...05151-  9468- 55
Fax...05151-  9468- 88
Mobil..0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: AttributeAppender seems to be ignored in AbstractAjaxBehavior.onComponentTag

2015-01-27 Thread Sven Meier

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: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org