You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Thorsten Schöning <ts...@am-soft.de> on 2015/01/27 19:25:29 UTC

AttributeAppender seems to be ignored in AbstractAjaxBehavior.onComponentTag

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


Re: AttributeAppender seems to be ignored in AbstractAjaxBehavior.onComponentTag

Posted by Sven Meier <sv...@meiers.net>.
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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org