|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.xoetrope.builder.XuiBuilder
public class XuiBuilder
A builder of XUI pages from an XML source. An instance of the class is setup by XApplet as a secondary page loader so that if a class file for the page is not found then an attempt is made to load the page from an XML file with the same base name.
Components, Menus, Events, Validations and Data Binding can be configured via the XML declarations.
The loading process itself relies heavily on the component factories to do the bulk of the work involved in constructing and adding components. The XPage class also performs much of the work involved in adding events and binding data.
Copyright (c) Xoetrope Ltd., 2002-2003
License: see license.txt
$Revision: 2.61 $Field Summary | |
---|---|
protected WidgetAdapter |
adapter |
protected java.util.Hashtable |
attributeSets |
protected java.lang.Object |
checkBoxGroup |
protected XStyleFactory |
componentFactory |
protected static java.util.Hashtable |
currentAttributes |
protected XProject |
currentProject |
static java.lang.String |
DEFAULT_PAGE_CLASS The default class used to instantiate a page. |
protected XAttributeEvaluator |
evaluator The default attribute evaluator. |
protected java.lang.String |
includeFileName |
protected XLayoutHelper |
layoutHelper |
protected XAppender |
menuBar |
protected java.lang.String |
packageName |
protected PageSupport |
page |
protected PageSupport |
rootPage |
protected java.lang.ClassLoader |
secondaryClassloader A secondary classloader for attempts to load classes referenced by a page |
protected java.util.Hashtable |
validationFactories |
Constructor Summary | |
---|---|
XuiBuilder(XProject project) Construct an instance of the builder with the default package set to net.xoetrope.awt |
|
XuiBuilder(XProject project, java.lang.String packageName) Construct a new builder and set the default package |
Method Summary | |
---|---|
protected void |
addBindings(PageSupport page, XmlElement model) Adds data bindings to the page. |
protected java.lang.Object |
addComponent(XmlElement childNode) 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 void |
addEvents(PageSupport page, XmlElement model) Adds the event handlers. |
protected void |
addHandler(PageSupport xpage, java.lang.Object targetComp, java.lang.String typeStr, java.lang.String name) Adds an event handler. |
protected void |
addMenu(PageSupport page, XmlElement model) Adds a menu to the application. |
void |
addMenuHandler(PageSupport xpage, java.lang.String targetStr, java.lang.String methodStr) Add a menu handler |
void |
addScripts(PageSupport page, XmlElement scriptsNode) Store the scripts in the page |
protected void |
addValidations(PageSupport page, XmlElement model) Adds validation rules to the components |
java.lang.Object |
evaluateAttribute(PageSupport page, java.lang.String attributeValue) Get the value of an attribute. |
static java.util.Hashtable |
getCurrentAttributes() Get the table of component attributes |
protected XDataBinding |
getFactoryBinding(PageSupport page, java.lang.Object compType, XModel model, XmlElement bindingNode) Try to get a binding factory to construct the binding |
protected int |
getInt(java.lang.String s, int def) Convert a string to an int or else return the default value |
protected java.lang.Object |
getMenuItem(java.lang.String name) Gets a reference to a menu object |
protected XValidationFactory |
getValidationFactory(java.lang.String validationFileName) Construct a validation factory appropriate to this builder |
protected void |
init(java.lang.String packageName) Initialize the builder |
void |
insertAttributes(XmlElement node) Insert the attributes of a named attribute set into the node |
void |
loadAttributeSet(XmlElement childNode) Process an attribute element |
protected PageSupport |
loadClass(java.lang.String className) Loads a class as the basis for a page |
void |
loadFrames(java.lang.String defPackageName, java.lang.String frameSetName, XPageDisplay pageDisplay, boolean useFrames) Loads a frameset. |
protected void |
loadOtherElement(PageSupport page, XmlElement childNode) Load any element other than the predefined node types e.g. |
PageSupport |
loadPage(java.lang.String defPackageName, java.lang.String pageName, boolean include) Loads an XPage via a reader obtained from the XProject (searches the classpath). |
protected void |
loadSingleTarget(XPageDisplay pageDisplay) Load a single target, used in case a frameset is not loaded |
PageSupport |
readPage(java.io.Reader reader, java.lang.String pageName, boolean include) Read an XML description of the page and construct a new XPage. |
static void |
registerBindingFactory(XDataBindingFactory fact) Register a data binding factory. |
void |
setAttributeEvaluator(XAttributeEvaluator e) Set the attribute evaluator object. |
void |
setClassLoader(java.lang.ClassLoader cl) Set a secondary classloader for loading the classes referenced by pages |
protected void |
setComponentAttributes(java.lang.String compType, java.lang.Object comp, java.util.Hashtable attribs) Iterate through the attributes and set the attributes for a component |
void |
setPackageName(java.lang.String defPackageName) Set the default package name. |
void |
setPageAttribute(java.lang.Object c, java.lang.String name, java.lang.String value) Get a page attribute (this version does nothing) |
protected void |
setPageName(java.lang.String pageName) Set the name of the page |
protected void |
setResourceBundle(PageSupport page, java.lang.String attribValue) Set the name of the page's resource bundle |
protected void |
setupPage(XmlElement model, java.lang.String pageName, boolean include) Loads the page based on the contents of the page tag or by using default values. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String packageName
protected XStyleFactory componentFactory
protected java.lang.Object checkBoxGroup
protected PageSupport page
protected PageSupport rootPage
protected XAppender menuBar
protected java.util.Hashtable validationFactories
protected java.util.Hashtable attributeSets
protected static java.util.Hashtable currentAttributes
protected XLayoutHelper layoutHelper
protected XProject currentProject
protected WidgetAdapter adapter
protected XAttributeEvaluator evaluator
protected java.lang.ClassLoader secondaryClassloader
protected java.lang.String includeFileName
public static final java.lang.String DEFAULT_PAGE_CLASS
Constructor Detail |
---|
public XuiBuilder(XProject project)
project
- the current projectpublic XuiBuilder(XProject project, java.lang.String packageName)
project
- the current projectpackageName
- the name of the default package e.g. net.xoetrope.awtMethod Detail |
---|
protected void init(java.lang.String packageName)
packageName
- the default componnet package or use AWT if none is specifiedpublic void setClassLoader(java.lang.ClassLoader cl)
setClassLoader
in interface XPageLoader
cl
- the class loaderpublic void setPackageName(java.lang.String defPackageName)
setPackageName
in interface XPageLoader
defPackageName
- the default package namepublic PageSupport loadPage(java.lang.String defPackageName, java.lang.String pageName, boolean include)
loadPage
in interface XPageLoader
defPackageName
- the package or path to the pagepageName
- the page name or the name of the class implementing the pageinclude
- true if the page to be loaded is being included in another page in which case any class attribute of the included page is ignoredpublic void loadFrames(java.lang.String defPackageName, java.lang.String frameSetName, XPageDisplay pageDisplay, boolean useFrames)
loadFrames
in interface XPageLoader
defPackageName
- the package or path to the pageframeSetName
- the page name or the name of the class implementing the pagepageDisplay
- the object that will display the pages and framesetuseFrames
- true to setup the frameset or false to add just a single target areaprotected void loadSingleTarget(XPageDisplay pageDisplay)
pageDisplay
- the object that will display the pages and framesetpublic PageSupport readPage(java.io.Reader reader, java.lang.String pageName, boolean include)
reader
- a input stream from which to read the pagepageName
- the name of the pageinclude
- the page to be loaded is being included in another pageprotected PageSupport loadClass(java.lang.String className) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.InstantiationException
className
- the full class namejava.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
protected void loadOtherElement(PageSupport page, XmlElement childNode)
page
- the page currently being loadedchildNode
- the xml element to processprotected void setupPage(XmlElement model, java.lang.String pageName, boolean include)
pageName
- the name of the pageinclude
- the page to be loaded is being included in another pageprotected void setResourceBundle(PageSupport page, java.lang.String attribValue)
page
- the page that owns the resourcethe
- resource bundle name, minus any extensionpublic void setPageAttribute(java.lang.Object c, java.lang.String name, java.lang.String value)
c
- the component associated with an attributename
- the attribute namevalue
- the attribute valuepublic void loadAttributeSet(XmlElement childNode)
attrElement
- the attribute elementpublic void insertAttributes(XmlElement node)
node
- the node to be modified if it has an atttributes attributepublic void setAttributeEvaluator(XAttributeEvaluator e)
e
- the new evaluatorpublic java.lang.Object evaluateAttribute(PageSupport page, java.lang.String attributeValue)
page
- the page being loadedattributeValue
- the raw value of the attributeprotected void addComponents(java.lang.Object page, XmlElement model)
page
- the new page objectmodel
- the Components XML element (and implicitly its children)protected void addEvents(PageSupport page, XmlElement model)
page
- The page that contains the response methodsmodel
- the 'events' XML elementprotected void addHandler(PageSupport xpage, java.lang.Object targetComp, java.lang.String typeStr, java.lang.String name)
xpage
- The page that contains the response methodstargetComp
- the component to which the event handler is addedtypeStr
- the type of handlername
- the name of the response methodpublic void addMenuHandler(PageSupport xpage, java.lang.String targetStr, java.lang.String methodStr)
xpage
- the owner pagetargetStr
- the name of the menu/menuItemmethodStr
- the name of teh response methodpublic static void registerBindingFactory(XDataBindingFactory fact)
fact
- the new binding factoryprotected void addBindings(PageSupport page, XmlElement model)
page
- the page to which the component/data bindings are addedmodel
- the data modelprotected XDataBinding getFactoryBinding(PageSupport page, java.lang.Object compType, XModel model, XmlElement bindingNode)
page
- the page that will own the bindingcompType
- the component typemodel
- the source data modelbindingNode
- the XML element defining the bindingprotected void setPageName(java.lang.String pageName)
pageName
- the new page name.protected java.lang.Object addComponent(XmlElement childNode)
childNode
- the XML element containing the component specification.protected void addMenu(PageSupport page, XmlElement model)
page
- the pagemodel
- the Menu XML elementprotected void addValidations(PageSupport page, XmlElement model)
page
- the pagemodel
- the Validations XML elementpublic void addScripts(PageSupport page, XmlElement scriptsNode)
page
- the current pagescriptsNode
- the scripts xml nodeprotected void setComponentAttributes(java.lang.String compType, java.lang.Object comp, java.util.Hashtable attribs)
comp
- the componentattribs
- the attributes.protected java.lang.Object getMenuItem(java.lang.String name)
name
- the name of the menu itemprotected XValidationFactory getValidationFactory(java.lang.String validationFileName)
validationFileName
- the validations file to readprotected int getInt(java.lang.String s, int def)
s
- the number as a stringdef
- the default valuepublic static java.util.Hashtable getCurrentAttributes()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |