Rendering a Form for a Work Item
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.
When a work item is opened, the client application must display the work item data to the user, 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.
BPMTestApplication displays work item data as a TIBCO form. The ViewWorkItem method (defined in ViewWorkItem.cs):
- creates a web browser control to hold the form.
- calls Adapter.OpenItem to open the work item and fetch its associated data.
- calls
ShowItem (which works with
FormRedirect.htm) to render the form and display it to the user.
public ViewWorkItem(Adapter adapter, string guid, WorkItem workItem) { InitializeComponent(); webBrowser1.AllowWebBrowserDrop = false; //webBrowser1.IsWebBrowserContextMenuEnabled = false; webBrowser1.WebBrowserShortcutsEnabled = false; webBrowser1.ObjectForScripting = this; this.StartPosition = FormStartPosition.CenterParent; _adapter = adapter; _guid = guid; _workItem = workItem; try { _item = _adapter.OpenItem(_guid, workItem); ShowItem(); } catch (Exception ex) { MessageBox.Show("ERROR: Failed to open item: " + ex.Message); throw ex; } } public void ShowItem() { Text = "Viewing item: " + _item.presentation.activityName; HtmlDocument doc = webBrowser1.Document; string pathToHTML = Environment.CurrentDirectory + "/FormRedirect.htm"; StreamReader streamReader = new StreamReader(pathToHTML); string htmlText = streamReader.ReadToEnd(); streamReader.Close(); htmlText = htmlText.Replace("%%SCRIPT_LOCATION%%", _adapter.GetJSURL()); // Now create a temporary file for the HTML page with the correct host location string tempFile = Path.GetTempFileName(); FileStream File_Stream = new FileStream(tempFile, FileMode.Create, FileAccess.Write); StreamWriter FileWriter = new StreamWriter(File_Stream); try { FileWriter.BaseStream.Seek(0, SeekOrigin.End); FileWriter.Write(htmlText); } finally { FileWriter.Close(); } webBrowser1.Url = new Uri(tempFile); }
Copyright © Cloud Software Group, Inc. All rights reserved.