SAS/IntrNet 1.2: Application Dispatcher |
Creating Dispatcher Applications - Input Component DetailsTechniques for InputThere are four primary techniques for sending input to a Dispatcher application:
HTML formHTML forms provide the most versatile mechanism for inputting data to a Dispatcher application. Forms are easy to create and function effectively in virtually all Web browsers. A Form definition begins with the HyperlinkIt is also possible to create a hyperlink on an HTML page that invokes a Dispatcher application. This is done by using the standard anchor HTML syntax. Instead of linking to a file, the <A HREF="/cgi-bin/broker?_service=default&_program=sample.hello.sas">Say Hello</A> creates a link that says Say Hello. Notice the question mark that follows Important: The Web browser has strict rules about the format of the query string. Name/value pairs must be URL encoded. For example, spaces cannot be passed in the query string. They must be encoded as + or %20. See the HTML Syntax Reference section for more complete information. IMG tagJust as anchors and <IMG SRC="mykids.gif"> and the browser loads the GIF file and inserts it into the Web page. However, the <IMG SRC="/cgi-bin/broker?_service=default&_program=sample.grphics.sas"> will insert the sample graphics output into your HTML page. Now imagine that the underlying data were changing daily. Putting such an image tag on your page would display a new graph each day! Location fieldMost browsers have a location or address field across the top that displays the Web address of the page that you are currently viewing. You can run a Dispatcher program by simply typing in the URL and query string into this field. For example, typing this into the field http://myserver/cgi-bin/broker?_service=default&_program=sample.hello.sas where myserver is the Web server you are using, will run the Hello World program. The ability to run programs without using a form is very useful when developing and debugging Dispatcher applications. By adding &_DEBUG=131 to the end of the location above you can see some useful debugging information including the SAS log. And there was no need to edit any HTML or reload a form. Important: The Web browser has strict rules about the format of the query string. Name/value pairs must be URL encoded. For example, spaces cannot be passed in the query string. They must be encoded as + or %20. See the HTML Syntax Reference section for more complete information. Understanding Name/Value PairsThe Browser passes parameters, data, and options from the HTML page to the Dispatcher through name/value pairs. You can pass name/value pair data via the URL or by inserting the information in fields such as the
<INPUT TYPE="radio" NAME="bar" VALUE="true">Bar Chart
This code indicates that a radio button, one of several input types, appears on the HTML page and is labeled The Dispatcher uses macro variables to surface name/value pair data to your programs. SCL programs are supplied with an SCL list as an additional mechanism for accessing the data. With a few exceptions, the macro variable names and list item names match the names supplied in the HTML code. The HTML names used to create the macro variable names must be valid SAS names and be expected by the program. The Dispatcher rejects nonvalid SAS names. Because the SAS rules for names are more restrictive than the rules for HTML names, Dispatcher application developers must follow the SAS naming rules for all fields:
Multiple Value PairsThere are some cases where multiple name/value pairs with the same name will be created. Because macro variables do not allow multiple values, the Broker must create a unique macro variable name for each value provided. It does this by adding numbers to the end of the name. Before explaining the details of how the Broker handles multiple value pairs, we will discuss what types of fields can cause multiple values to be created. The following input types can generate multiple values for one name:
Multiple values received from selectionsThis example assumes that you have a group of four
checkboxes, each named CBOX=one&CBOX=two&CBOX=three&CBOX=four The Broker then sends the following name/value pairs to your application:
The Text passed from a text entry fieldIf the value passed from a text entry field contains more than the default number of characters or contains a carriage return, the Broker creates multiple name/value pairs
The Here's an example:
<INPUT TYPE="hidden" NAME="_FLDWDTH" VALUE="40">
For more information on Dispatcher fields such as Using Hidden FieldsAlthough hidden fields do not appear on the HTML form, you can use them to pass parameters to the Dispatcher program. For example, you could pass a list of variables to a Dispatcher program for processing. A single Dispatcher program could then be referenced by many HTML files. Another common usage of hidden fields is to pass name/value pairs from one form to the next. The input component to a complicated application can often have more than one form and more than one page. This usually means that the name/value pair data must be propagated through each of the forms until the final program is invoked. Hidden fields are an easy way to accomplish this. If your application uses JavaScript or Visual Basic Script, you may also find that hidden fields are convenient for capturing data generated by user interaction with screen widgets. |
SAS/IntrNet 1.2: Application Dispatcher |