Wicket is a component based web framework which allows you to develop web applications in a similar way the desktop applications developed. The framework has very little effect on the HTML markup used. The dynamic elements of the html markup are marked with "wicket:id" attribute only. Eventhough it has very little addition on markup, its connection with the backend is very powerful thanks to the IModel interface.

IModel interface provides all the data the user interface elements need. Because the framework depends heavily on IModel interface, many implementations exist for IModel interface, but choosing the right model may be confusing at first. In addition to this, components of dynamic html elements created on server side but the creation and configuration of the components may lead to unnecessarily complex code.

For this reason, I am proposing another approach by using annotations to create and configure components on the server side. In order to explain it, I will create a simple "new user" page.

"id" is the path from topmost parent element to id of current dynamic element. If an element resides in a form element, and form element is the topmost parent then id of EasyWicket annotation is [form_element_id.element_id]. You can see an example of this usage in java code. The textfield for name of the user defined as following;

@EasyWicket(id="form.txtName", value="name")

Here you see that the EasyWicket id is the combination of form and text field elements separated by dot.

"value" is the value of the html element. "list" is the list of possible values. For example, DropDownChoice get list of the choices from this value. "action" is used for buttons and links. It is called when button submitted or link clicked. "required" call setRequired() function of a form component. "visible" is active for some elements. It specifies the name of function to determine the visibility of the element. "ajaxEnabled" make element ready for ajax manipulation. "rowsPerPage" and "columns" used for DataTable component. "displayProperty" and "idProperty" is used for DropDownChoice components. They are the names of the properties for displaying id and text of the select boxes.

The page component, PGNewUser implements IEasyContainer interface. This interface must be implemented for the components containing EasyWicket components.

IEasyWicketContainer.java

public interface IEasyWicketContainer {

public void initValues(); public void pack(); public void setCurrentWidgetContext(WidgetContext widgetContext);

}

"initValues()" called before components instantiated and configured. You have to initialize the values here. "pack()" called after components instantiated. "setCurrentWidgetContext()" called by some of EasyWicket components like DropDownChoice while rendering the component. It just gives the state of the current component to the container to get values while rendering in progress.

And finally, If you want to enable EasyWicket library you have to add EasyWicketComponentListener to your application like that;