This document shows java developers to write new applications and deploy them to bellvue. Bellvue promises to free development from GUI and SQL coding. Read here how it works and what the implications are.
main help
Index
Runtime environment
Bellvue Concept
Creating a BClass
Writing the java source
Text Fields
Numeric Fields
Date Fields
The Session data object (Sdata sd)
Collections
Delete Exclusive References
Making a field read only
References
Custom Methods and Result-Objects
Set Methods, Input Validation
Get Methods
Custom Locking
The Bellvue System Application
Reserved Method Prefixes
Reserved Variable Names
Bellvue is a Platform Framework for interactive applications with centralized data storage. It is implemented as a Web-Application following the Sun Microsystems J2EE servlet standards V2.3. It is developed and tested with Tomcat 4.1.18 as servlet container. Due to following the standard other containers as BEA Weblogic, IBM Websphere, Orion, Resin, Jrun or Servlet Exec should be possible without modifications.
JDK 1.4.x is needed because of the crypto extensions and extensions of the String class.
Since all data is kept in memory, the memory parameters "-XmsYm" and "-XmxWm" where Y=W for the java vm should be taken care of. From newer erratas for hotspot use on Pentium P3/P4 systems, the switch "-XX:UseSSE=0" might be used.
A single bellvue system can host many applications. An application in bellvue is simply a group of business classes called "BClass". The same bclass can be used in more than one application. To restrict access to applications, groups of users must be associated for an application. The configurations of User, Group, Application and BClass can be done at runtime using the System Application. The system configuration is persistent in the bellvue data store.
Choosing an icon image
Icons must be stored in the GIF format with the file name extension ".gif". The file name in front of the extension must be the same as the java class name. Get icons from sourceforge or Ximian.
Choosing a package name
The package names for custom bclasses can be freely chosen with respect to the standard java package naming conventions. Names starting with "java.*", "com.sun.*", "javax.*" etc. should not be used by applications. Keeping the package names as short as possible should be a matter of course.
All classes should import import net.methodyne.bellvue.* and need to implement the Serializable interface. The data storage requires each class to have an id declared like this:
public long id = -1l;
To give the user a way to identify the object a method called getTitle is needed:
public String getTitle(){ return title; }
Where the returned String is any meaningful for the user. It can return just a field called title or derived from the other fields.
Text fields represented by the String type in java can be represented in HTML in several ways. By default a one line inputbox is shown like this:
public String test = "hi";
test
To hide the value for password fields a disp-Method returning the String "HIDDEN" needs to be provided:
public String password = ""; public String dispPassword(Sdata sd){ return "HIDDEN"; }
For other styles a method with the same name as the String variable preceded by "disp" returning a String must be added.
This first letter of the variable name when preceded by disp need to be uppercase then. For example:
public String box = "opta"; public String dispBox(Sdata sd){ return "SELECT,Valone,Valtwo,ValThree,opta,optb"; }box
A text area is done that way:
public String area = ""; public String dispArea(Sdata sd){ return "AREA,30,5"; }
area |
Last not least radio boxes:
public String radio = ""; public String dispRadio(Sdata sd){ return "RADIO,Valone,Valtwo,ValThree,opta,optb"; }
Note: Since we have a function here the option values can be dynamically composed at runtime from the data store.
radio | Valone Valtwo ValThree opta optb |
Just declare as usual and don't forget to always give an initialization value.
public long id = -1l; public String title = ""; public boolean bool = true; public byte byte1 = 10; public short shorty = 20; public char character = 'J'; public int integer1 = 200; public float floating = 55.6660f; public long longer = 555555l; public double dubble = 66666.666d;
The java.util.Date() Object is supported. To allow the format of the date value to be altered a custom disp...-method must be supplied which returns the format for displaying and entering:
public Date date = new Date(); public String dispDate(Sdata sd){ return "yyyy.MM.dd"; }
For the format syntax see java.text.SimpleDateFormat from the java api documentation.
The Session data object (Sdata sd)
This links what the user sees and enters, the datastore, individual objects and other settings. Please see the source directly
To make a collection we need to provide a vector for the objects, a vector for the references and a method telling the collections type:
public Vector groups = new Vector(); public Vector referenceGroups = new Vector(); public String typeGroups(){ return "net.methodyne.bellvue.system.Group"; }
Sometimes objects in collections or references are not used in anywhere else. For example an address object referenced by
a person object. If the person gets deleted the referenced address is expected to be deleted as well.
To automate the task of deleting referenced objects in collections and references when deleting a parent object, a special function can be added. The function has the prefix "delEx". If it exists all referenced objects get recursive removed from the store on deletion of the parent object.
To make values read only or to disable custom functions an about-Method returning the String "on" or "off" must be in place:
public String aboutGroups(Sdata sd){ for(int i = 0 ; i < groups.size(); i++){ if( ((Group)groups.elementAt(i)).groupname.equalsIgnoreCase("admin") ){ return "on"; } } return "off"; }
References are like a collection that can only hold one object. Therefore instead of vectors it uses object as type:
public Object account = null; public Object referenceAccount = null; public String typeAccount(){ return "net.methodyne.demo.Account"; }
Custom Methods and Result-Objects
To give the user a possibility to run code against the data etc. methods can be added to the classes. The method name need to start with "action". To enable/disable it there must be a method with the same suffix and "about" as prefix returning "on" or "off".
public String aboutPlotChart(Sdata sd){ return "on"; } public void actionPlotChart(Sdata sd) { String filename = accountPlot("Account line", sd ); String graphURL = sd.req.getContextPath() + "/DisplayChart?filename=" + filename; net.methodyne.bellvue.core.ResultObject r = new net.methodyne.bellvue.core.ResultObject(); r.title = "Account balance time plot"; r.result = "<img src=\""+ graphURL + "\" width=500 height=300 border=0>"; sd.view.addStateLess(r); }
To give visual feedback to the user see the last four lines from aboves. First a resultobject gets created,
then a title string is assigned which gets displayed in the top line for each result in the main frame.
Everything assigned to r.result is expected to be html. In the account object it is a link to an image created above with the jFreeChart framework.
In the last step this resultobject needs to be added to the viewvector as shown in the last line.
For the full code see the Account object from the OrderManager app.
Methods for input validation start with the prefix "set" and end with the variables name first letter in uppercase. In case of an input error it should return a string which is displayed to the user in red besides or below the input box. Note that this function gets the string the user enters and the session data objects as parameters.
public int integer1 = 200; public String setInteger1(String e, Sdata sd){ int c = Integer.parseInt(e); if( (c < 100) || (c > 300) ){ return "Enter number between 100 and 300!"; } else{ this.integer1 = c; return null; } }
Get methods get executed before the value of a field gets read in order to be rendered in the html page. They are optional to allow data to be read from fields without writing a affiliated get method. However for page rendering the data is always read from the field after executing the get method. So the return value of the get method is not used. Here an example from the Order class:
public float total = 0; public String aboutTotal(Sdata sd) { return "off"; } public String getTotal(){ float ret = 0; Position pos = null; if(positions != null){ for(int i = 0; i < positions.size(); i++){ pos = (Position)positions.elementAt(i); if( pos != null && pos.product != null ){ ret += pos.count * ((Product)pos.product).price; } } } total = ret; return "" + ret; }
Bellvue supports three different locking variants. They can be assigned different for each bclass.
1. Exclusive read and write This makes the objects read and write access exclusive.
2. Exclusive write (default) Only the first user who opens an object can write it, others can still read it.
3. No lock This disables locking and is faster.
To change the locking behavior for a bclass add a method called lockType which returns one of these Strings:
1. EXRW
2. EXW
3. OFF
Note: providing this method is only usefull for setting EXRW or OFF since EXW is used per default when no method is there.
The Bellvue System Application
The core of the bellvue system is operated by a bellvue application called System. When starting bellvue for the first time without data a new System Application is created and a user called admin with the password admin_99. This is the only account to start with since creating users via the login page does not grant access to the system app which is necessary to add bclasses, applications etc. Writing this means that the password for the admin account should be changed immediately after logging in for the first time
Use the Bulk object for import and export of data from and to files. The data can be URL-encoded/decoded using one of these standard character sets:
UTF-8 Eight-bit UCS Transformation Format - this is the default. US-ASCII Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set ISO-8859-1 ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1 UTF-16 Sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order mark
When exporting Users or security sensitive data strong cryptography can be used.
Password based encryption us used here. The password for importing must be the same as the one used when the file got exported.
These names are used by the bellvue system as prefix for methods. The full method name is the prefix shown here and the associated variable name with the first character converted to uppercase.
Example:
variable name: wingMan
method: aboutWingMan()
Prefix | short description |
---|---|
type | Used for references and collections. Returns the full qualified classname |
disp | Tells the html form input type to render String variables or the format for Date fields/types. |
reference | Used for references and collections. This is a variable prefix - not for methods! For collections it must be a of type Vector() and for (single object collections) references of type Object. |
action | To make methods lauchable by the user. |
about | To make variables read only and disable methods. Returns the String "on" or "off" accordingly. |
getTitle() | This is not a prefix rather than a full methodname to give the user a dynamic (taken from the objects data somehow) title to distinguish between objects. |
set | Routines for input validation. |
get | Executed before values get read for a field. |
delEx | Recursively deletes referenced objects when parent gets deleted. |
These variable names are used by the bellvue system. The "id" MUST be existent in every Bclass as it makes the primary key.
The "referencePrivateUser" is optional to give the possibility to make objects only visible to the user who created them. Whenever this variable
exists in a bclass you get the effect.
Note: do not change the values of these variables in your code. Just declare them a shown below and the bellvue system can work with them.
// the internal primary key or automatic index public long id = -1l; // this means only the user created this can see this object! public long referencePrivateUser = -1l;
Copyright 2003 Methodyne GmbH Impressum