A Content Server Request Handler Example - Part 4 - Data Aquisition
Data Aquisition - made by the Easy Diffusion AI

A Content Server Request Handler Example - Part 4 - Data Aquisition

Care for a practical example in Content Server applications? Here this is the ( The example) of a Categories Search, purely based on the database, not on the normal Content Server Search Server.

The Core: The Request Handler

To get the basic idea, refer my Article on LinkedIn WTF is a Request Handler in oScript?

The request handler is a pure construct of the Legacy GUI, it cannot be compared to the smartUI GUI constructs of REST/Javascript

To recap, the video for the example video is here in my LinkedIn Article A Content Server Request Handler Example - Part 1 - the Example

The Architecture is in A Content Server Request Handler Example - Part 2 - The Architecture

How to ask the database (in this example its the SQL server) is in A Content Server Request Handler Example - Part 3 - Asking the Database

The Data Aquisition

Article content
Data Aquisition - made by the Easy Diffusion AI

In this first part, lets define the Data Aquisition screen to get all data for the Search2 request handler, which will do the actual search and display the data found.

Article content

This is an internal html page with intermixed oscript (named "Weblingo").

In this page, a display of all ( for this user visible) categories should allow the user to easy select a category.

Article content

The searchphrase follows the Like-SQL syntax and covers date, text and number attributes.

How is this done?

First, lets define the request handler Search.

Assuming, you defined a module and installed it in the Content Server, the Requesthandler folder will contain all of the request handlers.

Article content
Requesthandler Folder

Request Handler Search

Article content
Search Request Handler - made vy the Easy Diffision AI

So, the first request handler is defined by

package RESTUTILS::Requesthandler

public Object Search inherits WEBLL::LLRequestHandler

	override	Boolean	fEnabled = TRUE
	override	String	fFuncPrefix = 'rm'
	override	String	fErrorPrefix = "Error searching categories"
	override	Dynamic	fHTMLFile = "rm-search.html"
	Dynamic fcatname
	Dynamic fattrnames
	Dynamic fcatid
	Dynamic falength
	Dynamic fregions
	Dynamic facounter
	Dynamic fnexturl
	Dynamic frequest        

The Search request handler is enabled, the FuncPrefix is rm. The FuncPrefix is the value you use to start the request handler, maybe on the URL or in a button.

The html file rm-search.html is used to display this pagr.

URL Example of rm-search.html

Article content

The Execute Part

Article content
Execute - made by the Easy Diffusion AI

The main part is the execute method, here the request and the prgCtx (the main authentification mechanish) is available for processing

override function Dynamic execute( Dynamic ctxin, Dynamic ctxout, Record request )
		List        catname, attrnames
		List        catid, alength, acounter
		Integer     index
		Object      prgctx        

First, lets check, if this prgCtx is path of the request.

if ( IsFeature( request, 'prgCtx' ) && IsDefined( request.prgCtx ) )
		prgCtx = request.prgCtx
end        

Then, lets ask the database on a list of categories. This means, we must autorize against the database and submit the SQL in string form

String      sql0string = "Select distinct * from catregionmap"
RecArray    regions = CAPI.Exec( prgctx.fDBConnect.fConnection, sql0string )        

The regions recarray can contain multiple names, here we want only a list of all names

Integer     lengthattributes = Length( regions )
Assoc       seen = Assoc.createassoc()
Integer     k = 1, l = 1
	for index = 1 to lengthattributes
		Record  line = regions[index]
		//already seen? first is not already seen
		Boolean checkit = .check( seen, line.Catid )
		if ( !checkit )
			catname[k] = line.catname
			catid[k] = line.catid
 			k = k + 1
			end
		( seen.( k ) ) = line.catid  // add newest catid to already seen list
	end
	// get attribute names
	k = 1
	l = 1
	Integer     counter = 0
	Integer     lenghta = 0, cat
	Integer     infield = 1
	for k = 1 to lengthattributes
		cat = catid[infield]
		Record  line = regions[k]
		if ( cat <> line.catid ) //changed
			infield = infield + 1
			cat = catid[infield]
			alength[ptr] = lenghta
			acounter[ptr] = counter
			counter = 0
			lenghta = 0
			ptr=ptr+1
		end
		if ( cat == line.catid ) //not changed
			attrnames[k] = line.attrname
			counter = counter + 1
			lenghta = lenghta + 1
		end        

Now. store all objects in local features to be used by the weblingo file

		.fcatname = catname
		.fattrnames = attrnames
		.fcatid = catid
		.fregions = regions
		.falength = alength
		.facounter = acounter
		.fnexturl = request.nexturl
		.frequest = request        

and return undefined (Standard)

	return Undefined        

One additional method: check

To extract only the distinct names, there is one method check

function Boolean check ( Assoc liste, Integer value )
		Boolean     result = FALSE
		Integer     i
		for i = 2 to Length( liste ) + 1
			if ( ( liste.( i ) ) == value )
				result = TRUE
			end
		end
		return result
	end        

Returns TRUE, if the value is already seen, FALSE if not and the value should be saved.

SubclassExecuteComponents Function to use the OpenText GUI

Article content
SubclassExecuteComponents - made by the Easy Diffusion AI

To embed our page in the OpenText Legacy GUI, there is one more function required.

  • title.SetPictogramm(supportPrefix+filename) displays the serch loupe.
  • pageManager.SetTitleString(title) sets the page title.
  • guiComponents.componentname.SetIsEnabled(TRUE|FALSE) is used to switch the specific componentname on or off

override function SubclassExecuteComponents()
	// Get the title object so we can modify it
	Object      title = .fGUIComponents.title
	// The pageManager looks after our html pages
	Object      pageManager = .GetPageManager()
	Assoc       guiComponents = .fGUIComponents
	// this is the Content Server Components
	// section(center of the page)
	Object      livelink = guiComponents.livelink
	String      supportPrefix = .Module().SupportPrefix()
	// set image in Top Left area and set alternate text
	title.SetPictogram( supportPrefix + 'search-144.png' )
	title.SetPictogramAlt( "Category Searches" )
	// set the title in the header
	title.SetTitle1( [RHDL.StartsACategorySearch] )
        // disable the search bar - default is Enabled
	guiComponents.Search.SetIsEnabled( TRUE )
	guiComponents.Footer.SetIsEnabled( TRUE )
	guiComponents.Menu.SetIsEnabled( TRUE )
	// substitute our html file for
	// the regular Content Server Components
	livelink.SetContentHTMLFile( .TemplatePrefix(), .fHTMLFile )
	// Load the components into the Components section
	pageManager.SetContentComponents( { livelink } )
	// set the HTML page title
	pageManager.SetTitleString( Str.Format( "Category Searches" ) )

	end        

The final page (file rm-search.html) looks like

Article content
Final Page


In the next article, there iwill be an overview on the weblingo file rm-search.html

To view or add a comment, sign in

More articles by Reiner Merz

Explore content categories