MicroStrategy ONE

reating and Initializing Beans during Page Execution

After the definition of the target page has been retrieved, each bean defined on the page is instantiated and initialized. Beans that need to do so restore their state from the incoming request, enabling them to be in the same state they were in when the originating request was made.

Click on any box in the diagram to see a detailed explanation of that step in page execution. Click here to return to the Overview of Page Execution.

Initializing beans involves the following steps at which customizations can be performed:

  • Creating the bean instance (<web-bean> element)

  • Setting the name of the bean and specifying how the bean's state should be saved and restored (name and persist-mode attributes of the <web-bean> element)  

  • If necessary, setting the custom event handler for the bean (event-handler attribute of the <web-bean> element)  

  • Setting initialization properties for the bean (<init-properties> child element of the <web-bean> element)
    These static default user-defined values are set before the state of the bean is restored.  

  • Restoring the state of those beans whose persist mode requires restoration

    Not all beans need to have their state saved and restored. For example, once a report has been executed and its results collected and rendered, it may be desirable to store the state of the bean for restoration on a subsequent page. This is useful for any report manipulation or if you choose to view the report in a different mode. The state of a bean appears in the request as a URL parameter whose name is that of the bean. (persist-mode attribute of the <web-bean> element)  

  • Setting request properties for the bean (<request-properties> child element of the <web-bean> element)

    These dynamic values are usually set through the request after the state of the bean is restored.  

  • Specifying the default style to be used for the bean, which will be used unless it is overridden (name attribute of the child <style> element of the <web-bean> element)

Customization

Modifying the creation and initialization of beans does not require Java programming. It requires only the customization of an XML parameter file. You modify the attributes and child elements of <web-bean> elements in page definitions in the Page Configuration file, pageConfig.xml.

Copy
<page ...>
  ...
  <web-beans>
    <web-beanname="fb"persist-mode="2" sys-bean="FolderBean"event-handler="com.microstrategy.web.app.beans.AggregatedFolderEventHandler">
      <init-properties>
        <property name="sysFolder" source="const" type="int" value="7" />
        ...
      </init-properties>
      <request-properties>
        <property name="sysFolder" source="request" type="int" value="systemFolder" />
      </request-properties>
      ...
      <styles>
        <style name="FolderViewStyle" />
      </styles>
    </web-bean>
  </web-beans>
</page>

Problem solving at this step in page execution

Errors at this stage are usually related to the web bean definition in the Page Configuration file. For example, an initialization or request property might be misspelled or an incorrect class name might have been used so that the bean cannot be created.

If an error occurs during bean initialization, an exception is thrown and an error is logged. Depending on the severity of the error, execution either continues on the current page (with or without displaying a message related to the error condition) or execution is redirected to an Error page. The error's stack trace is written to the HTML output as a comment. Depending on the debug flags that are set, other specified information is also written to the HTML output as a comment. You can use all of this information to help resolve problems that you encounter when you perform customizations. Logging information can be viewed in the log file, and the stack trace and debugging information can be viewed in the HTML source for the page. See Error Handling for a more detailed discussion of error handling in MicroStrategy Web products, and see Logging Architecture for more information about error logging.

It is a good practice to validate XML configuration and layout definition files before starting MicroStrategy Web. Eclipse and other IDEs provide a way to validate these files.

Next step in page execution

After the beans have been instantiated and initialized, the next step in page execution is processing events.

See also