description has been loaded into an org.jdom.Element tree // please read the JDOM documentation for information about how to // retrieve values from elements in the tree public void readDescription(Element di) { // read the standard DataItem attributes super.readDescription(di); // read any extra data from the Element that is specific to this class // using the JDOM API setData(di); // bind to a Data Model if (model != null) { if (modelPath == null) modelPath = getPath(); Object node = model.getElement(modelPath); if (node == null) { LOG.error("no node for "+modelPath); } if (node != null && node instanceof Element) setData((Element)node); model.addDataChangeListener(new DataChangeListener() { public void dataChanged(DataModel model) { Object node = model.getElement(modelPath); if (node != null && node instanceof Element) setData((Element)node); } }); } } private void layoutComponents() { removeAll(); // add the GUI elements add(component); } protected void setData(Element node) { Element e; if ((e = node.getChild(fieldname)) != null) { // set the internal data with the value of this node i.e. component.setText(e.getText()); } // layout the GUI components layoutComponents(); } // methods that must be implemented protected Component getComponent() { // return a Component that contains data or null // used when laying out in a ColumnDataItem return component; } public NameValuePair getNameValuePair() { // classes which represent a single value can return a NameValuePair return new NameValuePair(fieldname,value); // otherwise return null; } protected ArrayList getParameters() { ArrayList list = new ArrayList(); // add NameValuePair objects to the list for each element of data return list; } protected ArrayList getAllElements() { return getParameters(); } protected ArrayList getSelectedElements() { // classes that represent data that can have selected elements can // return a list of elements that are selected, otherwise return null; } protected void updateData(ArrayList params,String action) { refresh(params,action); } protected void loadData(ArrayList params,String action) { if (loaded == false) refresh(params,action); loaded = true; } protected void refresh(ArrayList extraParams,String action) { loadItemData(extraParams,action); } public void close() { // called when the application closes } protected void loadItemData(ArrayList params,String action) { // post the parameters in the ArrayList to the url in the value attribute try { // post the parameters to the URL Element node = getElementFromURL(value,params,action); if (node != null) { setData(node) } } catch (Exception e) { LOG.error(name+" error loading data ",e); errorMessage("error loading data " + e.getMessage()); } } protected String getTypeName() { return "MyData"; } }
@version
$Revision: $
@author
Damian Hamill
@see {@link DataItemAdaptor}