THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
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;"); } }; ... |
You can also add to existing tag attributes using the onComponentTag:
Code Block |
---|
Image img = new Image("my-img-id") {
@Override
protected void onComponentTag(ComponentTag tag) {
// illustrates how to prevent an image from caching by adding a random value to the src attribute
super.onComponentTag(tag);
String src = (String) tag.getAttributes().get("src");
src = src + "&rand=" + Math.random();
tag.getAttributes().put("src", src);
}
};
|
A decoupled approach is to use a generic AbstractBehavior. In your WebPage:
...