MicroStrategy ONE
Layout Definitions for Rendering Prompts
In MicroStrategy Web versions prior to 8.0.2, the layout definition files for individual prompt styles included general prompt components such as title, summary, and restrictions, in addition to components specific to that prompt style. In MicroStrategy Web version 8.1.x, prompt-related layout definition files have been greatly enhanced for ease of customization. All common prompt display components such as title, summary, and restrictions have been extracted from individual prompt-related layout definition files and placed in a single prompt template layout definition file. All individual prompt-related layout definition files have the ability to include this template layout definition file. The result is that to customize a common prompt display component in 8.1.x such as a title, you need to make the customization in only one file— the prompt template layout definition file— and the customization is reflected in all the prompt styles.
The template layout definition file for rendering prompts is called PromptObjectLayout.xml. It is located in the WEB-INF/xml/layouts folder of the MicroStrategy installation directory. This folder also includes other prompt-related layout definition files such as PromptCheckboxLayout.xml for rendering prompts in a checkbox style, PromptRadioLayout.xml for rendering prompts in a radio button style, and PromptListboxLayout.xml for rendering prompts in a listbox style. For a complete list of the available elements in a layout definition, see the Layout Definition Elements Reference.
To make use of this enhancement, Individual prompt-related layout definition files must have the ability to include the template layout definition file (which provides the XML code for rendering common prompt display components) and ability to display prompt components specific to their own particular prompt styles (provided by their own prompt-specific XML code). This is accomplished by using the following MicroStrategy custom tags:
MicroStrategy custom tag | Description |
---|---|
include |
Instructs an layout definition file (in this case, an individual prompt-related layout definition file) to include the XML code from another layout definition file (in this case, the prompt template layout definition file). |
replace |
Specifies the block of XML code in a layout definition file (in this case, an individual prompt-related layout definition file) that should be inserted into the included layout definition file (in this case, the prompt template layout definition file).
|
slot
|
Specifies the location in a layout definition file (in this case, the prompt template layout definition file) where XML code from another layout definition file (in this case, the prompt-style specific XML from an individual prompt-related layout definition file) should be inserted.
|
While the elements in the table above are used specifically with prompt-related layout definition files, they can be used by any layout definition file.
The manner in which this technique is implemented by the application is described below, using code from the PromptCheckboxLayout.xml file as an example.
This explanation is provided simply to help you understand what the application does and does not describe anything that you must do manually.
-
The individual prompt-related layout definition file (PromptCheckboxLayout.xml) has a root <mstrlayout:layout> node, which has a child <mstrlayout:include> node. The file attribute of this child node specifies the external layout definition file whose entire XML contents (within that file's own <mstrlayout:layout> node) should be added to the individual prompt-related layout definition file at the point of the <mstrlayout:include> tag. In the code sample below, the external layout definition file to be included is the prompts template layout definition file, PromptObjectLayout.xml.
<!DOCTYPE mstrlayout:layout SYSTEM "mstrlayout.dtd">
<mstrlayout:layout>
<mstrlayout:include file="/WEB-INF/xml/layouts/PromptObjectLayout.xml">
...
</mstrlayout:include>
</mstrlayout:layout>
-
All of the XML code inside the <mstrlayout:layout> node of the external layout definition file (PromptObjectLayout.xml) is inserted into the original layout definition file (PromptCheckboxLayout.xml) at the point of the <mstrlayout:include> tag.
<!DOCTYPE mstrlayout:layout SYSTEM "mstrlayout.dtd">
<mstrlayout:layout>
<mstrlayout:if name="isPromptSummaryEnabled">
<mstrlayout:then>
<mstrlayout:render name="promptSummaryTitle"/>
<mstrlayout:render name="promptSummaryAnswer"/>
</mstrlayout:then>
<mstrlayout:else>
<div class="titleBar">
<mstrlayout:render name="promptTitle"/>
<mstrlayout:render name="promptBackToTopAnchor"/>
</div>
<mstrlayout:render name="promptErrorMessage"/>
<mstrlayout:render name="promptMeaning"/>
<mstrlayout:render name="promptRestrictions"/>
<mstrlayout:if name="areThereAvailableSelections">
<mstrlayout:then>
<mstrlayout:slot name="s1"/>
</mstrlayout:then>
<mstrlayout:else>
<mstrlayout:render name="promptNoSelectionsAvailable"/>
</mstrlayout:else>
</mstrlayout:if>
<mstrlayout:if name="isAnswerComplex">
<mstrlayout:then>
<mstrlayout:render name="promptDefaultAnswer"/>
</mstrlayout:then>
</mstrlayout:if>
<mstrlayout:render name="promptHiddenInputs"/>
</mstrlayout:else>
</mstrlayout:if>
</mstrlayout:layout>
The inserted code has a <mstrlayout:slot> tag (indicated in bold red in the code sample above), specifying the place where a section of XML code from another layout definition file should be inserted. The name attribute of the <mstrlayout:slot> tag identifies the particular slot.
-
The individual prompt-related layout definition file (PromptCheckboxLayout.xml) has a child <mstrlayout:replace> node of the <mstrlayout:include> node. The slot attribute of this <mstrlayout:replace> node specifies the section of XML code that should be inserted at the point of the <mstrlayout:slot> tag.
<!DOCTYPE mstrlayout:layout SYSTEM "mstrlayout.dtd">
<mstrlayout:layout>
<mstrlayout:include file="/WEB-INF/xml/layouts/PromptObjectLayout.xml">
<mstrlayout:replace slot="s1">
<div class="prmCheckbox">
<mstrlayout:list id="prompt" name="getPromptsList">
<div>
<mstrlayout:render name="promptCheckbox">
<mstrlayout:argument list="prompt" type="com.microstrategy.web.objects.WebDisplayUnit"/>
</mstrlayout:render>
<mstrlayout:render name="displayNameLabel">
<mstrlayout:argument list="prompt" type="com.microstrategy.web.objects.WebDisplayUnit"/>
</mstrlayout:render>
<mstrlayout:next list="prompt"/>
</div>
</mstrlayout:list>
<div class="mstrSpacer"/>
</div>
</mstrlayout:replace>
</mstrlayout:include>
</mstrlayout:layout>
-
After including and replacing the appropriate code, the XML code for the PromptCheckboxLayout would look like the code sample below:
<!DOCTYPE mstrlayout:layout SYSTEM "mstrlayout.dtd">
<mstrlayout:layout>
<mstrlayout:if name="isPromptSummaryEnabled">
<mstrlayout:then>
<mstrlayout:render name="promptSummaryTitle"/>
<mstrlayout:render name="promptSummaryAnswer"/>
</mstrlayout:then>
<mstrlayout:else>
<div class="titleBar">
<mstrlayout:render name="promptTitle"/>
<mstrlayout:render name="promptBackToTopAnchor"/>
</div>
<mstrlayout:render name="promptErrorMessage"/>
<mstrlayout:render name="promptMeaning"/>
<mstrlayout:render name="promptRestrictions"/>
<mstrlayout:if name="areThereAvailableSelections">
<mstrlayout:then>
<div class="prmCheckbox">
<mstrlayout:list id="prompt" name="getPromptsList">
<div>
<mstrlayout:render name="promptCheckbox">
<mstrlayout:argument list="prompt" type="com.microstrategy.web.objects.WebDisplayUnit"/>
</mstrlayout:render>
<mstrlayout:render name="displayNameLabel">
<mstrlayout:argument list="prompt" type="com.microstrategy.web.objects.WebDisplayUnit"/>
</mstrlayout:render>
<mstrlayout:next list="prompt"/>
</div>
</mstrlayout:list>
<div class="mstrSpacer"/>
</div>
</mstrlayout:then>
<mstrlayout:else>
<mstrlayout:render name="promptNoSelectionsAvailable"/>
</mstrlayout:else>
</mstrlayout:if>
<mstrlayout:if name="isAnswerComplex">
<mstrlayout:then>
<mstrlayout:render name="promptDefaultAnswer"/>
</mstrlayout:then>
</mstrlayout:if>
<mstrlayout:render name="promptHiddenInputs"/>
</mstrlayout:else>
</mstrlayout:if>
</mstrlayout:layout>
See also: