| [Data Definitions] | [Query Languages] | [JSP tag library: Intro | Listing | Forms] | [Business Logics] | [Summary] |
Attributes
Java Server Pages use attributes to keep the state of the application.
Makumba builds upon that its own notion of Attributes that keep the
read-only state
of a makumba task. They represent the "environment" of that makumba
task. The typical
example is a JSP page during execution, with its HTTP and session
parameters
as attributes. Since other kinds of attributes are possible, the
attribute
specification is kept HTTP-independent. Makumba BL code sees the
attributes
as an Java handler classes Java handler classes are classes that implement the "business
logic" of the organisation. Every makumba page will look for a handler,
and will call its methods when needed. Check also the
<mak:newForm> to know which methods
are called. If a handler class
exists, then some operations cannot be performed if these methods are
not defined in the handler class. Handler DiscoveryEach page will determine its handler class on first access, after being compiled. If the class changes on disk, a webapp reload is generally needed for the new class to take effect. The handler is 'discovered' by decomposing the full path of the JSP
page,
and finding a class with a matching name. Decomposition breaks the full
path
at every capital letter, or forward slash.
For example, with the page path
The class name prefix (e.g. java package name) can be regulated per parts of the site in a file called MakumbaController.properties which can be found in the CLASSPATH (just like MakumbaDatabase.properties). For example, the file can contain: /student=org.eu.best
There are good reasons to take into account the name of the response page of a form when looking for the business logic. Still, it is the name of the page that contains the form which matters not the name of the action page. It is good practice for both pages to actually have the same handler class. All methods of the handlers are http-independent. Methods are non-static, so the handler classes can use inheritance to their advantage. Still, handler classes are singletons (only one instance of a certain class in a JVM). For example, the validation of a form can be in a class that is closer to the actual JSP application (view level) while the more view-independent methods can be in the parent of that class. For example: org.eu.best.minerva.StudentHandler extends org.eu.best.StudentHandler Role of Java handlers
Handler Initialization
Whenever a handler is used in a new context (i.e.
with a different set of attributes, e.g. a new page access), a method
called
LoginLogin is done as a result of a missing attribute (possibly invoked incheckAttributes), when a find{AttributeName}
method is
called. The missing attribute is the principal that needs to log in.
If the attribute cannot be found due to wrong login information,
The principal (the person who logs in) can have more members (e.g. group, Lbg, Company representatives). E.g. the findCompany() method will check to see if the authentication (email_address and password) corresponds to any company representative of that company. If yes, it will return that company. Login can be done in 2 ways:
To cancel out a certain attribute, in order to produce a new login, the logout tag is available <mak:logout actor="student"/> You can remove (cancel-out, logout) multiple attributes from the
session by using <mak:logout actor="demo_*"/> (attributes whose names start with "demo_")
(Later on, logout request might be done in the
business logic, with a method
deleteAttributes(param)
that can accept either a String (with optional '*') or a String[]. )
(Later: to accomodate servers that don't do session tracking, login can be done by a query condition rather than by doing a query (once per session) to find an attribute. This way, it won't need to do a query (to check the authentication) at every access, but that condition will make sure that authentication is done. ) (<mak:object from="best.Student stud" where
="stud.$login()"> ...</mak:object> (Later: if an attribute has multiple values, a |