# Request Handlers

RHCore simplifies the creation of a request handler and has a few advantages over standard approaches:

  • reduces boilerplate by abstracting away guiComponents and pageManager;
  • provides a logical place for determining whether a request handler may be executed; and
  • uses RHTemplate instead of weblingo.

# Setup

A request can be built by subclassing one of the following into your module and giving it a unique name:

  • RHTemplate::RHTemplateRequestHandler
  • RHTemplate::RHTemplateAdminRequestHandler
  • RHTemplate::RHTemplateHomeRequestHandler

These are all direct subclasses from the standard LLRequestHandler, AdminLLRequestHandler, and HomeRequestHandler.

The following features should be implemented:

  • fEnabled - set to true;
  • fFuncPrefix - something unique (such as the ospace name);
  • SetPrototype (and .fPrototype) - a list defining the parameters of the request handler; and
  • SubclassExecute() - a script with the logic of the request handler.

The following features can be toggled true or false to display the related component:

  • fEnabledFooter
  • fEnableLivelinkUI
  • fEnableMasthead
  • fEnableMenu
  • fEnableSearch

The mayPerformRequest() function can be implemented to return false if the request may not be executed for any reason (e.g., permissions, a URL parameter is invalid, etc.).

# Implementation

A bare-bones implementation of SubclassExecute() is as follows:

function Void SubclassExecute(Object prgCtx, Record request, Assoc response)

	Frame template = $RHTemplate.RHTemplate.New(prgCtx, 'rhcore/generic_properties_form.html')
	Frame context  = $RHTemplate.RHContext.New(request)

	// place your logic here

	.SetTemplate(template)
	.SetContext(context)

end

The template and context can be setup as required, and rendered by passing them to the SetTemplate and SetContext functions.

# Building a URL

Links to a request handler can be generated with the $RHCore.Utils.BuildURL() function as follows:

String url = $RHCore.Utils.BuildURL(request, <request name> [,parameters])

Parameters are passed in to match the prototype and are automatically escaped.

For example, a login page URL (which has a required nexturl parameter defined in the prototype) can be created as follows:

String url = $RHCore.Utils.BuildURL(request, 'll.getlogin', {nexturl})

This is easier than pasting the URL together using string operations.

Last Updated: 8/15/2019, 11:15:09 PM