Using a Snap-In Component to Customize Themes

A snap-in theme customizer is a VL reusable part with ancestor VF_AC033O.

You specify the Id (not the name) of the snap-in in your custom VLF-ONE startup web page.

The shipped custom VLF-ONE startup web page is UF_OEXEC.

If you look at the source code you can see where you specify the theme customizer Id:

 

Note: Do not change UF_OEXEC. You will lose you changes when you upgrade or reinstall. Make your own copy.

This snap-in point is different to most other snap-ins because theme customization happens before any Framework definition is loaded.  

To learn about theme customization work through this example:

Create a reusable part with name and id MY_THEMES (say) using this source code as a starting point:

 

Begin_Com Role(*EXTENDS #VF_AC033O)

Mthroutine Name(Customize) Options(*REDEFINE)

#Sys_web.Alert Caption('MY_THEMES invoked')

EndRoutine

End_Com

 

Copy web page UF_OEXEC to create a custom web page named MY_OEXEC (say).

Set the Themecustomizerid(MY_THEMES) parameter. 

Compile MY_THEMES and MY_OEXEC

Execute MY_OEXEC and check that you see the alert:

Your redefined method Customize receives an array collection named #Themes of VF_SY170O theme objects:

Each VF_SY170O object in the collection has many properties. For example each has a symbolic name and a description.

Change MY_THEMES to use this code to see them all at start up:

 

Mthroutine Name(Customize) Options(*REDEFINE)

Define_Com Class(#prim_dc.UnicodeString) Name(#CRUnicode)

Define_Com Class(#Prim_dc.UnicodeString) Name(#AlertMessage)

#CRUnicode := (13).AsUnicodeString

For Each(#Theme) In(#Themes)

#AlertMessage += "SymbolicName=" + #Theme.SymbolicName + ", Description=" + #Theme.Description + #CRUnicode

Endfor

#AlertMessage += "Found " + #Themes.ItemCount.AsString + " themes."

#Sys_web.Alert Caption(#AlertMessage)

Endroutine

 

Recompile MY_THEMES.

Execute MY_OEXEC.

You should see something like this:

Next try this 'good taste' logic to block the use of all themes with “ORANGE” or “PURPLE” in their symbolic names:

 

Mthroutine Name(Customize) Options(*REDEFINE)

For Each(#Theme) In(#Themes)

#Theme.Enabled := #Theme.SymbolicName.Contains( "ORANGE" ).Not

If (#Theme.Enabled)

#Theme.Enabled := #Theme.SymbolicName.Contains( "PURPLE" ).Not

Endif

Endfor

Endroutine

 

Recompile MY_THEMES and execute MY_OEXEC. Log on.

The available themes list should now look like this:

Now try creating a new theme by using this code:

 

Mthroutine Name(Customize) Options(*REDEFINE)

Define_Com Class(#VF_SY170O) Name(#NewTheme) Reference(*DYNAMIC)

#NewTheme <= *New #vf_SY170O

#Themes.Insert Item(#NewTheme)

Set Com(#NewTheme) Symbolicname(MYTHEME1) Description('My First Theme') Vlwebapplicationtheme(2015Blue)

Set Com(#NewTheme.BaseTitleStyle) Normbackcolor(Red) Textcolor(white)

Endroutine

Note how the VLF theme has an associated Visual LANSA theme, in this case 20015Blue is used.

This is because VLF-ONE themes are an extension of Visual LANSA themes. 

The VLWebApplicationTheme value you supply maps into the #SYS_WEB.WebPage.Theme property so it must be a valid value or your application will fail.

Recompile MY_THEMES and execute MY_OEXEC.

Log on.

The available themes list should now look like this:

Next see what properties VF_SY170O objects have.

Select a VF_SY170O reference in your code:  

Then use F2 and look at the properties listed Details tab:

VF_SY170O objects have many properties with complex interactions.

For more details and examples make use of the VL forum at https://vlforum.lansa.com.au/.