Strategy ONE
Constructing a URL
The code sample shown below can be called from any transform. It assumes that a bean variable has already been defined, which can be used to fetch a particular event. This event is passed to the parameter builder, which uses it to construct a string containing all of the information necessary for generating the URL—the evt and src parameters and state information. In this example, the bean is the ReportBean ("rb") and the event is WebEventOpenDesktop.
Copy
WebEvent event = null;
String url = null;
// Create a new URI Builder
ParameterBuilder pb = newURIBuilder();
//For this example, assume "rb" is a ReportBean.
//The ReportBean is used to fetch the WebEventOpenDesktop event.
//To generate URLs, you can use any bean and fetch any event that
//applies to that bean.
//Get the event to open the Desktop page from the bean.
event = rb.getWebEvent(EnumServletEvents.WebEventOpenDesktop);
//Next, add event information.
//EventElementTypicalURLLink = EnumEventElement.EventElementEventID + EnumEventElement.EventElementSource + EnumEventElement.EventElementNonNullParams
//See EnumEventElement interface for more details about these constant values
//See EnumWebPersistableState interface for more details on the state of the bean that is kept in the URL.
pb.addEventInfo(event, EnumEventElement.EventElementTypicalURLLink,EnumWebPersistableState.MINIMAL_STATE_INFO);
//Set the contents of the ParameterBuilder to a String
url = pb.toString();
The output of this code looks similar to:
Copy
mstrWeb?evt=3010&src=mstrWeb.3010&mstrWeb=myMachine.myProject.0"
The URL includes the target base and the event, source, and minimal state for the bean. No arguments are included because this particular event does not require arguments.
