com.ibm.mashups.enabler.model.state
Interface NavigationStateProcessor


public NavigationStateProcessor

Interface representing NavigationStateProcessor.NavigationState is internally Represented as an JSON object.
Paramters are predefined.
{
sid: {
  value: <sid>,
  params: { }
},
pid: {
  value: <pid>,
  params: { }
},
pageselection: {
  <spaceid>: {
    value: <pageid>,
    params: { lm:<timestamp>}
  },
  <spaceid>: {
    value: <pageid>,
    params: { lm:<timestamp>}
  }
},
wparams: {
  <wid>: {
    value: {
      rp: { w:<"200">,h:<"300">,st:<"NORMAL">},
      cp: { <page:"3">}
    },
    params: { lm:<timestamp>}
  },
  <wid>: {
    value: {
      rp: { w:<"300">,h:<"400">,st:<"MAX">},
      cp: { <page:"4">}
    },
    params: { lm:<timestamp>}
  }
},
lcparams: {
  <pid>: {
  templateURL: "<dav:filestore/layout-templates/2ColumnEqual>", {
    value: {
      <lcid>: {
        value: {
          rp: { w:<"70%">}
        }
      },
      <lcid>: {
        value: {
          rp: { w:<"30%">}
        }
      }
    },
    params: { lm:<timestamp>}
  },
  <pid>: {
  templateURL: "<dav:filestore/layout-templates/3ColumnEqual>", {
    value: {
      <lcid>: {
        value: {
          rp: { w:<"30%">}
        }
      },
      <lcid>: {
        value: {
          rp: { w:<"30%">}
        }
      },
      <lcid>: {
        value: {
          rp: { w:<"40%">}
        }
      }
    },
    params: { lm:<timestamp>}
  }
},
sparams: {
  <id>: {
    global: {
      params: { lm:<timestamp>},
      value: {
        <name>: {
          value: <value>,
          params: { lm:<timestamp>}
        },
        <name>: {
          value: <value>,
          params: { lm:<timestamp>}
      }
    },
    <scope-id>: {
      params: { lm:<timestamp>},
      value: {
        <name>: {
          value: <value>,
          params: { lm:<timestamp>}
        },
        <name>: {
          value: <value>,
          params: { lm:<timestamp>}
      }
  }
}
}

Navigation State parameters will be written to url or persistence store upon configuration.
Here's the default configuration:


Following is the list of parameters that are configurable:
Upon page loading or page refresh, navigationstatemodel is initialized with navigation state data from url or
persistence. "decode" will be used to load data from url and "preprocess" will be used to load data from persistence.
Upon commit on NavigationStateModel updates, navigation state data will be sent to url or sent to persistence.
"postprocess" will send the updates to persistence and "encode" will generate the new url fragment based on latest navigation state.


Method Summary
 String encodeWidgetIdentifier(String wid, NavigationStateModel navigationStateModel)
           Encodes the specified widget instance id.
 String decodeWidgetIdentifier(String wid, NavigationStateModel navigationStateModel)
           Decodes a unique widget instance id.
 Object decode(String url, Function callback)
           Decode the url and store the state into a JSON Object.
 String encode(Object state, Function callback, Object oldState, Object additionalParams, NavigationStateModel navigationStateModel)
           Encode state object and generate fragment.
 String generateUrl(Object state, Function callback, JSON params)
          Deprecated.  Use generateURL instead.
 String generateURL(Object state, Function callback, JSON params)
           Encode state object and generate full url.
 Object preprocess(Object state, Function callback)
           Preprocess could be used to filter the original state.
 void dispose(Function callback)
           Dispose the any navigation state that's persisted.
 Object postprocess(Object state, Function callback, Object oldState, Object additionalParams)
           Postprocess could be used to filter the original state before url is generated.
 

Method Detail

encodeWidgetIdentifier

String encodeWidgetIdentifier(String wid,
                              NavigationStateModel navigationStateModel)
Encodes the specified widget instance id.

Parameters:
wid - widget instance id; different page may have same widget instance id.
navigationStateModel -
Returns:
unique id, representing a widget instance on a page

decodeWidgetIdentifier

String decodeWidgetIdentifier(String wid,
                              NavigationStateModel navigationStateModel)
Decodes a unique widget instance id.

Parameters:
wid - unique widget instance id.
navigationStateModel -
Returns:
widget instance id

decode

Object decode(String url,
              Function callback)
Decode the url and store the state into a JSON Object. JSON object should be pass into Callback. If no callback is defined, navigation state is returned.
callback:function(state) { };

Parameters:
url - url string
callback - callback function
Returns:
navigation state object

encode

String encode(Object state,
              Function callback,
              Object oldState,
              Object additionalParams,
              NavigationStateModel navigationStateModel)
Encode state object and generate fragment. Fragment should be passed into callback function.
callback(fragment); If no callback is defined, url fragment is returned.

Parameters:
state - JSON object representing Mashup state
callback - callback function which takes the following parameters:   additionalParams (JSON) - if the additionalParams was passed in to the encode function, then it must be passed back into the callback function
  responseParams (JSON) - Optional If additionalParams.allowRedirect is true and this is an asynchronous commit, then the implementation of this function may pass responseParams.doRedirect set to true to refresh the page after the commit is completed
oldState - JSON object representing Mashup state before it gets updated
additionalParams - Optional JSON object to control various aspects of encoding or the registered callback
navigationStateModel -
Returns:
the url fragment that contains navigation state

generateUrl

String generateUrl(Object state,
                   Function callback,
                   JSON params)
Deprecated.  Use generateURL instead.

Parameters:
state -
callback -
params -

generateURL

String generateURL(Object state,
                   Function callback,
                   JSON params)
Encode state object and generate full url. URL should be absolute URL. URL should be passed into callback function. If no callback, full url is returned.
callback:function(url) { };
Sample parameter: { nohash:"true"}
if "nohash" is set to true,the returned url will not contain state in hash.
By default Lotus Mashups only supports url that contains navigation state in hash.
Extensions can be added to support additional parameter by using extension registry.

Parameters:
state - JSON object representing Mashup state
callback - callback function
params - additional parameter in json format
Returns:
full url that contains navigation state

preprocess

Object preprocess(Object state,
                  Function callback)
Preprocess could be used to filter the original state. For example, pulling more state information that's cached in cookie.
The final state should be passed into callback.
callback:function(state) { };
If no callback, state object will be returned.

Parameters:
state - JSON object representing Mashup state
callback - callback function
Returns:
object contains navigation state

dispose

void dispose(Function callback)
Dispose the any navigation state that's persisted. Callback is executed when dispose action is done.
callback:function() { };

Parameters:
callback - callback function

postprocess

Object postprocess(Object state,
                   Function callback,
                   Object oldState,
                   Object additionalParams)
Postprocess could be used to filter the original state before url is generated. For example,some state information should be persisted into cookie.
The final state should be passed into callback.
callback:function(state) { };
If no callback, state object will be returned.

Parameters:
state - JSON object representing Mashup state
callback - callback function
oldState - JSON object representing Mashup state before it gets updated
additionalParams - Optional JSON object to control various aspects of encoding or the registered callback.
Returns:
object contains navigation state


Copyright IBM Corp. 2010 All Rights Reserved.