[[#wd Lookup TitleRecipe20 ]]

Overview

Most of the pages shown on the WWW contain tables. Since this is a very practical and well known format, we support it with COAST. We differ two kind of tables. Fixed size tables when you know the layout in advance and dynamically sized tables. The second case is the more interesting and we will concentrate on this one in the next steps.

Preconditions

Steps to do:

  1. Define a static HTML-Table with some sample data. Try out formatting and layout options.
    Sample:
    [[#wd DisplayAnythingRenderer {
    	/AnythingInfo {
    		"<table border=0>"
    		"<tr>"
    		"	<th>Account-No</th><th>Name</th><th>Currency</th>"
    		"</tr>"
    		"<tr valign=top>"
    		"	<td>123456</td><td align=right>Tax</td><td>CHF</td>"
    		"</tr>"
    		"<tr valign=top>"
    		"	<td>546123</td><td align=right>Savings</td><td>CHF</td>"
    		"</tr>"
    		"<tr valign=top>"
    		"	<td>987456</td><td align=right>Loan</td><td>USD</td>"
    		"</tr>"
    		"</table>"
    	}
    }]]
    
  2. Define the needed layout and variable formatting options. With this information you can fill in a first version of a list renderer specification into the Ex4Page.any file where you want to show the table.
    Assume you have account records to display with n-fields. You want to display three of them KTOST, KTOBEZ, WHRC, which are the field identifier in the record. The specification has the following structure shown by the example:
    [[#wd DisplayAnythingRenderer {
    	/AnythingInfo {
    		"/DataContents {"
    		"	"<table border=1 cellpadding=3 cellspacing=0>"   # HTML definitions for table with"
    		"	"<tr bgcolor=#BEBEBE><th>"                       # specific options"
    		"	"Konto</th><th>"                                 # Headers of the table"
    		"	"Kontobezeichnung</th><th>""
    		"	"Währung</th></tr>""
    		"	{"
    		"		 /List { "
    		"			 /ListName  AccountData					# data source"
    		"			 /EntryStore ActualData					# temporary stored at"
    		"			 /EntryHeaders {"
    		"						"<tr bgcolor=#FFFAFA>""
    		"						"<tr bgcolor=#D3D3D3>""
    		"					}"
    		"			 /EntryRenderer {						# renderer for the columns"
    		"				"<td>""
    		"				{/Lookup ActualData.KTOST}"
    		"				"</td><td>""
    		"				{/Lookup ActualData.KTOBEZ}"
    		"				"</td><td>""
    		"				{/Lookup ActualData.WHRC}"
    		"				"</td></tr>""
    		"			 }"
    		"		}"
    		"	}"
    		"	"</table>""
    		"}"
    	}
    }]]
    
    Be aware, that this is a complex specification and allows for a lot of customization through self made renderers in the body of the cell specifications.

  3. Define the source of your data. It might be the case that you have some sort of data access to a transaction system (e.g. a data base). In the preprocessing of the page you have to access this data and put all the needed records into the TmpStore of the Context.
    Sample:
    [[#wd DisplayAnythingRenderer {
    	/AnythingInfo {
    		"void Ex4Page::Preprocess(Context &c)"
    		"{"
    		"	Anything tmpStore=	c.GetTmpStore();"
    		" "
    		"	// get some data probably from a Host Transaction"
    		"	// Transaction::ExecTransaction(c,  "AccountAccess ", input, output);"
    		"	"
    		"	// get for recipe 20 some data from a file in Anything-format"
    		"	Anything input;"
    		"	iostream *is = System::OpenStream(  "AccountData.any ", 0 );"
    		"	if ( is != 0 ) {"
    		"		// opened ok; now read the content, close the file and store the data in tmpStore"
    		"		input.Import(*is);"
    		"		delete is; is = 0;"
    		"		"
    		"		tmpStore[ "AccountData "] = input;"
    		"	}"
    		"}"
    	}
    }]]
    

Remarks

See renderer specifications
See page preprocess

This renderer is supposed to be changed and adapted to your needs!!

Glossary

Related Topics

See more renderers and especially the list renderer.