Advanced Techniques - Control dynamic edit pages with request values

This workshop shows you how an edit page can be designed dynamically using request values. An understanding of the expert mode is an advantage. The example application for this workshop can be downloaded here and imported into your portal as usual. Make sure the expert options have been activated so that all of the dialogs explained in this example are available.



This is the edit page of the example application. The "City" field is a mandatory field. The page heading should be generated dynamically.



On the "All entries" page, the buttons "Internal appointment" and "External appointment" are configured to transfer the appointment type "Internal" or "External", respectively, as a request value to the edit page when a new appointment is created using one of these buttons. This behavior is controlled with the expert attribute "rq_custType".



The "Internal appointment" button has the attribute "rq_custType" with the value "Internal", the "External appointment" button has the attribute "rq_custType" with the value "External". The attribute name is free choice - the prefix "rq_" ensures that the attribute is interpreted as a request value and transferred to the opened page accordingly.



The expert attribute "customdefault" is used to automatically enter the appointment type on the edit page. The request value can be read using the following value:
$Request.get('rq_custType')


The "City" field should only be shown on the edit page, if the user is defining an external appointment. This behavior is controlled using a Grouping that is only shown under certain conditions. In the properties dialog of the grouping, the option Display if condition met has been activated on the Options tab. The following script is defined here:
#if($Request.get('rq_custType') == 'Internal')
	#set($show_simplegroupAC182D08 = false)
#elseif($Request.get('rq_custType') == 'External')
	#set($show_simplegroupAC182D08 = true)
#end
If the name of your grouping is different, you need to adjust it to your application. The script means that the grouping, which contains the "City" field, is not should, if the request value is "Internal". The grouping is shown if the value is "External".



If the edit page is opened via the "Edit page" link in the application menu, a request value is not transferred. Because the appointment type cannot be filled in automatically, every element apart from the heading should be hidden. This is done by grouping the elements together and defining the following script in the conditional display:
#if($Request.get('rq_custType') || $DC.getRecId() != -1)
	#set($show_simplegroup9BA104CE = true)
#else
	#set($show_simplegroup9BA104CE = false)
#end
Using the record ID -1 means that the grouping is shown if an existing data record is opened - e.g. via the view table on the "All entries" page. New data records that have not been saved yet have the record ID -1. The dynamic display of the page heading is controlled using a static text element with the setting "Programming, language dependent" on the Options tab.



The following script has been defined here:
## Determine page heading with VTL
#if($Request.get('rq_custType') == 'Internal')
	Internal appointment
#elseif($Request.get('rq_custType') == 'External')
	External appointment
#elseif($DC.getRecId() != -1)
	Edit appointment
#else
	You have opened this page from an unauthorized link 
#end
The page heading will therefore be displayed as follows: So that the city can be edited for existing records, the script in the conditional display of the grouping, which the "City" field is contained in, and its title can be modified as follows:
#if($Request.get('rq_custType') == 'Internal')
	#set($show_simplegroupAC182D08 = false)
#elseif($Request.get('rq_custType') == 'extern' || $DC.getValueHolder('textcontrol4A4C39CA').getValue() == 'External')
	#set($show_simplegroupAC182D08 = true)
#end
In the script, the value of the "Appointment type" field is checked and the grouping is affected accordingly. Please note that you may need to adjust the name of the grouping or the "Appointment type" in the script depending on your application.