MicroStrategy ONE
Rendering Beans for Display
All Web Beans used in MicroStrategy Web must be defined in the Page Configuration file. Rendering the bean for display is a two-step process. First, the bean is defined in the Page Configuration file; this can include a default style setting for the bean, a user preference for a style, or both. Second, the Web Bean is rendered on the MicroStrategy Web page that needs to display the bean content; a style can be set here as well. The page uses the MicroStrategy custom HTML tag displayBean to render the bean for display. The actual style used to display the bean can come from one of three sources:
Regardless of where the style is set, it is used to render a bean only if the transform associated with that style can be used with the type of bean specified as the value of the bean attribute in the <web:displayBean> node or the name attribute in the <web-bean> node. (Each transform is hard-coded with the type of bean to which it can be applied.) If the bean types do not match, the style can still be used to render children of the bean if they are the same type of bean that the transform uses. For example, if you add a "CustomPromptStyle" to a ReportBean, the style is applied to the PromptsBean for a report that includes prompts.
MicroStrategy SDK provides a Web Customization Editor that can be used to associate a style with a bean. See the following topics for detailed steps.
Using the style set in the code that renders the bean
If a style is specified in the styleName attribute of the <web:displayBean> node in the code that renders the bean, it takes precedence over styles set anywhere else. In the following sample code, both a default style and a user preference style are set in the Page Configuration file, but the style set in the <web:displayBean> node (FolderStyleIcon) is used.
If the style specified in the <web:displayBean> node cannot be found, the application attempts to use the default or user preference style.
It is not necessary for the style specified in the <web:displayBean> node to be included in a <style> child node of the bean in the Page Configuration file.
Page Configuration file code for defining the bean:
<web-bean name="fb" sys-bean="FolderBean" persist-mode="2">
<styles>
<style name="FolderStyleList" preference="FolderViewMode"/>
</styles>
</web-bean>
JSP code for rendering the bean:
<web:displayBean bean="fb" styleName="FolderStyleIcon" />
ASP.NET code for rendering the bean:
<web:displayBeanrunat="server"bean="fb" styleName="FolderStyleIcon" />
The code for these Custom HTML Tags remains almost identical in the J2EE and the .NET architecture except for the inclusion of the runat="server" attribute in ASP.NET code.
Using the style specified by the user preference set in the Page Configuration file
User preferences can also be instantiated to dictate how a bean is rendered since beans can use properties based on user preferences. If no styleName attribute is provided in the <web:displayBean> node and a bean has a child <style> node with a preference attribute, the style referenced by that user preference is used to render the bean. In the following sample code, because both a default style and a user preference are set in the Page Configuration file and no style is set in the <web:displayBean> node, the style referenced by the user preference, folderViewMode, is used. User preferences are stored as name/value pairs in the sys_definitions.xml in the WEB-INF/xml folder. In this example, folderViewMode is linked to a specific style.
If the style specified in the preference attribute of the <web-bean> node cannot be found, the application attempts to use the default style.
Page Configuration file code for defining the bean:
<web-bean name="fb" sys-bean="FolderBean" persist-mode="2">
<styles>
<style name="FolderStyleList" preference="folderViewMode"/>
</styles>
</web-bean>
JSP code for rendering the bean:
<web:displayBean bean="fb"/>
ASP.NET code for rendering the bean:
<web:displayBeanrunat="server"bean="fb"/>
The code for these Custom HTML Tags remains almost identical in the J2EE and the .NET architecture except for the inclusion of the runat="server" attribute in ASP.NET code.
Using the default style set in the Page Configuration file
When no styleName attribute is provided in the <web:displayBean> node and there is no preference attribute in the child <style> node of the bean in the Page Configuration file, the bean is displayed with the default style set in the name attribute. In the following sample code, because only a default style is set in the Page Configuration file and no style is set in the <web:displayBean> node, the default style (FolderStyleList) is used.
A bean can have multiple <style> nodes. If there are multiple styles and the style specified in the name attribute of the <web-bean> node cannot be found, the application attempts to use the subsequent styles until it finds one.
Page Configuration file code for defining the bean:
<web-bean name="fb" sys-bean="FolderBean" persist-mode="2">
<styles>
<style name="FolderStyleList"/>
</styles>
</web-bean>
JSP code for rendering the bean:
<web:displayBean bean="fb" />
ASP.NET code for rendering the bean:
<web:displayBeanrunat="server"bean="fb" />
he code for these Custom HTML Tags remains almost identical in the J2EE and the .NET architecture except for the inclusion of the runat="server" attribute in ASP.NET code.
See also
-
References: Custom HTML Tags Reference (for more in-depth information about using the <web:displayBean> tag)