Automatic Project Login Web Addon
I’ve noticed that in my experience, most users log into a single project. Either because there’s only one project in the environment, or because the projects are specific to their department or function and it’s the only one they have access to. With that, it’s always slightly annoyed me that a user has to login and then click to access the single project they have.
I’ve wanted to build a web addon for a long time that would automatically send a user to their project if they’ve only got access to one, but still present the normal project list to someone with access to many. I’m not very good with the Web SDK and have only done some very basic stuff, but I finally had success with this project and was able to somewhat accomplish it. It’s not perfect, and I think it could be a lot better, but I’d like to share it today because I’ve encountered a few other people who thought this feature would be useful. Also, if you are familiar with the Web SDK and think you can improve upon it, by all means please do so and drop any feedback in the comments section!
I’ll try to go step by step so that this is not only a “here’s the addon”, but a tutorial of sorts with using the Web SDK. Although I’ve done a few other Java Web SDK posts, they’re centered around using the Java components for stand alone apps, and not customizing Web functionality. I don’t think I know enough to do a comprehensive post on the subject, so here I’ll just share what I learned in this exercise.
By the way, here’s the addon if you just want it and don’t care.
Setting Up Your Environment
The addon requires some Java code that must be compiled. While some previous examples have used Eclipse, that’s actually overkill for this. Here’s a much easier way to do it:
To compile the Java Class, you must first download the JDK: http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u26-download-400750.html
Once installation is complete, the best thing to do is create a little batch file like this:
"C:Program FilesJavajdk1.6.0_26binjavac" -source 1.4 -target 1.4 -classpath "C:Program FilesCommon FilesMicroStrategyWebBeans.jar;C:Program FilesCommon FilesMicroStrategyWebObjects.jar;C:Program FilesCommon FilesMicroStrategyWebApp.jar;C:Program FilesCommon FilesMicroStrategyWebAppTransforms.jar;C:Program FilesCommon FilesMicroStrategyWebTransform.jar" -g SoloProjectLogin.java
The pause is so that you can see if there are any compilation errors. You may need to adjust the path to javac or the MicroStrategy JAR files if yours are installed in a different place.
This does require some Java code to be able to check the project count and then insert an HTML tag that will trigger the redirect:
public class SoloProjectLogin extends ProjectsTransform
public boolean isSingleProject()
ArrayList bProjects = super.getProjectsList();
boolean result = false;
if (bProjects.size() == 1)
result = true;
public void renderRedirect(MarkupOutput out)
ArrayList projects = super.getProjectsList();
ProjectInformation projectInfo = (ProjectInformation)projects.get(0); //get the first project
out.append("<meta http-equiv="REFRESH" content="0;url=Main.aspx?evt=3010&src=Main.aspx.3010&Port=0&Project=" + projectInfo.getProjectDetails().getProjectName() + "&Server=YOURSERVER&loginReq=true">");
out.append("<h3>Loading Project: " + projectInfo.getProjectDetails().getProjectName() + ". Please Wait.</h3>");
out.append("<br>If the project does not load, <a href=Main.aspx?evt=3010&src=Main.aspx.3010&Port=0&Project=" + projectInfo.getProjectDetails().getProjectName() + "&Server=YOURSERVER&loginReq=true>click here</a>.</br>");
So what happens here is our add on will extend the ProjectsTransform which normally handles loading the projects. The first function, isSingleProject I’ll use later, but it’s basically a flag that tells us if there is only 1 project, or if there are multiple projects returned. It’s important to note that this is based on the user’s security, not the actual list of projects. You may have 10 projects, but if the user only has access to 1, then this will return 1.
Next is where the actual redirect happens. In order for this to work, there are two important pieces that are required:
- The function must be named renderWhatever .. in my case, renderRedirect. It’s a requirement of the framework for later on when we call it.
- It must accept a parameter called MarkupOutput out which is how our html insert will be integrated with the web page output.
For our add on, we’ll add to this condition, like so:
One last modification to this file is to close out the open if / else tags at the bottom of the file, around this section:
Adding our Add On to the Style Catalog
Finally, we just need to modify the StyleCatalog.xml file to tell it to use our customized ProjectsTransform instead of the default one. The full plugin file will look like this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE StyleCatalog SYSTEM "styleCatalog.dtd">
<StyleCatalog description="MSTR System Style Catalog" name="MSTRStyleCatalog" version="1.1">
<TransformDefn class="com.custom.microstrategy.SoloProjectLogin" name="SoloProjectLogin"/> </TransformDefns>
<Style description="Style: Display HTML for the projects that are currently available on the servers" name="ProjectsStyle" transform="SoloProjectLogin">
<ActualParameter name="displayFlag" type="2" value="15"/>
<ActualParameter name="useStyleSorting" type="4" value="false"/>
<Layout layout_source="AppLayoutSourceFile" order="1"><![CDATA[/plugins/SoloProjectLogin/WEB-INF/xml/layouts/ProjectsLayout.xml]]></Layout>
You can download a copy of the plugin here, but you need to edit the java file to put in your IServer name, then recompile it with compile.bat.
The plugin will look something like this on the Project page: