MicroStrategy - SDK - Request Keys



What is the purpose of the RequestKeys class?

I AM NOT SURE WHY MSTR HAS THIS CLASS OR CONCEPT, and why they or (we, SDK developers) should just not use session to store our data. Perhaps, session is for storing data across the entire sessions (including different pages), and RequestKeys is for storing or passing information from one component to another component (specific to the current request).

It is often useful to capture the content of the RequestKeys object to update the event id or path before the next URL is triggered. https://community.microstrategy.com/t5/SDK/TN32298-How-to-check-RequestKeys-content-using-MicroStrategy-Web/ta-p/183175

Can we store multiple things inside the RequestKeys object?


How can we store multiple things inside the RequestKeys object?

See the add method or the addObject method from the RequestKeys class.

How can we iterate over the keys inside the RequestKeys object?

To walk through the list of all unique names, use the getName method supplying an index from 0 to the value of getNameCount - 1.

public void preCollectData(PageComponent page) {
    RequestKeys keys = page.getAppContext().getRequestKeys();
    String name; 
    String val;

    for (int i=0; i <keys.getNameCount(); i++){
        name = keys.getName(i);
        val = keys.getValue(name);

How can we get access to the RequestKey object?

public void renderCustomKeys(MarkupOutput out){
    String name = null;
    Tag tag = getTagsFactory().newTag("br");
    ReportBean rb = getReportBean();
    AppContext ap = (AppContext)rb.getBeanContext();
    RequestKeys rkeys = ap.getRequestKeys();
    int i = rkeys.getNameCount();
    for (int j = 0; j <=i; j++) {
        name = rkeys.getName(j);

The above code show an example of how we can work with the MarkupOutput object, the Tag object, and how we can get access to the RequestKeys object if that is not immediately available.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License