Why does Wicket changes the id of the html elements?

Monis Iqbal picture Monis Iqbal · Jan 16, 2010 · Viewed 10.1k times · Source

If I write

<form wicket:id="form" id="form>

or even

<form wicket:id="form>...

Then the rendered HTML shows the id 'form' appended with different numbers whenever the page is refreshed e.g.

   <form id="form7"....

Is there a way to disable this behavior of the Wicket framework?

Answer

Michal Bernhard picture Michal Bernhard · Jan 19, 2010

We set markup ids by hand extensively on our project to ease automatic testing with Selenium testing framework. It definitely works.

Component.setOutputMarkupId(true); // write id attribute of element to html
Component.setMarkupId("someid"); // id attribute of element is "someid"