MicroStrategy ONE

Representation of PromptEditor (View block)

As mentioned earlier, the server-side layout definition file, PromptsContainerLayout_widget.xml (available in the WEB-INF\xml\layouts\widgets folder of the MicroStrategy Web installation), creates PromptEditor (view block) and ReportInstanceModel (model block) by instantiating them from the Block Library and setting appropriate properties on them.

Based on the Model-View-Controller architectural pattern, the model is the true repository of data, while the view is simply one possible visual representation of that data.  A view's properties are applied to configure that representation, but the raw data itself typically resides in a separate model object; not in the view's properties. Thus, each view needs to be linked to a model. This is accomplished using the server-side layout definition file, PromptsContainerLayout_widget.xml, as explained below.

The PromptEditor.xml (view block) has a book property of type Block which specifies a collection of prompts as views. PromptsContainerLayout_widget.xml, sets the modelPath for this book property. The modelPath property is used to link the PromptEditor view block with the model block “promptQuestions” (defined in ReportInstanceModel model block) using the code below.

Copy
<mstrlayout:bSetProperty path="book/modelPath" value="parent/model/promptQuestions"/>

The values for the book property in the PromptEditor view block can be blocks—ViewStack (display one by one mode) or PromptQuestionViewRoll (display all prompts on single page). This value is also set in the server-side layout definition file, PromptsContainerLayout_widget.xml.

Blocks “ViewStack” and “PromptQuestionViewRoll” have a property called views of type List. Each view element in this list corresponds to a single prompt defined by a PromptQuestionView. A PromptQuestionView has two child views—SimpleAnswerView (prompt answers displayed for selection in the interactive area of the prompt editor) and ComplexAnswerView (prompt answers that cannot be displayed in the interactive area and are therefore, displayed as a string for selection). As shown in the code below, the getPromptAppBeans method gets a collection of PromptAppBean objects under PromptsContainerBean. The getPromptPageWidget method is responsible for transforming the individual PromptAppBean objects using the default style.

Copy
<mstrlayout:list id="promptIndexList" base="bean" name="getPromptAppBeans">
            <!-- Append an entry to the book "pages" list... -->
            <mstrlayout:bAppendList path="book/views" method="getPromptPageWidget">
                <mstrlayout:argument list="promptIndexList" type="com.microstrategy.web.app.beans.PromptAppBean"/>
                <mstrlayout:argument type="boolean" value="false"/> <!-- model=false; view = true -->
            </mstrlayout:bAppendList>
            <mstrlayout:next list="promptIndexList"/>
</mstrlayout:list>

The <mstrlayout:argument type="boolean" value="false"/> <!-- model=false; view = true --> line from the code shown above passes the boolean value "false" to the isDisplayingModel method of the PromptBaseLayout.xml file. PromptBaseLayout.xml then starts filling in the slot for the view block, PromptQuestionView. It renders information that is required for all individual prompts (SimpleAnswerView and ComplexAnswerView).

The final step is to serialize the client-side layout definition files. This is achieved by the following line of code.

Copy
<!-- Generate the JavaScript for the Layouts referenced in the 0th root block -->
    <mstrlayout:juilLayouts rootBlockName="PromptEditor"/>

The code above iterates through the entire block tree starting at the root block “PromptEditor”, and wherever it finds a layoutClass property that specifies the client-side layout definition file for that block, it generates the JavaScript variable from the client-side layout definition file. The JavaScript variable is used during the rendering of the view block.