|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
JavaScript FunctionsNOTE: The tooltips for the Framework are provided by Walter Zorn. Please visit his site at http://www.walterzorn.com. He is the one developer I can identity, there are many more functions that I begged, borrowed and stole(copy and pasted) from the internet – “Why think, when you can GOOGLE!” Another point of interest, the Framework never performs a
“Submit”, all interactions with the host are via http://java.sun.com/javaee/javaserverfaces/ajax/tutorial.jsp Ok – Back to the topic(s) at hand…. Java Script Commands:sbGeneral.jsThe sbGeneral.js file contains the core Framework script functions for all server and form interactions. var sysAccess =
"Page"; var sysLastForm =
""; var sysCurrentForm =
""; var sysSessionStartDateTime = ""; var sysSessionEndDateTime = ""; var sysAction =
""; var localTransitionForm =""; var FormContextArea =
"ajaxcontentarea"; var FormTopArea =
"ajaxtoparea"; var FormHeaderArea = "ajaxheaderarea"; var FormBottomArea =
"ajaxbottomarea"; var FormFooterArea =
"ajaxfooterarea"; Functions:
AjaxLib.jsProvides JavaScript “class” like access to
var aj = new Once you have created an instance of the Asynchronous Request – do not wait for responseAjax.requestText(servlet,
handler, formvalues) Ajax.requestXML(servlet,
handler, formvalues) Synchronous Request – wait for server responseAjax.requestSyncText(servlet,
handler, formvalues) Ajax.requestSyncXML(servlet,
handler, formvalues) Text or XML responseThe requests can return either a text string, or an XML DOM object. Text return values are harder to interrogate, but is very useful for returning simple strings. The XML DOM requests are far more useful for form, or multiple field value return types. Request ParametersEach of the for request methods require the same three parameters. Servlet – This is the equivalent to the html Form “Action” attribute. It is the name of the servlet to be invoked. Handler – This is the handler function which will be called when the server returns a respsone. The handler function must take the following form; function AjaxReturnHandler(domObject){ alert("returned XML DOM from
Server"); } OR function AjaxReturnHandler (stringObject){ alert("returned Text String
from Server"); } FormValues – The data to be sent to the server. Sample Request w/Handlerfunction MyServlet_Sample(){ setFormValue("sysAction", "Import"); var aj = new aj.requestSyncXML("/FWAdmin/MyServlet", "SampleHandler", getAllFormValues("MySevlet")); } function SampleHandler(dom){ alert("returned from Import"); } The above JavaScript will execute a synchronous request to the /FWAdmin/MyServlet servlet using all the form values using the sbGeneral.js function getAllFormValue(formname). When the servlet returns it’s response, the handler “SampleHandler” will be invoked. FormValidation.js
Standing on the shoulders of giants, I have assembled most of these functions by combing the web. Thanks to all you un-named developers out their! The FormValidation functions are geared toward data manipulation, and formatting. Functions:
Framework Page InterfaceOk, so JavaScript doesn’t really have the concept of an ‘Interface’. That said, the Framework requires that you implement a script for every page that user will interact with, and that that page implement certain functions, and a variable. The pseudo-interface requires that these functions begin with the name of the form (case matters). Variable:var yourFormNameDirty = false; Functions:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
Copyright 2009. All rights reserved by S. Chappell |