Creating a Pod using a PodLoader

The next step is to create our PodLoader class. The PodLoader extends the class curam.cefwidgets.pods.pod.impl.PodLoader and implements the createPod method. Create a new class on the Server by copying the example below into a class named HelloWorld in the package pods.loaders.

Figure 1. A very simple PodLoader
001  package pods.podloaders;
002
003  import java.util.Map;
004  import org.w3c.dom.Document;
005  import org.w3c.dom.Node;
006  import curam.cefwidgets.docbuilder.impl.PodBuilder;
007  import curam.cefwidgets.pods.pod.impl.PodLoader;
008  import curam.codetable.PODTYPE;
009
010  public class HelloWorld extends PodLoader {
011
012    @Override
013    public Node createPod(Document document, Map<String,Object> contexts) {
014      try{
015        PodBuilder helloWorld = 
016          PodBuilder.newPod(document, PODTYPE.HELLOWORLD);
017        helloWorld.setTitle("Hello World");
018        return helloWorld.getWidgetRootNode();
019      }catch(Exception e){
020        throw new RuntimeException(e);
021      }
022    }
023  }

Input

The createPod method receives 2 parameters from the infrastructure that calls it.
Table 1. createPod method parameters
Parameter Description
document

The Document parameter is an instance of a org.w3c.Document class.

It is passed to the method by the infrastructure that calls it. The Document instance is used to create and append the 'pod' Node that describes the Pod.

context The context parameter is used to pass page level paramtets to the Pods. Currently this is not support.

Output

An instance of the org.w3c.Node object is returned by the createPod method.
Table 2. Return object from createPod
Return object Description
org.w3cNode The content of the Node returned must match a predefined schema. The PodBuilder class provides an API to create our 'pod' Node in the correct format.
In the example 4.3 the simple Pod is created by creating a new instance of a PodBuilder class on line 16. The Document instance from the PodLoader and the codetable value from the PodType codetable are passed to the consturctor. On line 17 we use the PodBuilder to set the title of the Pod. The PodBuilder builds a Node tree representing the Pod which is returned on line 18 as a Node object.