What is the design decision behind setting Component.ouputMarkupId false by default?
In Apache Wicket web framework every component returns false from getOuputMarkupId() by default.
I am curious about the reason. The design decision behind.
I am using ajax components and I need to refresh some others components on a page. To do that I got to setOutputMarkupId(true) on every component which is involved in ajax page refreshing. Because I heavily use ajax I got to do it very often. And it's not very convenient. Besides "The Best Code is No Code At All".
I can handle it this way:
class MyApp extends Application {
@Override
public init() {
Application.addComponentInstantiationListener(
new IComponentInstantiationListener() {
public void onInstantiation(Component component) {
component.setOutputMarkupId(true);
component.setOutputMarkupPlaceholderTag(true);
}
}
);
But is there any trade-off? Only trade-offs comes to my mind are:
- rendered page (html) is larger
- there is some render开发者_JAVA百科ing overhead (ie. when id attributes are write down to html)
But those have only small footprint imho.
It can't pickup id's from the .html (yet, it can in 1.5). So this would override those id's, that you may be using for css/js etc
From memory I think it isn't set by default it will overwrite any existing dom id, which could mess up your css if you are using dom id selectors.
If you don't see this problem then your solution seems good.
精彩评论