[[#wd Lookup TitleRecipe3 ]]

Overview

Some (static) HTML pages should be showed by a new COAST project. The pages will be linked with a next and previous button. To achieve this result the following steps are performed:

  1. Add the new pages names to the main configuration (/Pages)
  2. Create a page configuration for each HTML file (Pagename.any)
  3. Extend configuration to add the image buttons configuration(FormRenderer, FieldRenderer)
  4. Extend the HTML template files refering the button renderers by name ([[#wd Lookup ...]])
  5. Adjust the Action/Page navigation map for the roles at hand (/Map)

Note: This example is much more complex than the title task implies to show more relevant features of COAST. Look at other [[#wd Lookup Recipe2 ]] for simpler ways of integrating and connecting HTML files to a COAST server using simple links.

Preconditions

  1. The config.any file exists and contains a valid COAST application configuration.
  2. We got 3 simple static HTML files - that's it.

Steps to do:

  1. Add the page names to the appropiate slot in the config.any file's Pages slot.
    [[#wd DisplayAnythingRenderer {
    	/AnythingInfo {
    		"/Pages {"
    		"	/Page {"
    		"		"FirstPage" "SecondPage" "ThirdPage""
    		"	}"
    		"}"
    	}
    }]]
    
  2. Create for every HTML file a new file PageName.any. For example with the following Content of file PageName.any:
    [[#wd DisplayAnythingRenderer {
    	/AnythingInfo {
    		"{"
    		"	/Version "PageName.any Version 1.0 1997/12/04""
    		"	/PageLayout {"
    		"		/HTML {"
    		"			/TemplateName "PageName"      #HTML filename"
    		"		}"
    		"	}"
    		"}"
    	}
    }]]
    
  3. Add a FormRenderer and an associated FieldRenderer specification for the buttons in every PageName.any file e.g.
    [[#wd DisplayAnythingRenderer {
    	/AnythingInfo {
    		"#----  Renderer Specification for Next Button ---------------------"
    		"/NextPage {"
    		"	/Form {"
    		"		/Template {"
    		"			"[[#wd Lookup NextButton ]]""
    		"		}"
    		"		/Method "GET""
    		"		/Action "GoNextPage""
    		"	}"
    		"}"
    		" "
    		" "
    		"/NextButton {"
    		"	/Button {"
    		"		/Name "submit""
    		"		/Label {"
    		"			/String {"
    		"				/Default "Next Page""
    		"			}"
    		"		}"
    		"	}"
    		"}"
    	}
    }]]
    
    [[#wd DisplayAnythingRenderer {
    	/AnythingInfo {
    		"#----  Renderer Specification for Previous Button ---------------------"
    		"/PrevPage {"
    		"	/Form {"
    		"		/Template {"
    		"			"[[#wd Lookup PrevButton ]]""
    		"		}"
    		"		/Method "GET""
    		"		/Action "GoPrevPage""
    		"	}"
    		"}"
    		" "
    		"/PrevButton {"
    		"	/Button {"
    		"		/Name "submit""
    		"		/Label {"
    		"			/String {"
    		"				/Default "Previous Page""
    		"			}"
    		"		}"
    		"	}"
    		"}"
    	}
    }]]
    
  4. Insert a ContextLookupRenderer for the buttons which should be displayed on the pages in every HTML file e.g. SecondPage.html:
    [[#wd DisplayAnythingRenderer {
    	/AnythingInfo {
    		"<html>"
    		"	<head>"
    		"		<title>"
    		"			Welcome to the COAST"
    		"		</title>"
    		"	</head>"
    		"	<body background= imagedir/backgrnd.gif >"
    		"		<center><h1>Welcome on the second page of COAST</h1></center>"
    		"		<!-- Renderers for Next/Previous buttons specified in SecondPage.any -->"
    		"		[[#wd Lookup PrevPage ]]"
    		"		[[#wd Lookup NextPage ]]"
    		"	</body>"
    		"</html>"
    	}
    }]]
    
  5. Insert the action/page map for the pages in file Role.any. For each page (or the default) the map contains a mapping from symbolic actions to pages. The default action is used if no action was specified e.g.
    [[#wd DisplayAnythingRenderer {
    	/AnythingInfo {
    		"/Map {"
    		"	# the following actions are available for all pages "
    		"	/Default {"
    		"		/Home       "FirstPage""
    		"		/GoNextPage "FirstPage""
    		"		/GoPrevPage "FirstPage""
    		"	}"
    		"	# specific action/page maps"
    		"	/FirstPage {"
    		"		/GoNextPage "SecondPage""
    		"	}"
    		"	/SecondPage {"
    		"		/GoPrevPage "FirstPage""
    		"		/GoNextPage "ThirdPage""
    		"	}"
    		"	/ThirdPage {"
    		"		/GoPrevPage "SecondPage""
    		"	}"
    		"}"
    	}
    }]]
    

Remarks

This example shows how you can build a COAST application from scratch in a simple way. In every Page.any file we had to insert a Renderer specification for the buttons. This disadvantage should be avoided. It's recommended to use a 'Shared Page-Layout', which allows to define layout rules only once and reuse them. The 'Shared Page-Layout' is descripted in recipes 4/5.

Glossary

FormRenderer, FieldRenderer, Shared Page-Layout, HTML-Templates

Related Topics