Rendering a Form for a Work Item

When a work item is opened, the client application must display the work item data to the user.

This can be done using either:

  • a TIBCO form, which provides a web-based user interface to the work item data.
  • a custom form. Development and use of custom forms is entirely the responsibility of the client application, so is not covered further in this guide.

The Forms Runtime Adapter is a JavaScript API provided as part of the BPM runtime. To display a TIBCO form, a client application must load and use the Forms Runtime Adapter in the browser control containing the form.

Note: See the TIBCO Business Studio Forms User’s Guide for detailed information about the Forms Runtime Adapter.

SampleApp displays work item data as a TIBCO form.

  • The login.jsp creates the HTML page containing the Login form. This form provides the entry point to the sample application. The form action submitted by the user is passed to the WorkProcessingServlet.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    ...
    <SCRIPT LANGUAGE="JavaScript">
    	function submitData(action){		
    		document.forms[0].action="workprocessor?action="+action;
    		document.forms[0].method="post";
    		document.forms[0].submit();
    	}
      </SCRIPT>
    </head>
    ...
    <form action="">
    		<label for="username">Username:</label>
    		<input type="text" name="userName" class="text" id="username">
    		<br />
    		<label for="password">Password:</label>
    		<input type="password" name="pass" class="text" id="password">
    		<br />
    		<serverLabel for="protocol">Server:</label>
    		<input type="checkbox" name="secure" value="secure" checked="checked">Secure (https)</input>
            <!-- <serverLabel for="protocol">Protocol:</serverLabel>
            <input type="radio" name="protocol" value="HTTP" checked="checked">HTTP</input>
            <input type="radio" name="protocol" value="HTTPS">HTTPS</input> -->
            <br /><br />
            <serverLabel for="host">Host:</serverLabel>
    		<input class="serverInput" type="text" name="host" class="text" id="host" value="localhost">
    		<br /><br />
    		<serverLabel for="port">Port:</serverLabel>
    		<input class="serverInput"  type="text" name="port" class="text" id="port" value="8080">
            <br /><br />
    		<input type="submit" onclick="submitData('login');" class="submit" name="submit" value="Submit">
    	</form>
    </div>
    </body>
    </html>
  • The process method in WorkProcessingServlet.java handles all the requests and calls the appropriate method.

    The WorkProcessingServlet.java contains all the methods and control is passed over to the appropriate method. For example, when a user submits the username and password on the login page, the request is handled by the method process and the methods setServiceConnector, setServiceConnector and authenticate are called. Once completed, the method orchestratePages is called.

    /*
    	 * =====================================================
    	 * METHOD : process
    	 * =====================================================
    	 */
    	/**
    	 * Selects the method called based on the request action.
    	 *
    	 * @param req
    	 * @param resp
    	 * @throws ServletException
    	 * @throws IOException
    	 */
    	public void process(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    	{
    		if (getAction(req).equals(Actions.LOGIN))
    		{
    			setServiceConnector(req);
    			authenticate(req, resp);
    		}
    else if (getAction(req).equals(Actions.OPEN_WORKITEM))
    		{
    			openworkItem(req, resp);
    		}
    ...
    		else if (getAction(req).equals(Actions.SHOW_WORKLIST))
    		{
    			displayWorklist(req, resp);
    		}
    ...
    		orchestratePages(req, resp);
    	}
  • The method orchestratePages checks for the action that has been processed and displays an appropriate JSP file to the user
    /*
    	 * =====================================================
    	 * METHOD : orchestratePages
    	 * =====================================================
    	 */
    	/**
    	 * Orchestrates JSP page flow for the application.
    	 *
    	 * @param req
    	 * @param resp
    	 * @throws ServletException
    	 * @throws IOException
    	 */
    	private void orchestratePages(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
    			IOException
    	{
    		if (getAction(req).equals(Actions.LOGIN))
    		{
    			getServletContext().getRequestDispatcher("/worklist.jsp").forward(req, resp);
    		}
    		else if (getAction(req).equals(Actions.OPEN_WORKITEM))
    		{
    			getServletContext().getRequestDispatcher("/openworkitem.jsp").forward(req, resp);
    		}
    		else if (getAction(req).equals(Actions.CLOSE_WORKITEM))
    		{
    			displayWorklist(req, resp);
    			getServletContext().getRequestDispatcher("/worklist.jsp").forward(req, resp);
    		}
    		else if (getAction(req).equals(Actions.COMPLETE_WORKITEM))
    		{
    			displayWorklist(req, resp);
    			getServletContext().getRequestDispatcher("/worklist.jsp").forward(req, resp);
    		}
    		else if (getAction(req).equals(Actions.SHOW_WORKLIST))
    		{
    			getServletContext().getRequestDispatcher("/worklist.jsp").forward(req, resp);
    		}
    ...
    		else if (getAction(req).equals(Actions.LOGOUT))
    		{
    			getServletContext().getRequestDispatcher("/login.jsp").forward(req, resp);
    		}
    	}