Instantly share code, notes, and snippets.

Embed
What would you like to do?
LANSA Tour Of Heroes Pt 2 Application Controller
function options(*DIRECT)
begin_com role(*EXTENDS #PRIM_OBJT)
* =====================================================================================
* COMPONENTS
* =====================================================================================
define_com class(#PRIM_KCOL<#PRIM_ALPH #STD_STRNG>) name(#mParameters)
* =====================================================================================
* PROPERTIES
* =====================================================================================
* =====================================================================================
* EVENTS
* =====================================================================================
* =====================================================================================
* ROUTINES
* =====================================================================================
mthroutine name(NavigateTo)
define_map for(*INPUT) class(#PRIM_ALPH) name(#pViewId)
* copy known query parameters to the navigation parameters
for each(#lParameter) in(#SYS_WEB.URLParameters)
case of_field(#lParameter.Name.UpperCase)
when (= TRACE)
#mParameters<#lParameter.Name> := #lParameter.Value
when (= DEVELOPER)
#mParameters<#lParameter.Name> := #lParameter.Value
when (= DEBUG)
#mParameters<#lParameter.Name> := #lParameter.Value
endcase
endfor
* add the view to the parameters collection
#mParameters<VIEW> := #pViewId
* finally replace the querystring to trigger the view change
#SYS_WEB.History.Add( #COM_OWNER.BuildQueryString.LowerCase )
#mParameters.RemoveAll
endroutine
mthroutine name(AddURLParameter)
define_map for(*INPUT) class(#PRIM_ALPH) name(#pKey)
define_map for(*INPUT) class(#PRIM_ALPH) name(#pValue)
#mParameters<#pKey> := #pValue
endroutine
mthroutine name(GetURLParameter)
define_map for(*INPUT) class(#PRIM_ALPH) name(#pParameter)
define_map for(*RESULT) class(#PRIM_ALPH) name(#pValue)
if (#SYS_WEB.URLParameters<#pParameter> *IsNot *NULL)
#pValue := #SYS_WEB.URLParameters<#pParameter>.Value
else
#pValue := *BLANKS
endif
endroutine
mthroutine name(BuildQueryString) access(*PRIVATE)
define_map for(*RESULT) class(#PRIM_ALPH) name(#pString)
for each(#lParameter) in(#mParameters)
if (#pString <> "")
#pString += "&" + #mParameters.KeyOf<#lParameter> + "=" + #lParameter
else
#pString := #mParameters.KeyOf<#lParameter> + "=" + #lParameter.Value
endif
endfor
endroutine
end_com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment