<!-- Enhydra Java Application Server Copyright 1997-1999 Lutris Technologies, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes Enhydra software developed by Lutris Technologies, Inc. and its contributors. 4. Neither the name of Lutris Technologies nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY LUTRIS TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUTRIS TECHNOLOGIES OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --> <JDDI INCLUDE="../jinc/Setup.jinc"></JDDI> <HTML> <HEAD> <TITLE>JDDI HTML Example: JDDI Fields</TITLE> </HEAD> <JDDI INCLUDE="../jinc/Header.jinc"></JDDI> <BODY> <CENTER> <B><FONT FACE="Arial,Helvetica" SIZE=+3> JDDI Fields </FONT></B> </CENTER> </BODY> <JDDI INCLUDE="../jinc/Buttons.jinc"></JDDI> <JDDI INCLUDE="../jinc/Home.jinc"></JDDI> <BODY> <BR> <CENTER> <TABLE COLS=1 WIDTH="60%"> <TR> <TD> <FONT FACE="Arial,Helvetica" SIZE=+1> This page demonstrates: <UL> <LI>JDDI Fields for "page level" persistence: <UL> <LI>How to extract CGI query string information. <LI>How to create JDDI Fields from a Java Section. </UL> <LI>How to access JDDI Fields from static HTML. <LI>How to access JDDI Fields from Javascript. <LI>How to use Java Sections within HTML. <LI>How to generate HTML from Java sections. </UL> </FONT> </TD> </TR> </TABLE> </CENTER> <BR> <JDDI HTML IFEQ FIELD=cgiArgs.firstname VALUE=""> <CENTER> <TABLE COLS=1 WIDTH="60%"> <TR> <TD> <FONT FACE="Arial,Helvetica" SIZE=+1> To use this demo, please enter your First and Last names below, and hit the submit button. </FONT> </TD> </TR> </TABLE> </CENTER> <FORM METHOD=POST ACTION="JDDIFields.po"> <TABLE WIDTH=600> <TR> <TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\">First Name:</B></TD> <TD><INPUT TYPE=TEXT SIZE=20 NAME=firstname></TD> </TR> <TR> <TD ALIGN=RIGHT><B><FONT FACE=\"Arial,Helvetica\">Last Name:</B></TD> <TD><INPUT TYPE=TEXT SIZE=20 NAME=lastname></TD> </TR> <INPUT TYPE=HIDDEN NAME=debug VALUE=(@cgiArgs.debug@)> <INPUT TYPE=HIDDEN NAME=help VALUE=(@cgiArgs.help@)> <TR> <TD COLSPAN=2 ALIGN=CENTER><BR><INPUT TYPE=SUBMIT VALUE=Submit></TD> </TR> </TABLE> </FONT> </FORM> </JDDI> <OL> <HR ALIGN=LEFT WIDTH=30%> <FONT COLOR=green><B>Inside Static HTML</B></FONT><BR> <HR ALIGN=LEFT WIDTH=30%> <LI> <FONT FACE="Arial, Helvetica"> The notation <B> &#040;@@&#041; </B> provides a pre-formatted dump of all the decoded CGI query string information as well as JDDI Fields that have been created during the lifetime of the presentation object page. This is an excellent tool for debugging. Since no page-level additions have been made to the pool of JDDI Fields, only elements of the query string will be displayed in this example. At the end of this page, <B> &#040;@@&#041; </B> is used again, revealing the additional JDDI Field information that was created within the Java section. <P> <JDDI HTML IFEQ FIELD=cgiArgs.help VALUE="on"> <CENTER> <TABLE COLS=1 WIDTH="40%" > <TR> <TD> <FONT FACE="Arial,Helvetica" COLOR=red> If the JDDI Field references a directory, an HTML-formatted dump of all known JDDI Field names and their values under the directory will be reported. </FONT> <IMG SRC="../media/arrow.gif" BORDER=0 ANCHOR=BOTTOM ALIGN=LEFT> </TD> </TR> </TABLE> </CENTER> </JDDI> For this place in the page, the output of <B> &#040;@@&#041; </B> is:<P> (@@) </FONT><BR> <LI> <FONT FACE="Arial,Helvetica"> About to use a Java section to retrieve query string values from the HTTP query string and assign them to programmer-defined variables in the JHtmlPageData object. These variables become new JDDI Fields. </FONT><BR> <JDDI JAVADEF> public void nameHandler(JoltPage page) throws Exception { // We don't care if you are logged in or not, so we don't // do any authentication. String[] firstNames = page.request.getParameterValues("firstname"); String[] lastNames = page.request.getParameterValues("lastname"); String fName; page.append("<HR ALIGN=LEFT WIDTH=30%>"); page.append("<FONT COLOR=blue><B>Inside Java Section</B></FONT>"); page.append("<HR ALIGN=LEFT WIDTH=30%>"); page.append("<FONT FACE=\"Arial, Helvetica\">"); if (firstNames.length > 0) { fName = firstNames[0]; } else { fName = "no username set"; page.append("<LI>No firstName found in http request args."); page.append("<BR>"); } String lName; if (lastNames.length > 0) { lName = lastNames[0]; } else { lName = "no username set"; page.append("<LI>No lastName found in http request args."); page.append("<BR>"); } // Store the name information in pageData for use later on in the page. page.append("<LI>Setting firstName to JDDI Field variable: \"fName\""); page.append("<BR>"); page.data.set("fName", fName); page.append("<LI>Setting lastName to JDDI Field variable: \"lName\""); page.append("<BR>"); page.data.set("lName", lName); page.append("</FONT>"); } </JDDI> <JDDI JAVACALL=nameHandler></JDDI> <HR ALIGN=LEFT WIDTH=30%> <FONT COLOR=green><B>Back to Static HTML Again</B></FONT><BR> <HR ALIGN=LEFT WIDTH=30%> <!-- resuming <OL> from above... --> <LI> <FONT FACE="Arial, Helvetica"> Getting username via JDDI Field </FONT><BR> <LI> <FONT FACE="Arial, Helvetica"> My JDDI fields tell me that you are: <B><FONT COLOR=red> &nbsp;&nbsp;&nbsp;&nbsp;&quot;(@lName@), (@fName@)&quot; </FONT></B> </FONT><BR> <JDDI HTML IFEQ FIELD=cgiArgs.help VALUE="on"> <TABLE COLS=1 WIDTH="40%" > <TR> <TD> <FONT FACE="Arial,Helvetica" COLOR=red> <BR> The section below, demonstrates the use of Javascript for some client side processing vs. Java processing which takes place on the server side... </FONT> <IMG SRC="../media/arrow.gif" BORDER=0 ANCHOR=BOTTOM ALIGN=LEFT> </TD> </TR> </TABLE> </JDDI> <SCRIPT LANGUAGE="JavaScript"> /* Extract the users initials from the JDDI Fields fName and lName using Javascript */ document.write("<HR ALIGN=LEFT WIDTH=30%>") document.write("<FONT COLOR=blue><B>Entering Javascript </B></FONT>") document.write("<HR ALIGN=LEFT WIDTH=30%>") var fName = "(@fName@)" var lName = "(@lName@)" var firstInitial = fName.charAt(0) var lastInitial = lName.charAt(0) document.write("<FONT FACE=\"Arial,Helvetica\" SIZE=+1>") document.write(fName + "'s initials are: </FONT><FONT COLOR=red SIZE=+1>" + firstInitial + lastInitial + "</FONT>") </SCRIPT> <BR> <HR ALIGN=LEFT WIDTH=30%> <FONT COLOR=green><B>Inside Static HTML Again</B></FONT><BR> <HR ALIGN=LEFT WIDTH=30%> <LI> <FONT FACE="Arial, Helvetica"> Final contents of JHtmlPageData accessed via JDDI Field, including lName and fName created in the Java section:<P> (@@) </FONT> </OL> <JDDI INCLUDE="../jinc/VerboseDebug.jinc"></JDDI> </BODY> </HTML>