Strategy ONE

Generating Hidden Inputs for an HTML Form

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 hidden inputs for an HTML form. In this example, the bean is the ReportBean ("rb") and the event is WebEventOpenDesktop.

Copy
 WebEvent event = null;
    
 // Create a new Hidden Input Builder
 ParameterBuilder pb = newHiddenInputBuilder();
 
 //For this example, assume "rb" is a ReportBean.
 //The ReportBean is used to fetch the WebEventOpenDesktop event.
 //To generate hidden inputs, 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.
 //EventElementTypicalEventOnly = EnumEventElement.EventElementEventID + EnumEventElement.EventElementSource
 //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.EventElementTypicalEventOnly,EnumWebPersistableState.TYPICAL_STATE_INFO);  
 
 //Convert the parameter builder to a string
 String strHiddenInputs = pb.toString();
 
 //Add the hidden inputs to the MarkupOutput           
 out.append(strHiddenInputs);

The output of this code looks similar to:

Copy
<input value="3010" type="hidden" name="evt" id="evt"/>
<input value="mstrWeb.3010" type="hidden" name="src" id="src"/>"

Only the ID and source of the event appear as hidden inputs (as specified in the previous code snippet).