Instantiating the custom component

To use the custom component in your server-side scripts, you specify your package and component name in the form YourPackage/YourComponent. If you are using methods of the generic component installed with EAServer, you must use the narrow method on the generic component helper class to reference the DataWindow/HTMLGenerator125 interface.

The following code instantiates a custom component called EmpListDW that uses the generic HTMLGenerator125 component interface. EmpListDW is deployed in the EmpListPkg package. You substitute this code for the line that instantiates the generic component in the example for “Instantiating the component”, but you do not change the narrow method called on the generic component’s helper class:

String dwGenerator = "EmpListPkg/EmpListDW";
   EmpListDW dwGen = null;
...
dwGen = HTMLGenerator125Helper.narrow(factory.create
          ("jagadmin",""));

Using OneTrip to set up the component and get the generated HTML “Instantiating and configuring the server component” described several items your server script should include to set up the Web DataWindow correctly. Instead of coding all these things separately, you can do all the setup and get the generated HTML with a single method when the EAServer component has been configured with a DataWindow definition and transaction information. This technique is especially useful for improving performance without requiring the server component to maintain state.

String browser=(String)request.getHeader("User-Agent");
dwGen.SetBrowser(browser);
String URI = request.getRequestURI();
String [] myArray = URI.split ("/");
String selfLink = myArray [myArray.length-1];
int retVal;
String dw_1_action =(String)request.GetParameter     ("dw_1_action");
String dw_1_context = (String)request.GetParameter     ("dw_1_context");
if (dw_1_action == null){
 dw_1_action = "";
 }
if (dw_1_context == null){
 dw_1_context = "";
 }
// Pass setup info to server 
String dwHTML = dwGen.OneTrip("dw_1", browser, 
		selfLink, "", dw_1_action, dw_1_context);
// Insert HTML returned from OneTrip in the page
out.print (dwHTML);

Using OneTripEx for retrieval arguments If your DataWindow requires retrieval arguments, use OneTripEx instead of OneTrip. The code checks for a page parameter that has the retrieval argument value. It also makes sure the value will still be available in a reloaded page by providing a selflinkargs expression:

String retrievearg = (String) request.getParameter ("RetArg"):
if (retrievearg == null){
// Provide some meaningful default value
   retrievearg = "default";
}
String selflinkarg = "RetArg='\"" + retrievearg + "\"'";
String dwHTML = dwGen.OneTripEx("dw_1", retrievearg,
   browser, selfLink, selflinkarg, action, context);
out.print (dwHTML);