...
- The first approach is the simplest approach which overrides the Components "onComponentTag" method. In your WebPage:
Code Block ... // this can be any Component new TextField("my-text-field", myModel){ @Override protected void onComponentTag(final ComponentTag tag){ super.onComponentTag(tag); tag.put("onmouseover", "foo();return false;"); } }; ...
- The second A decoupled approach is to use a generic AbstractBehavior. In your WebPage:
Code Block ... new TextField("my-text-field", myModel).add(new AbstractBehavior(){ @Override public void onComponentTag(Component component, ComponentTag tag) { tag.put("onmouseover", "foo();return false;"); } }); ...
- The second A decoupled approach is to use an AttributeModifier/AttributeAppender. In your WebPage:
Code Block ... new TextField("my-text-field", myModel).add(new AttributeAppender("onmouseover", new Model("foo();return false;"), ";")); ...