MicroStrategy ONE

Creating a Custom Bean and Event Handler

The instructions in this topic walk you through the steps to create a custom bean and event handler using the Web Customization Editor. A plug-in, called CustomBeanSample, is provided for you with sample Java classes for a custom bean (SampleCustomBean), custom event handler (SampleCustomEventhandler), custom transform (SampleCustomTransform),  and a custom layout definition file (SampleCustomLayout), as well as a sample JSP file for the content page-section (Sample_Bean_Content).

After customization:

This customization can be accomplished using either of the following methods:

Deploying the plug-in provided with MicroStrategy SDK  

MicroStrategy SDK provides a plug-in (ZIP file) that can simply be extracted to the plugins folder to view the customization in MicroStrategy Web. The following steps guide you in locating the plug-in and deploying it.

 

  1. Access the plug-in: JSP version or ASP .NET version.

  1. Copy the plug-in to the plugins subfolder inside the MicroStrategy Web installation folder. Extract the plug-in to the plugins subfolder inside the MicroStrategy Web installation folder.
     

  2. Launch MicroStrategy Web to view the customization.
     

 Access the new page using one of the URLs below: 

J2EE environment:

http://localhost:8080/MicroStrategy/servlet/mstrWeb?evt=10000&src=mstrWeb.CustomBeanSamplePage.10000&server=ServerName&project=ProjectName

.NET environment:

http://localhost/MicroStrategy/asp/Main.aspx?evt=10000&src=Main.aspx.CustomBeanSamplePage.10000&server=ServerName&project=ProjectName

replacing ServerName and ProjectName with the appropriate values in your environment.

Using the Web Customization Editor to create a plug-in

