I want to add a tooltip behavior to a ContextImage in Wicket 1.5.5.

public class SimpleTooltipBehavior extends Behavior{

        private String tooltip;
        
        public SimpleTooltipBehavior(String tooltip) {
                super();
                this.tooltip = tooltip;
        }
                
        @Override
        public void onComponentTag(Component component, ComponentTag tag) {
                super.onComponentTag(component, tag);
                tag.addBehavior(AttributeModifier.replace("alt", tooltip));
                tag.addBehavior(AttributeModifier.replace("title", tooltip));
        }       
}

This does not work. The modifiers are not added to the markup.

But this works:

public class SimpleTooltipBehavior extends Behavior{

        private String tooltip;
        
        public SimpleTooltipBehavior(String tooltip) {
                super();
                this.tooltip = tooltip;
        }
                
        @Override
        public void onComponentTag(Component component, ComponentTag tag) {
                super.onComponentTag(component, tag);
                tag.getAttributes().put("alt", tooltip);
                tag.getAttributes().put("title", tooltip);
        }
        
}

What is wrong with the first code?
                


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/ContextImage-and-tooltip-behavior-tp4544817p4544817.html
Sent from the Users forum mailing list archive at Nabble.com.

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

Reply via email to