Constructing the list

A Pod does not need to know what its content will be. At runtime the Pod will delegate to other widgets to produce the HTML that will render the content. Our movies Pod is a list of movie names and it will re-use another widget to return a HTML table containing the list data. Like the PodBuilder the ListBuilder is an API for creating lists that conform to the schema for a renderer called ListBodyRenderer. The ListBuilder generates a fragment of XML that describes a list and at runtime the ListBodyRenderer will translate this XML into the HTML that can be added to the body of a Pod. To build the Pod content for our Pod the PodLoader will use the ListBuilder to produce the list of movies.

The first step in creating our list is to construct a new ListBuilder object. The constructor on line 16 accepts an int value which is the number of columns in the list. The second parameter is a org.w3c.Document. The document parameter represents the overall PodContainer to which our Pod will be added. The document object is used to create the new Nodes that represent our Pod and its content. Those Nodes will be appended to the some part of the document object.

015      ListBuilder myFavouriteMovies =
016        ListBuilder.createList(1, document);