Model interactionThis document describes how Bishop converts HTTP request variables into Java object and how to invoke methods on the model (business objects). WebMacro vs BishopIf WebMacro transform the java object into html, Bishop does something like the opposite. Bishop converts HTTP request variables into real java object. These object can then be used as arguments to methods on the business model. Thus eliminating the need for the global Hashtable, or the context as it is called in WebMacro. Parameter conversionAs mentioned elsewhere, Bishop is able to convert HTTP request variables into ordinary Java objects. While this might sound a bit like magic at first, doesn't mean that it is hard to use. The parameter conversion is primarily used when invoking model methods. If the method setAgeForUser(String name, int age) should be invoked, we need 2 variables. These variables are supplied by the client as HTTP request variables and are accessible via the servlet api as Strings. The user has filled out a form that contained one field with named "name" that contains the name of the user who's age should be changed and one variabled "age" with the value for age. When invoking the method setAgeForUser, Bishop get the variables "name" and "age" from the HTTP request and converts them into their Java representation. Ie the name is a java.lang.String and the age variable is an int. These new objects are then supplied as arguments when the method is called. The Bishop code for this conversion and invokation would be:
If the client for some reason doesn't provide these request variables, is it possible to defined a default-value for each object. This is shown in the code above. ObjectsA model invokation can take existing objects as arguments as well as HTTP request varibles. For example, the result from one invokation can be used as input to another:
|
[home] | [introduction] | [webmacro] | [model interaction] | [developer's guide] | [reference] | [terms and definitions] |