Parameterized Query Application Source HTML



The following source HTML code is used to create the Parameterized Query Application:

<HTML>

<HEAD>
<TITLE> Parametrized Query Example </TITLE>
<SCRIPT LANGUAGE="JavaScript">
	// There are two data items that must be placed on the InfoBus in order
	// to execute the query:  the parameter to the query and the query trigger.
	// The query is executed (by the JDBCSource applet defined below) only when
	// the query trigger goes from false to true.  Thus, we first reset the query
	// trigger before placing both data items on the InfoBus.
	function run_query()
	{
		var i = document.forms[0].elements[0].selectedIndex;
		document._ScriptHelper.publishStringToInfoBus("shoeQueryResult.trigger","false");
		document._ScriptHelper.publishStringToInfoBus("state",document.forms[0].elements[0].options[i].value);
		document._ScriptHelper.publishStringToInfoBus("shoeQueryResult.trigger","true");
	}
</SCRIPT>
</HEAD>

<BODY BACKGROUND="KS_bg.gif">

<img src="millenniashoes.gif" width=540 height=143><BR>

<!-- Include an instance of the ScriptHelper applet to allow our script function
  to put data items on the InfoBus.  The applet has no UI so we make it invisible
  on the web page by using a minimal WIDTH and HEIGHT setting in the APPLET tag. -->

<applet NAME="_ScriptHelper" CODEBASE="../.."
	CODE="lotus.scripthelper.ScriptHelper" 
	ARCHIVE="jars/devpack_scripthelper_app.jar"
	WIDTH=1
	HEIGHT=1>
	
	<PARAM NAME="CABINETS" value="cabs/devpack_scripthelper_app.cab, cabs/devpack_sheet_app.cab, cabs/devpack_jdbc_app.cab, cabs/devpack_chart_app.cab, cabs\devpack_dbaw.cab">
</APPLET>

<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=755>
	<TR ALIGN=center>
		<TD></TD>
		<TD>
			<!-- A script function is called when the user clicks on the button
			  defined below.
			  
			  The script function gets the parameter for the query from a drop down
			  box and places it on the InfoBus.  It then places the query trigger
			  on the InfoBus.  (The query trigger is a boolean whose name is the
			  query name with ".trigger" appended).  This causes the JdbcSource applet
			  to execute the query and place the resulting data set on the InfoBus
			  with a name that is the same as the name of the query - "shoeQueryResult"
			  in this example.
			  
			  Since the template loaded by the Sheet applet defined above has a
			  range named "shoeQueryResult" the results of the query wind up
			  there. -->
			<FORM>
				Select a state:
				<SELECT NAME="state">
					<OPTION VALUE="Alabama">Alabama
					<OPTION VALUE="Alaska">Alaska
					<OPTION VALUE="Arizona">Arizona
					<OPTION VALUE="Arkansas">Arkansas
					<OPTION VALUE="California">California
					<OPTION VALUE="Colorado">Colorado
					<OPTION VALUE="Connecticut">Connecticut
					<OPTION VALUE="Delaware">Delaware
					<OPTION VALUE="Florida">Florida
					<OPTION VALUE="Georgia">Georgia
					<OPTION VALUE="Hawaii">Hawaii
					<OPTION VALUE="Iowa">Iowa
					<OPTION VALUE="Idaho">Idaho
					<OPTION VALUE="Illinois">Illinois
					<OPTION VALUE="Indiana">Indiana
					<OPTION VALUE="Kansas">Kansas
					<OPTION VALUE="Kentucky">Kentucky
					<OPTION VALUE="Louisiana">Louisiana
					<OPTION SELECTED VALUE="Massachusetts">Massachusetts
					<OPTION VALUE="Maryland">Maryland
					<OPTION VALUE="Maine">Maine
					<OPTION VALUE="Michigan">Michigan
					<OPTION VALUE="Minnesota">Minnesota
					<OPTION VALUE="Missouri">Missouri
					<OPTION VALUE="Mississippi">Mississippi
					<OPTION VALUE="Montana">Montana
					<OPTION VALUE="North Carolina">North Carolina
					<OPTION VALUE="North Dakota">North Dakota
					<OPTION VALUE="Nebraska">Nebraska
					<OPTION VALUE="Nevada">Nevada
					<OPTION VALUE="New Hampshire">New Hampshire
					<OPTION VALUE="New Jersey">New Jersey
					<OPTION VALUE="New Mexico">New Mexico
					<OPTION VALUE="New York">New York
					<OPTION VALUE="Ohio">Ohio
					<OPTION VALUE="Oklahoma">Oklahoma
					<OPTION VALUE="Oregon">Oregon
					<OPTION VALUE="Pennsylvania">Pennsylvania
					<OPTION VALUE="Rhode Island">Rhode Island
					<OPTION VALUE="South Carolina">South Carolina
					<OPTION VALUE="South Dakota">South Dakota
					<OPTION VALUE="Tennessee">Tennessee
					<OPTION VALUE="Texas">Texas
					<OPTION VALUE="Utah">Utah
					<OPTION VALUE="Virginia">Virginia
					<OPTION VALUE="Vermont">Vermont
					<OPTION VALUE="Washington">Washington
					<OPTION VALUE="Wisconsin">Wisconsin
					<OPTION VALUE="West Virginia">West Virginia
					<OPTION VALUE="Wyoming">Wyoming
				</SELECT>
				 
				<INPUT TYPE=button VALUE="Submit Query" ONCLICK="run_query();">
			</FORM>
		</TD>
	</TR>
	<TR ALIGN=center>
		<TD>
			<!-- Include an instance of the Sheet applet which gets the results of
			  the query.  The applet is programmed to load a template file which
			  has all range names, formats, and formulas defined for presenting
			  the results of the query.  It is also programmed to disable column
			  and row headers, the edit line, and the status line and to enable the
			  horizontal and vertical scroll bars.
			  
			  Note:  the template file has two range names defined: "shoeQueryResult"
			  where the results of the query are placed and "shoeChart" where the
			  inputs to the Chart applet reside. -->
			<APPLET NAME="shoeSheet" CODEBASE="../.." CODE="lotus.sheet.Sheet" 
				ARCHIVE="jars/devpack_sheet_app.jar"
			WIDTH=281 HEIGHT=352>
	<PARAM NAME="CABINETS" value="cabs/devpack_scripthelper_app.cab, cabs/devpack_sheet_app.cab, cabs/devpack_jdbc_app.cab, cabs/devpack_chart_app.cab, cabs\devpack_dbaw.cab">
				<PARAM NAME="FileName" VALUE="PQueryTemplate.html">
				<PARAM NAME="ColumnHeadingsVisible" VALUE="false">
				<PARAM NAME="RowHeadingsVisible" VALUE="false">
				<PARAM NAME="HorizontalScrollBarVisible" VALUE="true">
				<PARAM NAME="VerticalScrollBarVisible" VALUE="true">
				<PARAM NAME="EditLineVisible" VALUE="false">
				<PARAM NAME="StatusLineVisible" VALUE="false">
			</APPLET>
		</TD>

		<TD>
			<!-- Include an instance of the Chart applet which graphs a range of
			  data on the Sheet applet.  The charted data is calculated from the
			  results of the database query.  The name of the applet (shoeChart)
			  determines the name of the data item that is charted so it is
			  important (in the context of this example) that the Sheet applet
			  defines a range with this name. -->
			<APPLET NAME="shoeChart" CODEBASE="../.." CODE="lotus.chart.Chart" 
				ARCHIVE="jars/devpack_chart_app.jar"
				WIDTH=472 HEIGHT=352>
	<PARAM NAME="CABINETS" value="cabs/devpack_scripthelper_app.cab, cabs/devpack_sheet_app.cab, cabs/devpack_jdbc_app.cab, cabs/devpack_chart_app.cab, cabs\devpack_dbaw.cab">
				<PARAM NAME="backgroundImageName" VALUE="KS_chartbg.gif">
				<PARAM NAME="ParseDirection" VALUE="COLUMN">
				<PARAM NAME="PlotLayout" VALUE="PIE">
				<PARAM NAME="Rendering" VALUE="3D">
				<!PARAM NAME="viewPoint" VALUE="1000,1000,1000,-90.25">
			</APPLET>
		</TD>
	</TR>

