org.formaria.editor.builder.pojo
Class PojoFormBuilder

java.lang.Object
  extended by org.formaria.builder.AriaBuilder
      extended by org.formaria.builder.generic.GenericBuilder
          extended by org.formaria.editor.builder.pojo.PojoFormBuilder
All Implemented Interfaces:
PageLoader

public class PojoFormBuilder
extends GenericBuilder

A form builder based upon the GenericBuilder. The builder processes mappings using reflection to inspect the available properties of a POJO and creating a form in the process.

Copyright (c) Formaria Ltd., 2001-2007, This software is licensed under the GNU Public License (GPL), please see license.txt for more details. If you make commercial use of this software you must purchase a commercial license from Formaria.


Field Summary
protected  java.beans.BeanInfo beanInfo
           
protected  java.lang.Object pojo
           
protected  java.lang.Class pojoClass
           
protected  java.beans.PropertyDescriptor[] properties
           
 
Fields inherited from class org.formaria.builder.generic.GenericBuilder
commonAttributeMapping, componentsNodeName, decorationPanel, documentUrl, escapes, evaluator, fileExtension, formPanel, layoutManager, packageName, processors, reverseOrder, typeMap
 
Fields inherited from class org.formaria.builder.AriaBuilder
adapter, attributeSets, checkBoxGroup, componentFactory, currentAttributes, currentProject, customizer, DEFAULT_PAGE_CLASS, eventHandler, includeFileName, layoutHelper, menuBar, page, rootPage, secondaryClassloader, validationFactories
 
Constructor Summary
PojoFormBuilder(Project project)
          Create a new builder.
 
Method Summary
protected  java.lang.Object addComponent(java.beans.PropertyDescriptor pd)
          Adds an individual component element to the page (this method may be called recursively for nested elements).
protected  void addComponents(java.lang.Object page, XmlElement model)
          Adds the elements specified by the Components element and its children
protected  java.beans.PropertyDescriptor getProperty(java.lang.String name)
          Get a named property
 java.lang.String getType()
          Get the page loader type - a unique name identifying the loader
 PageSupport loadPage(java.lang.String defPackageName, java.lang.String pageName, boolean include)
          Loads an Page via a reader obtained from the Project (searches the classpath).
 PageSupport readPage(java.io.Reader reader, java.lang.String pageName, java.lang.String ext, boolean include)
          Read an XML description of the page and construct a new Page.
protected  void setupPage(XmlElement model, java.lang.String pageName, java.lang.String ext, boolean include)
          Loads the page based on the contents of the page tag or by using default values.
 
Methods inherited from class org.formaria.builder.generic.GenericBuilder
addBinding, addComponent, addVocabulary, escape, getMappedValue, getMappedValue, getUrlInputStream, init, setComponentAttributes, setStyle, setupCommonAttributeMapping, setupComponentMapping, setupFileTypeHandler, setupInstructionMapping, setupPageLayout, unescape
 
Methods inherited from class org.formaria.builder.AriaBuilder
addBinding, addBindings, addEvent, addEvents, addHandler, addMenu, addScripts, addValidations, evaluateAttribute, evaluateAttributeAsString, getCurrentAttributes, getFactoryBinding, getInt, getMenuItem, getValidationFactory, insertAttributes, loadAttributeSet, loadClass, loadFrames, loadOtherElement, loadSingleTarget, popIncludeReference, popRepeatReference, pushIncludeReference, pushRepeatReference, setAttributeEvaluator, setClassLoader, setComponentAttributes, setPackageName, setPage, setPageAttribute, setPageExtension, setPageName, setResourceBundle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pojoClass

protected java.lang.Class pojoClass

pojo

protected java.lang.Object pojo

beanInfo

protected java.beans.BeanInfo beanInfo

properties

protected java.beans.PropertyDescriptor[] properties
Constructor Detail

PojoFormBuilder

public PojoFormBuilder(Project project)
Create a new builder. An attempt is made to configure the builder with a configuration file when the builder is constructed if the configuration file is specified as part of the startup properties via the GenericBuilderConfig setting.

Parameters:
project - the current aria project
factory - the component factory
Method Detail

loadPage

public PageSupport loadPage(java.lang.String defPackageName,
                            java.lang.String pageName,
                            boolean include)
Loads an Page via a reader obtained from the Project (searches the classpath). The pageName is assumed to be the name of an Java POJO class file. For example if the pageName is 'welcome' then the 'Welcome.class' file in the default package is inspected. A full class name can be specified.

Specified by:
loadPage in interface PageLoader
Overrides:
loadPage in class GenericBuilder
Parameters:
defPackageName - the package or path to the page
pageName - the page name or the name of the class implementing the page
include - true if the page to be loaded is being included in another page in which case any class attribute of the included page is ignored
Returns:
the page

readPage

public PageSupport readPage(java.io.Reader reader,
                            java.lang.String pageName,
                            java.lang.String ext,
                            boolean include)
Read an XML description of the page and construct a new Page. An instance of the class specified by the class attribute is constructed or else an instance of Page if no class attribute is specified. The new page is populated but is not yet added to its parent.
The startup file parameter 'DefaultClass' is used to obtain a default for each page's class if a class parameter is not specified in the page's XML
The startup file parameter 'Validations' is used to obtain a default for each page's set of validation rules

Specified by:
readPage in interface PageLoader
Overrides:
readPage in class GenericBuilder
Parameters:
reader - a input stream from which to read the page
pageName - the name of the page
ext - the file extension
include - the page to be loaded is being included in another page
Returns:
the page

setupPage

protected void setupPage(XmlElement model,
                         java.lang.String pageName,
                         java.lang.String ext,
                         boolean include)
Loads the page based on the contents of the page tag or by using default values.

Overrides:
setupPage in class GenericBuilder
Parameters:
pageName - the name of the page
ext - the file extension
include - the page to be loaded is being included in another page

addComponents

protected void addComponents(java.lang.Object page,
                             XmlElement model)
Adds the elements specified by the Components element and its children

Overrides:
addComponents in class AriaBuilder
Parameters:
page - the new page object
model - the Components XML element (and implicitly its children)

addComponent

protected java.lang.Object addComponent(java.beans.PropertyDescriptor pd)
Adds an individual component element to the page (this method may be called recursively for nested elements). Several methods will be attempted until a component is successfully created. Firstly the built-in component types are checked, then any additional registered component constructors. The types can be specified by type ID, type name or class name.

Parameters:
childNode - the XML element containing the component specification.
Returns:
the new component

getProperty

protected java.beans.PropertyDescriptor getProperty(java.lang.String name)
Get a named property

Parameters:
name - the property name
Returns:
the property descriptor or null if no such named property is found

getType

public java.lang.String getType()
Get the page loader type - a unique name identifying the loader

Specified by:
getType in interface PageLoader
Overrides:
getType in class GenericBuilder
Returns:
"ifnopath"