我想使用Apache Wicket将AttributeAppender添加到AjaxEventBehavior内的组件。行为具有getComponent()方法,但在构造函数getComponent()obvioulsy中返回null。如何将行为添加到另一个组件中另一个行为添加到该组件的Wicket
现在我该组件传递给AjaxEventBehavior的构造,它的工作,但是这是一个很好的方式来实现我的目标..
下面是我在做什么:
AjaxTooltipBehavior:
public class AjaxTooltipBehavior extends AjaxEventBehavior {
public AjaxTooltipBehaviour(String event, Component tooltippedComponent) {
super(event);
tooltippedComponent.add(new AttributeAppender("data-tooltip","wicketAjaxTooltip"));
}
...
}
这就是我的方式使用它:
...
final WebMarkupContainer icon = new WebMarkupContainer("icon"); //a tooltiped icon
icon2.add(new AjaxTooltipBehaviour("mouseover",icon2)
我问自己是否没有办法将AttributeAppender添加到组件中,而不将组件传递到AjaxTooltipBehavior。 有谁知道这是可能的检票口还是有更好的解决方案? 仅供参考:我正在使用wicket 1.6。
在此先感谢您的支持! Ronny
此解决方案的工作原理,但我发现了一个更好的方法。我重写'onConfigure(Component component)',这似乎是与行为组件一起工作的正确位置。不过谢谢你! – rontron