</TABLE>

<!-- Include an instance of the JdbcSource applet to perform a specific database
  query.  We make the applet invisible on the web page by using a minimal WIDTH
  and HEIGHT setting in the APPLET tag and setting the "allowUI" parameter to false.

  The "database", "ID", and "password" parameters specify the database to use for
  the query and the ID and password to use when accessing it.
  
  The "autoConnect" parameter is set so that the applet connects to the database
  once it is started.
  
  The "retrievals" parameter specifies a list of query names to process, in this
  case the list contains only one query name: shoeQueryResult.
  
  The "shoeQueryResult" parameter specifies the actual query to execute.  Note
  that the query contains a parameter.
  
  You can specify the format of each resulting data set by specifying a parameter
  whose name is the name of the query with "_resultStyle" appended.  In this case,
  "shoeQueryResult_resultStyle" specifies that only the data is to be returned in
  the data set.
  
  Note that a query in the list of query names isn't processed until its query
  trigger is set on the InfoBus.  The query trigger is a boolean value whose name
  is the name of the query with ".trigger" appened. -->
 <APPLET NAME="shoeQuery" CODEBASE="../.." CODE="lotus.jdbc.JdbcSource" 
 			ARCHIVE="jars/devpack_jdbc_app.jar"
			WIDTH=1
			HEIGHT=1>
	<PARAM NAME="CABINETS" value="cabs/devpack_scripthelper_app.cab, cabs/devpack_sheet_app.cab, cabs/devpack_jdbc_app.cab, cabs/devpack_chart_app.cab, cabs\devpack_dbaw.cab">
	<PARAM NAME="database" VALUE="jdbc:dbaw://suitebiz:8889/Sybase_SQLANY/PQueryData/PQueryData">
	<PARAM NAME="user" VALUE="dba">
	<PARAM NAME="password" VALUE="sql">
	<PARAM NAME="allowUI" VALUE="false">
	<PARAM NAME="autoConnect" VALUE="true">
	<PARAM NAME="autoExecute" VALUE="false">
	<PARAM NAME="retrievals" VALUE="shoeQueryResult">
	<PARAM NAME="shoeQueryResult" VALUE="select Price,Quantity,Description from SalesData where State='%state%'">
	<PARAM NAME="shoeQueryResult_resultStyle" VALUE="Data">
</APPLET>

</BODY>

</HTML>