| Tag attribute @id@ plays a crucial role in web development as it allows JavaScript to identify a DOM element. That's why class @Component@ provides two dedicated methods to set this attribute. With method @setOutputMarkupId(boolean output)@ we can decide if the @id@ attribute will be rendered or not in the final markup (by default is not rendered). The value of this attribute will be automatically generated by Wicket and it will be unique for the entire page. |
| If we need to specify this value by hand, we can use method @setMarkupId(String id)@. The value of the id can be retrieved with method @getMarkupId()@. |
| |
| Wicket generates markup ids using an instance of interface @org.apache.wicket.IMarkupIdGenerator@. The default implementation is @org.apache.wicket.DefaultMarkupIdGenerator@ and it uses a session-scoped counter to generate the final id. A different generator can be set with the markup settings class @org.apache.wicket.settings.MarkupSettings@ available in the application class: |
| |
| {code} |
| @Override |
| public void init() |
| { |
| super.init(); |
| //wrap disabled links with <b> tag |
| getMarkupSettings().setMarkupIdGenerator(myGenerator); |
| } |
| {code} |