AbstractFrame
is the root of the controller class hierarchy. Below is the description of its main methods:
-
init()
is called by the framework after creating components tree described by an XML-descriptor, but before a screen is displayed.init()
method accepts a map of parameters that can be used in controller. These parameters can be passed both from the controller of the calling screen (usingopenWindow()
,openLookup()
oropenEditor()
methods) or defined in the screen registration file screens.xml.init()
method should be implemented if it is necessary to initialize screen components, for example:@Inject private Table someTable; @Override public void init(Map<String, Object> params) { someTable.addGeneratedColumn("someColumn", new Table.ColumnGenerator<Colour>() { @Override public Component generateCell(Colour entity) { ... } }); }
-
getMessage()
,formatMessage()
– methods for retrieving localized messages from a pack, defined for a screen in the XML-descriptor. They work as shortcuts for calling the corresponding methods of the Messages interface. -
getDialogParams()
– returns aDialogParams
object to set up dialog window display properties (height, width, etc.). The values defined in this object affect the next screen opened as a modal dialog (WindowManager.OpenType.DIALOG
). The settings are reset to defaults after the dialog has been displayed.Thus, the properties of
DialogParams
object should be set immediately before opening another modal screen usingopenWindow()
,openLookup()
,openEditor()
. For example:getDialogParams().setWidth(400); openEditor("sales$Customer.edit", customer, WindowManager.OpenType.DIALOG);
If the current screen itself is modal it is possible to adjust its display properties by changing
DialogParams
object in itsinit()
method. Please note that the properties defined ininit()
method have priority over the ones defined in the calling code. -
openFrame()
– loads a frame according to an identifier registered in screens.xml file. If the method receives a container component from the invoking code, the frame is shown within the container. The method returns frame controller. For example:@Inject private BoxLayout container; @Override public void init(Map<String, Object> params) { SomeFrame frame = openFrame(container, "someFrame"); frame.setHeight("100%"); frame.someInitMethod(); }
It is not required to pass the container immediately via
openFrame()
method, instead it is possible to load the frame first and then add it to the necessary container:@Inject private BoxLayout container; @Override public void init(Map<String, Object> params) { SomeFrame frame = openFrame(null, "someFrame"); frame.setHeight("100%"); frame.someInitMethod(); container.add(frame); }
-
openWindow()
,openLookup()
,openEditor()
– open a simple screen, a lookup screen, or an edit screen respectively. Methods return a controller of the created screen.CloseListener
can be added in order to perform actions after the invoked screen closes, for example:CustomerEdit editor = openEditor("sales$Customer.edit", customer, WindowManager.OpenType.THIS_TAB); editor.addListener(new CloseListener() { @Override public void windowClosed(String actionId) { // do something } });
-
showMessageDialog()
– shows a dialog box with a message. -
showOptionDialog()
– shows a dialog box with a message and an option for user to invoke certain actions. Actions are defined by an array of Action type items displayed as buttons in the dialog.DialogAction
objects a recommended to be used for display of standard buttons such as , and other, for example:showOptionDialog("PLease confirm", "Are you sure?", MessageType.CONFIRMATION, new Action[] { new DialogAction(DialogAction.Type.YES) { @Override public void actionPerform(Component component) { // do something } }, new DialogAction(DialogAction.Type.NO); });
-
showNotification()
– shows a pop up notification. -
showWebPage()
– opens specified web page in a browser.