Linux Today: Linux News On Internet Time.

Extending OpenCms: Developing a Custom Widget

Jan 16, 2009, 06:32 (0 Talkback[s])
(Other stories by Dan Liliedahl)

[ Thanks to Sanjiv Lavangare for this link. ]

"Referring to the highlighted code in BlogEntry content type schema file we can see that the category field is populated from a drop-down list provided by SelectorWidget. The SelectorWidget obtains its values from the static configuration string defined within the blog schema file. This design is problematic as we would like category values to be easily changed or added. Ideally, the list of category values should be able to be updated by site content editors. Fortunately, we can create our own custom widget to handle this requirement.

"An OpenCms widget is a Java class that implements the I_CmsWidget interface, located in the org.opencms.widgets package. The interface contains a number of methods that must be implemented. First there are some methods dealing with instantiation and configuration of the widget:

"newInstance: This returns a new instance of the widget.
setConfiguration: This method is called after the widget has been initialized to configure it. The configuration information is passed as a string value coming from the declaration of the widget within the schema file of the content type using it.
getConfiguration: This is called to retrieve the configuration information for the widget."

Complete Story

Related Stories: