Class M.ViewManager
Extends
M.Object.
The ViewManager manages and knows all views that are used in the application. The ViewManager is part of M.Application.
It is used by various other components (e.g. controller: switchToPage) to connect from javascript objects to their
HTML representation.
Defined in: view_manager.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Field Attributes | Field Name and Description |
---|---|
A reference to the currently displayed page.
|
|
A reference to the latest found view which is necessary for the findView() method.
|
|
Prefix for Id.
|
|
The nextId delivered to a view (used as html id attribute value) with prefix m_.
|
|
The type of this object.
|
|
Array containing all views used in the application.
|
Method Attributes | Method Name and Description |
---|---|
findView()
Searches for a certain view within a given parent view.
|
|
Returns the currently displayed page.
|
|
Returns the id for a given view.
|
|
Returns the next Id build from nextId property incremented by 1 and the prefix.
|
|
getPage()
Returns the page object from the view list array identified by its name.
|
|
getView()
Returns the view object from the view list array identified by the view's
name and its page.
|
|
getViewById(id)
Returns the view object from the view list array identified
by the value of its id attribute.
|
|
register(view)
Adds the view to the viewlist array.
|
|
setCurrentPage(page)
Sets the currently displayed page.
|
Field Detail
{Object}
currentPage
A reference to the currently displayed page.
{Object}
foundView
A reference to the latest found view which is necessary for the findView() method.
{String}
idPrefix
Prefix for Id.
{Number}
nextId
The nextId delivered to a view (used as html id attribute value) with prefix m_.
Initial state is 0, will be incremeneted by 1 on each call.
{String}
type
The type of this object.
{Object}
viewList
Array containing all views used in the application.
Method Detail
{Object}
findView()
Searches for a certain view within a given parent view. If it is found, the result
is returned. Otherwise the search algorithm checks for possible child views and then
recursively searches within these child views for the target view.
This method is mainly used by the getView() method to find a view within a page.
- Parameters:
- {Object} parentView.
- The parent view to search in.
- {String} targetView.
- The name of the view to be returned.
- Returns:
- {Object} The last found view.
{Object}
getCurrentPage()
Returns the currently displayed page.
- Returns:
- {Object} The currently displayed page.
{String}
getIdByView()
Returns the id for a given view.
- Parameters:
- {Object} view.
- The view for which the id value is wanted.
- Returns:
- {String} The id of a view object.
{String}
getNextId()
Returns the next Id build from nextId property incremented by 1 and the prefix.
The id is used as the value for the HTML attribute id.
- Returns:
- {String} The next id for a view, e.g. 'm_123' (if last id was 'm_122').
{Object}
getPage()
Returns the page object from the view list array identified by its name. If
there are multiple pages with the same name, the first result is returned.
Note: Try to use unique names for your pages!
- Parameters:
- {String} pageName.
- The name of the page to be returned.
- Returns:
- {Object} M.Page object identified by its name.
{Object}
getView()
Returns the view object from the view list array identified by the view's
name and its page. If there are multiple views with the same name on the
same page, the first result is returned.
Note: Try to use unique names for your views within the same page!
- Parameters:
- {String|Object} parentView.
- The name of the parent view or the parent view itself.
- {String} targetView.
- The name of the view to be returned.
- Returns:
- {Object} The view object from the view list identified by the view's name and the page where it's on.
{Object}
getViewById(id)
Returns the view object from the view list array identified
by the value of its id attribute.
- Parameters:
- {String} id
- Returns:
- {Object} The view object from the view list identified by id.
register(view)
Adds the view to the viewlist array.
- Parameters:
- {Object} view
- The view to be registered in the viewlist.
setCurrentPage(page)
Sets the currently displayed page.
- Parameters:
- {Object} page
- The page to be set as current page.