Wiki
Clone wikijavarosa / CreatingView
Creating New Displays
There are two primary view objects in the system design. One of them is a Form View, that is responsible for displaying an entire XForm. The other is a Prompter, which actually prompts the user with a single XForm question, and is responsible for setting the new answer for that question.
An individual display can be both a Form View and a Prompter. The Chatterbox interface is both a Form View and a Prompter.
Creating a Form View/Prompter
New Form Views need to implement the !FormView interface. The interface has two methods that need to be implemented
registerController(Controller controller)
: Internally registers the given Controller for this viewshowPrompt(Prompt prompt)
: Displays an individual prompt
New Prompters need to implement the IPrompter interface. This interface has three methods that need to implemented
showPrompt(Prompt prompt)
: Displays an individual promptshowPrompt(Prompt prompt, int screenIndex, int totalScreens)
: Displays an individual prompt and provides the index of the current promptregisterController(Controller controller)
: Internally registers the given Controller for this view
Interacting with the Controller
Both Form Views and Prompters have a method that provides the inheriting class with a Controller object. This object is responsible for actually providing Prompts. The Form View and Prompter are responsible for signaling the Controller to request the next prompt, or to save or exit.
Once registered, the Controller can be sent events with the processEvent
method, which takes a !ReponseEvent object as an argument. Typical events are ResponseEvent.NEXT
, ResponseEvent.SAVE_AND_RELOAD
, and ResponseEvent.EXIT
.
Registering the Actual Display
The view that is used is set in the Controller that is used by the application. This is set in the !TransportShell class, in the configureController
method. Currently, there is a property that is set on the devices, "!ViewStyle", which will be one a discrete set of values that identifies the current view.
The JavaRosaPropertyRules
class is responsible for identifying what values that View Style can be set to. Your view should be added to this list of allowable Displays.
Once your display is an acceptable value for the View Style, you can set the Prompter and Form View for it in Transport Shell, in the setViewType
method, using the displays already there as examples.
Updated