This section demonstrates how to pass a parameter to WebClient function. The following example is based on wxpcourse60 model calling the function WXwF, which prompts the user to insert an item record.
The first step is to create a URL which calls the insert item function, without parameters. To accomplish this, open WebClient.properties file and add the following property.webclient.entry.url.InsertItem=WXPCOURSE60.WXwF
Now, the servlet will respond to the URL /WebClientServlet/InsertItem
by calling the function WXPCOURSE60.WXwF as the WebClient entry point. However, it does not yet allow parameters to be passed.
To pass parameters in, a custom servlet needs to be created. Open J2EE perspective. Right-click on web project → Select New → Select Servlet.
Enter deeplink as the Java package and Class name. For the servlet mapping, specify InsertItem. Click Finish.
The parameters are passed to WebClient using an XML format. Locate the variable plexXML in the source code; this contains the XML data that is sent. Modify the input variable name and field name to match those expected by the WXwF function.
final String plexXML = " <FieldName=\"ItemID\">"+ encodeToXML(myVariable) + final String plexXML = "<PlexFunction
xmlns=\"http://adcaustin.com/ws-plex/1.0/%22%3E
<InputVariables Name=\"Input\"><FieldName=\"ItemID\">"+
encodeToXML(myVariable) +
"</Field></InputVariables></PlexFunction>";"";
Modify webClient URL from final String webclientURL =
"/webclient/test"; to final String webclientURL =
"/WebClientServlet/InsertItem";
Now the InsertItem servlet will forward its requests to the WebClient servlet. Save changes.
The last change that needs to be made is the servlet mapping. It needs to have the characters /* at the end to match against any parameter that is passed in the URL. Open web.xml and change deeplink servlet mapping to
/InsertItem/*
And WebClientServletservlet mapping to
/WebClientServlet/*