Context Framework
Encyclopedia
The Context Framework is an open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...

 component based web framework
Software framework
In computer programming, a software framework is an abstraction in which software providing generic functionality can be selectively changed by user code, thus providing application specific software...


for the Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

 platform and it has similarities with Apache Wicket and Lift.

Design

The goal of Context is to create a flexible and lightweight framework based on XSLT
XSLT
XSLT is a declarative, XML-based language used for the transformation of XML documents. The original document is not changed; rather, a new document is created based on the content of an existing one. The new document may be serialized by the processor in standard XML syntax or in another format,...

-templating language. All pages are a tree of components (including the page-component ifself) and during rendering they form a single DOM-tree that is transformed into XHTML. The choice creates a sharp separation between logical representation and physical representation and only very little logic is possible to present on XSLT-templates.

Second aspect is that all interaction and page updates are javascript based. For instance traditional form-submits are not encouraged, however they are possible if needed. Third, the component-model is designed in such way that each component is able to update their content independently from other components. This enables complex interaction between page components.

Pages themselves are normally made of multiple views that are nested. With this approach the outer views can concentrate to general content such as HTML-decrations or menus. Outer views also generate a natural perimeter for authentication so that only authenticated users are allowed to access inner views.

Framework is also highly stateful, where each page instance has their own state on server. This is called a page scope. The goal was to create page state in such manner that it does not interfere with having multiple open pages on same site. A speciality for mainting the page scopes is that no cookies or session is used.

Even if framework is considered stateful, creating new pages is lightweight operation thus making Context suitable for small sites or large web applications.

Context support full live class reloading to pages and their components during development mode. It allows new set of compiled classes to be loaded into system during page loads thus minimizing the need for complete system restarts. The live class reloading can be extend singletons-scoped instances if designed carefully.

Example

A Hello World view, containing two files:

HelloWorldView.java
The Java-component for the page


@PageScoped
@View(url="/helloworld", parent=OuterView.class)
public class HelloWorldView extends Component {

@Attribute
private Date currentTime = new Date;

}


When rendered this component translates into following DOM-tree snippet:





HelloWorldView.xsl
The template for the view






Hello World!



Current date is:






External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK