com.vinay.ui.vinui.fw.core
Class Page

java.lang.Object
  extended bycom.vinay.ui.vinui.fw.core.Page

public abstract class Page
extends java.lang.Object

Represents a logical page. An application can be divided into several pages each of which hosts a set of controls. Navigation can be defined between pages. A default page exists for each application which is rendered initially. Each page has an associated layout manager which can be set before adding the controls.
A page also has a context available. Certain control properties e.g. text can be bound to the page context attributes. Modification of context attributes result in control UI changes.
The page context attributes can be optionally mapped to the application context attributes. In this case, the control properties are indirectly bound to the application context(or its attributes). This can be useful in cases where an action on a control in a page can affect a UI element belonging to a different page.

Author:
Vinay Nath

Constructor Summary
Page(java.lang.String name)
          Page Constructor
 
Method Summary
protected  void addControl(Control control)
          Adds a UI Control to the page.
protected  void addControl(Control control, int position)
          Adds a UI Control to the page.
protected  void addControlToGroup(Control control, UIGroup group)
          Add a UI control to a valid UIGroup within this page
protected  Control getControl(long id)
          Returns a Control with a given id
protected  java.util.Map getControls()
          Returns the map of controls hosted in this page
 long getId()
           
protected  Layout getLayout()
           
 java.lang.String getName()
           
protected  Context getPageContext()
          Returns the context object of this page
 UIRendererFactory getRendererFactory()
           
 java.lang.String getRenderType()
           
protected abstract  void init()
          Page Initialization.
protected  void mapAttribute(java.lang.String contextAttribute, java.lang.String appContextAttribute)
          Maps a page context attribute to application context attribute.
protected  void mapToApplicationContext()
          Maps the entire page context to application context.
protected abstract  void modifyPage()
          Invoked just before rendering the page.
protected  void navigateTo(java.lang.String pageName)
          Creates a navigation rule typically defined in an action listener.
protected  boolean process(java.lang.String controlId, java.lang.String eventType)
           
protected  void removeControl(Control control)
          Removes a given control from the page
protected  java.lang.String render()
           
protected  void setLayout(Layout layout)
          Set the Layout of the page.
protected  void setName(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Page

public Page(java.lang.String name)
Page Constructor

Method Detail

init

protected abstract void init()
Page Initialization. Invoked only once when the page is requested for the first time Layouts and controls can be defined here. Context can be initialized here. External resources can be initialized.


modifyPage

protected abstract void modifyPage()
Invoked just before rendering the page. Modifications to the page/controls can still be done here.


getPageContext

protected Context getPageContext()
Returns the context object of this page

Returns:
context object of this page

navigateTo

protected void navigateTo(java.lang.String pageName)
Creates a navigation rule typically defined in an action listener. Navigation can be defined to a page which is already created.

Parameters:
pageName - a valid page name.
See Also:
Application.addPage(Page)

getId

public long getId()

getRenderType

public java.lang.String getRenderType()

getRendererFactory

public UIRendererFactory getRendererFactory()

getControls

protected java.util.Map getControls()
Returns the map of controls hosted in this page

Returns:
Returns the controls.

getControl

protected Control getControl(long id)
Returns a Control with a given id

Parameters:
id - the Control id
Returns:
Control if it exists, else null

addControl

protected void addControl(Control control)
Adds a UI Control to the page. The default layout is FlowLayout

Parameters:
control - the UI Control to add
Throws:
java.lang.NullPointerException - if argument is null

addControl

protected void addControl(Control control,
                          int position)
Adds a UI Control to the page. The position parameter has significance only when an appropriate layout was already set on the page.

Parameters:
control - the Control to be added
position - the position defined by layout
Throws:
java.lang.NullPointerException - if control argument is null

addControlToGroup

protected void addControlToGroup(Control control,
                                 UIGroup group)
Add a UI control to a valid UIGroup within this page

Parameters:
control - the Control to be added
group - the UIGroup to which the control needs to be added

removeControl

protected void removeControl(Control control)
Removes a given control from the page

Parameters:
control - the Control to be removed

process

protected boolean process(java.lang.String controlId,
                          java.lang.String eventType)

render

protected java.lang.String render()
                           throws VinUIException
Throws:
VinUIException

getName

public java.lang.String getName()

setName

protected void setName(java.lang.String name)
Parameters:
name - The name to set.

mapAttribute

protected void mapAttribute(java.lang.String contextAttribute,
                            java.lang.String appContextAttribute)
Maps a page context attribute to application context attribute. The value of the page context attribute is derived from that of the application

Parameters:
contextAttribute - the page context attribute
appContextAttribute - the application context attribute

mapToApplicationContext

protected void mapToApplicationContext()
Maps the entire page context to application context. FIXME Not mature


getLayout

protected Layout getLayout()

setLayout

protected void setLayout(Layout layout)
Set the Layout of the page. There can be only one master layout. The default is FlowLayout. For other layouts, the layout needs to be set before adding controls. Else the results are unpredictable.

Parameters:
layout - the Layout to be set