3.8. Reusable components and controller library

In this chapter we discuss some of the framework elements that you can use to build your code. Specifically we describe how to use some of the GUI components and reusable controllers.

Note that since this documentation is work in progress, not all available compontens or controllers are described. Since this is a new section in the documentation it will take some time to describe the older components as well. Your help is apprechiated, please help us making the documenation complete by writing articles about components!

TextComponent and TextFactory

Whenever you have a little text fragment that you want to display on screen you can use the TextComponent .

The following features are supported:

  • Display raw text (provide a string)

  • Display i18nified text (provide an i18n key and a translator. Translation happens at render time)

  • Wrapp in a DIV or SPAN element

  • Style by providing an optional CSS class name that is added to the wrapper DOM element

When the text (raw or i18n) and CSS class changed on an instantiated object using the appropriate setter method the text element will be redrawn on screen. This means that when you put a TextComponent in a VelocityContainer , you can change the displayed text without making the container dirty. Only the text component itself will be redrawn. This has many advantages when building a commplex GUI and you don't want to redraw everything just because a litte text element has changed.

Usage examples can be found in the GuiDemoLinksController . To create a TextComponent object, use the TextFactory . There are two methods:

  • createTextComponentFromString

  • createTextComponentFromI18nKey