![]() |
![]() |
| Baila | |
![]() Balia is not like another swing based widgets suite. A window built with baila maps data to widget and automatically shows the right data in the right widget. Baila also contains a user input checker, showing appropriate error message to the application user if needed. Using Baila for UI development reduces twice the "Hand Written" code! Baila does not map the database, Baila is a full 3-Tier complient (persistance layer independence). Screenshots![]() Baila beans ![]() Baila beans customizer used for UI mapping settings ![]() Widgets hierarchy for a frame using Baila Baila User's GuidePackages
Class diagram
FilesBaila is a single JAR file named "Baila.jar". RequirementsBaila run on JRE 1.1.5 and upper. Adding Baila to an IDEEach java beans capable Integrated Development Environment can import JAR files to its own java beans library. Each imported java beans can be shown in the java beans palette of the user interface IDE. For example, with Visual Café, the menu "File Add component to the library" let the user choose the "Baila.jar" file. The IDE usualy shows the new added java beans as described below.
Visual Café component library with Baila widgets From this window, the user can add all the Baila java beans in the IDEs widgets palette. This makes available Baila widgets as all other already available widgets.
Visual Café component palette with Baila widgets Now, your IDE is ready for building applications using Baila. Building an application with BailaMost IDE uses projects for building applications. The project defines source code files, archive files used, the "public static void main(String args)" start class (or HTML start page for applets) and application parameters if needed. Creating a project using BailaAs all archive used in an application, the "Baila.jar" file must be declared in the application project at design time (most IDE add it automaticaly if needed). A Baila application must starts with the Baila
Application Starter, its full class name is
" com.activebean.baila.ABBailaApplicationStarter". An
Application Starter requires two parameters : For example, the command line for the Baila sample application is : java com.activebean.baila.ABBailaApplicationStarter com.activebean.samples.crm.SearchPersonFrame parameters.properties Note : In the example above, there is no carriage return but only a space after "ApplicationStarter". Building windows with Baila widgetsBaila are used as standard Swing widgets. The developper can mix Baila widget and non Baila widgets with only one restriction : for automatic data mapping, a Baila widget must be added into a Baila container widget (ABFrame, ABPanel, etc.). Baila container widget can contain non Baila widgets. Mapping settingInstance mappingThe very first widget who have to map a value is usualy an ABFrame. The mapped value to show is usualy created or selected from a database or a file. When this value is in memory, the developer can use a code who looks like the example below for enabling automatic data mapping. Person p = getPerson(sId); // gets data from a persistance server// "this" is a ABFrame (who can be without any mapped value)this.showAsChild(new CustomerFrame(),p); Here a CustomerFrame automaticaly shows the person "p", "p" fields are automaticaly mapped with the CustomerFrame Baila widgets. The following code works outside an ABFrame.
Person p = getPerson(sId); //
gets data from a persistance server Field mappingThe MappedName property let the developper chose which business instance field have to map with the currently selected widget.
Visual Café property list for a widget named ABTextField1 In the example above, the widget ABTextField1 will map with a field named name (property MappedName). Mapping CustomizerEach ABFieldMapper widget (ABTextField, ABCheckBox, etc.) can be can be easily customized from the Baila Mapping Customizer available when the user select the "customize" property from the property list.
Baila Mapping Customizer Recursive MappingMapping is automaticaly recursive between "ABInstanceMapper" widgets using the "this" MappedName. The recursive mapping is broken if one of the widget container is not a Baila widget container (a standard Swing Jpanel for example). For example, the following "CustomerFrame" makes recursive data mapping :
CustomerFrame widgets hierarchy In this example, "tabCustomer" and "pnlCivilStatus" widgets MappedName are both set to "this", "address" widget MappedName is "address", etc. Recursive mapping is broken when a non Baila widget container (a java.awt.Container not implementing " com.activebean.baila.ABInstanceMapper") contains a Baila widget. The developer can use a code who looks like the example below for linking an isolated Baila widget with a Baila widget container. BailaContainer.addABFieldMapper(isolatedBailaWidget); Updating memory value with UI valueThe developer get an automaticaly updated instance from an ABInstanceMapper (ABFrame, ABPanel, etc.) with a code similar to the sample below :
// p is initialized with the
Person mapped in the CustomerFrame Checking UI valueThe property "Requirement" let define if this widget must be filled or not, if it had to contain a number, a date, a boolean, etc. For requirement setting, use the "Mapping Customizer" described below. The "NullWhenEmpty" property let the developper choose if the mapped instance field should be set to null when the widget is empty. If the requirement isnt satisfied when the ABInstanceMapper (the widget container) gets the mapped instance value, an error message box is automaticalty shown to the user. This message box shows the message identified by the "ErrorMessageCode" property. Baila parameters properties fileThe parameters properties file is given to the Baila Application Starter at application starting as a command line parameter or as an applet parameter, depending on the running mode. The parameter file is defined by a full or relative local file or by an URL pointing to a remote and shared parameters file like in a web site for example. Note : If the parameter file is local, it must be deployed with each client application. Requirement error messages are defined in the "parameters.properties" file like in the sample below :
# The date format used for date checking in Baila widgets is defined in the "parameters.properties" file like in the sample below :
# For work group, ActiveBean advise to share this file with a version control tool like CVS. For localisation, ActiveBean advise to use another parameters properties file with all needed converted values (messages, date format, etc.). This means that a part of the localisation is managed at deployment time. Child window closing event notificationThe user can detect a child frame closing event overriding the childClose method on the parent ABFrame calling the child ABFrame.
public void childClosed(Frame
child) Customizing mapping codeTo customize memory data update, the developper can override the "getMappedValue()" method on the needed ABFrame subclass like in the example below.
public Object getMappedValue() To customize UI update, the developper can override the "setMappedValue()" method on the needed ABFrame subclass like in the example below.
public void setMappedValue(Object
data) Managing data mapping in ABCombBox widgetsLike all Baila widgets ABCombox can map every "java.lang" class type. It had to be filled before any mapping with all possibles "toString()" resulting values. For example, if an ABComboBox had to map with a "java.lang.Integer" field, it must be filled before with "1", "2", "3" items. If the mapped field contains an Integer value that didnt match (with a "toString()" ) with any ABComboBox items, the data mapping will not work. Note on using ActiveBean Tool Library with BailaThe ActiveBean Tool library ("com.activebean.tool" package) is used by Baila, check the Tool library documentation, lots of functionnalities are assumed by the Tool library. Do not use Baila with a different version than the one already included with Baila archive. For more information on ActiveBean Tool library. Managing arraysAutomatic Array mapping are managed in the Baila v1.1.0 version. For older versions, ActiveBean advise to use a Swing JTable to select an array element like in the "SearchPersonFrame" from the "Crm" sample application. The selected element can then be shown and modified alone with Baila single element automatic mapping. Baila v1.1.0 manage automatic array mapping with the "ABArrayPanel" widget. This widget contain a control bar, an optional list, and an optional custom panel.
Array Element ClassAn array can contains differents type of elements (for example a contract array can contain an insurrance contract and a subscription contract defined in differents sub-classes of contract). For this reason the ABArrayPanel contains the "ArrayElementClass" property. This property defines wich elements of the aray are allowed to be mapped in the ABArrayPanel. The "ArrayElementClass" property is usefull to filter elements to show in a ABArrayPanel. For example it is possible to map the same a contract array with two ABArrayPanel widgets in the same window. One ABArrayPanel widget will show, add, delete and update insurrance contracts and the other ABArrayPanel widget will do the same thing for the subscriptions contracts on the same array of contract. If no class are defined in this property, the ABArrayPanel will not show any array element and consider the mapped instance as a simple business object. Control BarThe ABArrayPanel widget contains a control bar with :
Array element updates are performed automatically when :
Inner customizing panelABArrayPanel widget can be customized with an inner custom panel as in the example above. To specialize this widget add a ABPanel with a MappedName set to "this" and the "Placement" property set to "Center" (layout is forced to BorderLayout).
Optional list widgetThe optional list is available if the "ListMode"
property is set to "True". This list is not editable and
unsorted.
For more information, read the generated javadoc documentation. Managing Enumerations ValuesApproximately 50% of business object fields are enumeration values (contract type, person gender). Considering this, Baila v1.1.0 and newer versions includes an enumeration manager engine. Baila also contains widgets with automatic enumeration values filling. For example Baila combobox and list widgets (ABComboBox and ABList) will automaticaly be filled with all values available for the enumeration type of their mapped field. In Baila, an enumeration instance is a subclass of the "com.activebean.enumeration.ABEnumeration" class. Each enumeration instance contains a type (the business class name) with a limited list of valid string values. Each string value is associated with an integer code. This enumeration code is used for comparison and persistance purpose. Enumeration Properties FileEnumeration values are stored in a enumeration properties file (usualy named "enumerations.properties") defined by the "EnumerationFile" parameter of the Baila Application Starter "paramater.properties" file. You can see an example of Enumeration File declaration in the parameter properties file below :
#
Creating a new enumerationThe creation of a new enumeration needs two steps :
To create a ABEnumeration sub-class, copy an paste the following code and replace text in bold with the new enumeration name and/or package :
package business.package; ActiveBean advise to store enumeration classes in the same package of the business object(s) declaring it. To add a property in the enumeration properties file, add a new line in the file as in the example below :
# ABC enumeration values (A is
the default value) In this example, each enumeration value is separated by a semi-colon ";". Each value is associated with a code value : the first value is for the code 0 (the default value), the 2nd value is for the code 1, etc. For no default value, leave blank the first value item like in the example below :
# ABC enumeration values without
default value Each enumeration can have a format tag ("#format" at the end of the enumeration name), allowing to display differents values for the same code. The format tag is usefull for localisation. You can see an example below :
com.activebean.samples.business.ContractType=Unknown;Sales;Rental Most IDE contains a localisation tool allowing developper to choose any property value for any widget. To localize UI with Baila enumeration mapper widgets, use the format property. Using enumeration values in codeEnumeration values can be used in business method code to create or compare an instance of enumeration with a given value. You can used the sample code below as an example :
try { Note: ActiveBean strongly advise to not refer to formatted values in business code method, this will cause problem for further localisation purpose. Use only default format values or manually defined "public static final" values. Business objects are usually stored by a persistance layer like a database, ActiveBean advise to store enumeration values using the associated code. You can used the sample code below as an example for a JDBC layer :
//
database examples (table "Person" contain a "sex"
column of type "number") Mapping enumeration with Baila widgetsBaila widgets enabled to map with enumeration values (widgets implementing the ABEnumerationMapper) are ABComboBox and ABList. An ABEnumerationMapper widget will automaticaly be filled with all values available for the enumeration type of the mapped field. This means that the mapped field can not be null. For this reason all enumeration values have an "unknown value code" (-1) and a "default value code". Depending on business object with enumeration field needs, the business object constructor must set all it's enumeration fields with at least a unknown value code like in the example below : aEnumeration.setCode(ABEnumeration.UNKNOWN_VALUE_CODE); When a widget map an enumeration with a unknown value code, it display the ENUMERATION_UNKNOWN_VALUE defined in the enumeration properties file as in the example below :
# ABList widget is a Swing JList sub-class, this means that it must be in a ScrollPane to show a vertical scroll bar if needed. A ScrollPane is not a Baila widget container and this breaks recursive mapping for ABList widgets. To resolve this problem, bind the isolated ABList widget with a call of addABFieldMapper() from the associated Baila widget container. You can use the following code as an example :
/* manually bind the ABList
contractType For more information, read the generated javadoc documentation. Enabling Baila Traces for DebugBaila traces can be set to help developper to resolve problems like unmapped widgets. To enable Baila trace in standard output (Java console), add a property named "DebugBailaMapping" and set it to "True" in the Baila parameters properties file, like in the example below :
# A log file can be created to store all Baila traces. To define this log file, add add a property named "LogFile" and set it with a full or relative local file in the Baila parameters properties file, like in the example below :
# The created log file will contains information like this one :
LogFile created at 27/10/00
17:41. Those traces are managed by the ABTracer tool from the ActiveBean Tool Library and it's subclass ABBailaTracer from the Baila class package. For more information in traces read the generated javadoc documentation. Deploying an Application using BailaIn a stand alone application the Baila archive must be declared in the "CLASSPATH". For example, in Windows, use the DOS command : set CLASSPATH=.\Baila.jar;%CLASSPATH% For applets, the "Baila.jar" file must be declared in the "ARCHIVE" parameter of the "<APPLET>" tag. For example in this HTML sample : <applet archive="Baila.jar,App.jar" code="com.activebean.baila.BailaApplicationStarter"> </applet> If parameter properties file is not shared by all client programs (in a web server for example), it must be deployed in all client program hosting machines. The parameter properties file is defined in the program command line or in the "<applet>" html tag as an applet parameter. If enumeration properties file is not shared by all client programs (in a web server for example), it must be deployed in all client program hosting machines. The enumeration properties file is defined in the parameter properties file, in the "EnumerationFile" property. If application manage localization, please check that :
| |