[[#wd Lookup TitleRecipe1 ]]

Overview

A new page is incorporated into an existing COAST project, using an already defined superpage by the following steps:

Preconditions

  1. The config.any file exists and contains a valid COAST application configuration.
  2. There exists an appropriate and valid "super page" with a corresponding configuration file "SuperPage.any" (e.g. Page.any for pages instantiated from class Page)
  3. There is already a HTML template file "SharedPageTemplate.html" file that defines the general layout of our new page. For the example the SharedPageTemplate.html looks like this:
    [[#wd DisplayAnythingRenderer {
    	/AnythingInfo {
    		"<html>"
    		"	<head>"
    		"		<title>"
    		"			[[#wd Lookup PageTitle ]]"
    		"		</title>"
    		"	</head>"
    		"	<body background= imagedir/backgrnd.gif >"
    		"		[[#wd Lookup Header ]]"
    		"		[[#wd Lookup Body ]]"
    		"		[[#wd Lookup Footer ]]"
    		"	</body>"
    		"</html>"
    	}
    }]]
    
Explanation: This HTML template file defines several places for COAST to fill in. Each of these places is specified using the macro-extension mechanism with a pair of double square brackets ([[#wd ... ]]). The #wd specifies this as a COAST macro. The rest of the macro is a Renderer specification. This can be given literally using the renderer name (Image) and an Anything defining the renderers parameters. Note that Lookup stands short for ContextLookupRenderer, which in turn looks in the context for a renderer specification with the given name (e.g. Footer). These renderer specifications are to be given by the derived pages configuration files.

Steps to do:

  1. Add the page name to the appropriate slot in the config.any file's /Pages slot. This structure allows you to define multiple pages to be derived from a single C++ class derived from class Page. These pages share the same program code but differ in their configuration. In addition the configurations of such derived pages are also "inherited". That allows you to specify new pages by just giving the differences in configuration regarding the "super page". In our example the new page named InfoPage is given as an instance of the Page (C++-)class:
    [[#wd DisplayAnythingRenderer {
    	/AnythingInfo {
    		"{"
    		"	/Pages { # define the hierarchy of pages in the application"
    		"		/Page { # define subordinate configurations"
    		"			"InfoPage" #there may be some more derived pages here"
    		"		}"
    		"}"
    	}
    }]]
    
  2. Create a new configuration file for the page added (named InfoPage.any). Define all the page dependend Renderer specifications that are used by the HTML template used for your page (SharedPageTemplate.html in the example). Because page configurations are "inherited" you might rely on renderer configurations already given by the "super page". For example the PageTitle and Body are specific to InfoPage, whereas the other Renderer specifications (Header, Footer) are taken from Page.any. The resulting file InfoPage.any might look like:
    [[#wd DisplayAnythingRenderer {
    	/AnythingInfo {
    		"{"
    		"	/PageTitle "This is the Info Page""
    		"	/Body {"
    		"		/Form {"
    		"			/Template {"
    		"				"Hello - This is my InfoPage""
    		"				"[[#wd Lookup GoBackButton ]]""
    		"			}"
    		"			/Method "GET""
    		"			/Action "GoFirstPage""
    		"		}"
    		"	}"
    		" "
    		"#---- Parts ----------------------------------------------------------------"
    		" "
    		"	/GoBackButton {"
    		"		/Button {"
    		"			/Submit"
    		"			/Label {"
    		"				/String {"
    		"					/Default "Return to FirstPage""
    		"				}"
    		"			}"
    		"		}"
    		"	}"
    		"}"
    	}
    }]]
    
  3. Update the role specific navigation maps for the new page in the configuration files of each role you want to grant access to your page. The navigation maps are normally located in a role's config file "Rolename.any". The navigation map specifies two aspects:
    1. The action name that will result in retrieving the new page from a special page
      (/FirstPage {
          /GoInfoPage "InfoPage"
      }
      )
    2. The valid (non-default) actions for the role, once your new page was reached (/InfoPage {
          /GoFirstPage "FirstPage"
      }
      ).

    Note: The actions given here are simple names specifying config entries and the resulting new pages' names. For actions that have side effects and more functionality see another Receipe.

    For example Role.any contains:

    [[#wd DisplayAnythingRenderer {
    	/AnythingInfo {
    		"/Map {"
    		"	# the following actions are available for all pages "
    		"	/Default {"
    		"		/Home "IntroPage""
    		"	}"
    		" "
    		"	/FirstPage {"
    		"		/GoNextPage     "SecondPage""
    		"		/GoInfoPage     "InfoPage""
    		"		/GoAnotherPage "AnotherPage""
    		"	 }"
    		" "
    		"	/InfoPage {"
    		"		# additional actions and their resulting pages"
    		"		/NextStep        "FirstPage""
    		"		/GoFirstPage    "FirstPage""
    		"	 }"
    		"	 #... other pages navigation maps"
    		"}"
    	}
    }]]
    

Remarks

Glossary

Related Topics