Apogee Home

Apogée XForms Engine: Viewers

Plugin manual

Bogdan Stefanescu, bs@nuxeo.com, Nuxeo


1. Overview

The plugin org.nuxeo.xforms.ui.editors is providing a XForms viewer widget, a XForms model viewer and integration of an Eclipse editor and viewer.

To use this plugin inside Eclipse IDE you should install the three XForms plug-in from Nuxeo:

  1. org.nuxeo.xforms.core

  2. org.nuxeo.xforms.ui

  3. org.nuxeo.xforms.ui.editors

Simply copy the plug-in jars inside your eclipse plugins directory and restart eclipse.

The org.nuxeo.xforms.ui.editors plug-in register an Eclipse View and an Eclipse editor that is bound to *.xhtml, *.xforms and *.xf file extensions.

The XForms view is located inside the group “Other Views” and can be used to browse and test XForms files

2. XForms Viewers

There are three types of viewer provided:

  1. A form Viewer: org.nuxeo.xforms.ui.editors.FormViewer

    This viewer is displaying the SWT form build from the XForms file. It also provides optional support for auto-validation when a control lose the focus. The validation status messages are displayed inside a status bar.

    On validations error a red font is used.

  2. A model viewer: org.nuxeo.xforms.ui.editors.ModelViewer

    Provides a tree view of the XForms model. For now it supports only browsing. You cannot edit the model. This will be implemented in a future version.

  3. A multi page viewer: org.nuxeo.xforms.ui.editors.XFormsViewer

    This viewer has 2 pages and contains the form viewer in the first page and the model viewer in the second page. The contained viewers are sharing the same XForms processor It also have an optional toolbar that provides several actions like:

    1. XForms file loading

    2. XSD file loading

    3. CSS file loading

    4. Instance document loading

    5. Reset, Validation and form submission

This viewer is conceived to browse and test XForms files.

3. Form Viewer

The viewer status bar is displaying the status of the last validation: a red color is used to display validation errors otherwise the default color is used :

3.1. Model Viewer

The model viewer is displaying the XForms model in a tree widget. It can be used only for borwsing the model. In a future version you will also be able to edit the model and to generate XForms files.

3.2. Using the XForms viewers

To create a XForms viewer inside a parent widget and to load a XForms document you need only a few lines of code:

FormsViewer viewer = new FormsViewer(parent, FormsViewer.MESSAGE_BAR);
XInputSource src = new FileInputSource(new File(“document.xml”));
viewer.getProcesor().load(src);
viewer.rebuild();

or

XInputSource src = new FileInputSource(new File(“document.xml”));
XFormsProcessor proc = new XFormsProcessor(src);
FormViewer viewer = new FormViewer(proc, parent, FormViewer.MESSAGE_BAR);

The first approach is creating the XForms Viewer control first, then loading a XForms file and finally rebuilding the content of the viewer.

The second approach is building the viewer using an initialized XForms processor so is no need to rebuild the view.

The model viewer is not a widget, instead it extends an Eclipse TreeViewer. It can be intialized as follows:

XInputSource src = new FileInputSource(new File(“document.xml”));
XFormsProcessor proc = new XFormsProcessor(src);
ModelViewer viewer = new ModelViewer(proc, parent);

The model viewer is usually using input objects of type: XForms, XFModel or XFInstance. Thus, to change the content displayed by the viewer you simply set a new input:

XForms form = processor.getForm();
viewer.setInput(form);
...
viewer.setInput(form.getModel(“myModel”));
...

The XFormsViewer can be used in a similar way:

XInputSource src = new FileInputSource(new File(“document.xml”));
XFormsProcessor proc = new XFormsProcessor(src);
FormViewer viewer = new FormViewer(proc, parent, XFormsViewer.MESSAGE_BAR | XFormsViewer.TOOLBAR);

To refresh the viewer after loading another XForms file (or modifying the current one) you need to call the rebuild() method: viewer.rebuild();

4. XForms View

The XForms View is located in the “Other Views” view category. It can be used to browse and test XForms documents.

5. XForms Editor

The XForms Editor is still in development. You cannot yet visually edit the XForms document but only view the generated form and the model tree.

This site is powered by CPS, which includes CPSSkins. CPS and its design are Copyright © 2002-2006 Nuxeo SAS. CPSSkins is Copyright © 2003-2006 Jean-Marc Orliaguet.
vPOWEREDBYCPS2.png
valid_xhtml.png
valid_css.png