MicroStrategy SDK provides a Web Customization Editor that can be used to create a customization plug-in. The following steps guide you in creating the plug-in and deploying it.
 

  1. Launch the Web Customization Editor

  2. Create a new plug-in and give it a meaningful name, such as  CustomBeanSample

  3. Use the Eclipse IDE to create a specialized SampleCustomEventHandler builder class. The sample, SampleCustomEventHandler.java, contains the entire code for this custom builder class.

  4. Compile SampleCustomEventHandler.java and place the class file inside the classes folder of this customization plug-in adhering to the package structure. For example: plugins\CustomBeanSample/WEB-INF/classes/com/microstrategy/sdk/samples/events

  5. Use the Eclipse IDE to create a specialized SampleCustomBean builder class. The sample, SampleCustomBean.java, contains the entire code for this custom builder class. 

  6. Compile SampleCustomBean.java and place the class file inside the classes folder of this customization plug-in adhering to the package structure. For example: plugins/CustomBeanSample/WEB-INF/classes/com/microstrategy/sdk/samples/beans.

  7. Copy Sample_Bean_Content (Sample_Bean_Content.jsp for J2EE from the CustomizationPlugins/AdvancedScenarios/CustomBeanSample/CustomBeanSample/jsp folder inside the MicroStrategy SDK installation or Sample_Bean_Content.ascx and Sample_Bean_Content.ascx.vb for .NET from the CustomizationPlugins/AdvancedScenarios/CustomBeanSample_ASP/CustomBeanSample/asp folder inside the MicroStrategy SDK installation), the sample provided for the content page-section, to the jsp /asp folder under the plug-in folder in your MicroStrategy installation directory (that is, the plugins/<plugin name> folder). For example, plugins/CustomBeanSample/jsp/Sample_Bean_Content.jsp or plugins/CustomBeanSample/asp/Sample_Bean_Content.aspx

  8. Copy SampleCustomLayout.xml, the sample code provided for the layout definition file, to the WEB-INF/xml/layouts folder under the plug-in folder in your MicroStrategy installation directory (that is, the plugins/<plugin name> folder). For example, plugins/CustomBeanSample/WEB-INF/xml/layouts

  9. Relaunch the Web Customization Editor. 

  10. Click on MicroStrategy Web Configuration inside the Application Settings view to expand the hierarchical tree. The expanded list contains all of the different settings that can be modified to perform customizations. 

  11. Right-click Styles and select Create Transform to launch the Transform Creation Wizard. On the Transform Creation Wizard, do the following:

    1. On the first wizard panel, do the following: 

      1. Click Browse... next to the Source folder text field to select the src folder and click OK

      2. Enter com.microstrategy.sdk.samples.transforms as the Package name for the transform class. 

      3. Enter SampleCustomTransform as the Name for the transform class. 

      4. Click the Add button for Interfaces and select the LayoutTransform interface. 

      5. Check the Open new style wizard checkbox. 

      6. Click Next

    2. On the second wizard panel, click Next

    3. On the final wizard panel, click Finish.

  12. The Style Creation Wizard opens. On the Style Creation Wizard, enter the following information:

    1. On the first wizard panel, do the following: 

      1. Enter SampleBeanStyle as the Style Name

      2. Enter Style for the custom bean as the Description

      3. Select SampleCustomTransform as the Transform Defn

      4. Click Next

    2. On the second wizard panel, click Next. There are no transform parameters for this sample. 

    3. On the third wizard panel, select SampleCustomLayout as the Layout Definition and click Next.:

      This is the file you saved in step 8 above.

    4. On the final wizard panel, click Finish.

  13. Click the SampleCustomTransform.java tab, and it opens in the editor. The SampleCustomTransform.java sample code, which has been provided for you, contains the entire code for this custom transform. Copy the sample code and paste it over the newly created SampleCustomTransform.java in the editor.   

  14. Save your changes. 

  15. Collapse Styles, right-click Pages, and select New Empty Page

  16. Enter CustomBeanSamplePage as the name for the page and click OK. The new empty page gets created and it opens on the right displaying the Basic Properties tab. 

  17. On the Basic Properties tab, do the following: 

    1. Change the Descriptor from "Default Page" to "Page with Custom Bean". 

    2. Clear the User must have a valid MicroStrategy Intelligence Server session to access this page checkbox to make sure that login is not required. 

  18. Expand the CustomBeanSamplePage page on the left panel, right-click on Beans, and select New Bean

  19. On the New Web Bean Creation Wizard, do the following: 

    1. Enter sb as the Name for the new bean. 

    2. Click the Fully qualified bean class radio button and choose the SampleCustomBean class. 

    3. Choose "Session" as the Persist Mode and click Next

    4. Since there are no features associated with this bean, click Next

    5. Since there is an event handler associated with this bean, select Yes, choose SampleCustomEventHandler, and click Next

    6. There is one initialization property, called "text". Select it using the >> button on the shopping cart and click Next

    7. Since there are no request properties, click Next.

    8. Click Finish 

  20. Click on the Bean Properties tab at the bottom of the page and add "Hello, SDK User!" as the value of the initialization property called "text". 

  21. On the Bean Styles tab (within the Bean Propertiestab), click the Add button on the bottom left of the pane. Add the SampleBeanStyle to the shopping cart and click OK

  22. Click on the Template Properties tab at the bottom of the page, right-click on the content page-section, and select Choose a new file. Navigate to Sample_Bean_Content (.jsp or .ascx) and select it as the new file to be used for this page-section.:

    This is the file you saved in step 7 above.

  23. Save your changes. 

  24. Launch MicroStrategy Web to view the customization. Access the new page using one of the URLs below::

    J2EE environment:

    http://localhost:8080/MicroStrategy/servlet/mstrWeb?evt=10000&src=mstrWeb.CustomBeanSamplePage.10000&server=ServerName&project=ProjectName

    .NET environment:

    http://localhost/MicroStrategy/asp/Main.aspx?evt=10000&src=Main.aspx.CustomBeanSamplePage.10000&server=ServerName&project=ProjectName

    replacing ServerName and ProjectName with the appropriate values in your environment.