tags:

views:

39

answers:

2

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 rendering overhead (ie. when id attributes are write down to html)

But those have only small footprint imho.

+3  A: 

It's 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

slckin
I see! Now I understand... Thx..
Michal Bernhard
A: 

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.

Richard