Informatica ActiveVOS
- Informatica ActiveVOS 9.2.6
- All Products
<html> <head> <!-- header content --> </head> <body> <!-- Main DIV that contains all markup related to this request form UI --> <div id="processRequestForm$ID"> <!-- DIV that contains UI related request form and data entry --> <div id="processRequestForm$ID"> <div>Display Name UI</div> <!-- container for the form UI controls --> <div> <form id="loanApplicationInputForm$ID"> <!-- actual form content, for example: --> First Name: <input id="firstName$ID" name="firstName" value="" size="50" /> <br/> Last Name: <input id="lastName$ID" name="lastName" value="" size="50" /> <br/> </form> <!-- Send button --> <input type="button" id="sendRequest$ID" value="Send Request" /> </div> </div> <!-- DIV that contains html to show the results after submitting a form (invoking a process). Note this DIV is initially hidden, and only shown when response data needs to be displayed. --> <div id="responseContainer$ID" style="display: none;"> </div> </div> <!-- Script --> <script type="text/javascript"> // <![CDATA[ // JavaScript to implement JSON process invoke // ]]> </script> </body> </html>
// The jQuery 'ready' event is fired once the page (form) is loaded and ready for processing. $(document).ready(function() { // bind button click event handler code when the Send button is pressed. $("#sendRequest$ID").click( function() { sendForm(); // see fn below. }); }); // send form function sendForm() { // first grab data entered by user. var firstNameStr = $("#firstName$ID").val(); // .. // .. get other UI data such as loanType, lastName, phone etc. // .. // build JSON request var loanRequestJSON = {"loanProcessRequest": {"xmlns":"http:\/\/schemas.active-endpoints.com\/sample\/LoanRequest\/2008\/02\/loanRequest.xsd", "loanType":{"$t": loanTypeStr}, "firstName":{"$t": firstNameStr}, "lastName":{"$t": lastNameStr}, "dayPhone":{"$t": dayPhoneStr}, "nightPhone":{"$t": nightPhoneStr, "socialSecurityNumber":{"$t": ssnStr}, "amountRequested":{"$t": loanAmount}, "loanDescription":{"$t": loanDesc}, "responseEmail":{"$t": email} } }; // JSON endpoint URL (for example, // http://localhost:8080/active-bpel/services/JSON/humantaskProcessDemoService) var loanServiceUrl = AE_AJAX_SERVICE_UTIL.getActiveVOSServiceUrl("JSON/humantaskProcessDemoService"); // send JSON request AE_AJAX_SERVICE_UTIL.postJSON( loanServiceUrl, loanRequestJSON, function(aJsonResponse) { // success result handler: // show <status/> element text in the response div. var statusText = AE_JSON_NODE_UTIL.getText(aJsonResponse.status); // (above is same as aJsonResponse.status.$t) // append the status text string to the <div id="responseContainer$ID" /> div $("#responseContainer$ID").html("<p>Status=" + statusText + "</p>"); // show the div (since it was initially hidden) $("#responseContainer$ID").show(); }, function(aJsonFault) { alert("Fault!"); }, function(aStatusCode, aStatusMessage) { alert("Transport error: " + aStatusCode + " " + aStatusMessage); } ); }
// Function that encapsulates the form script. var AeRequestForm$ID = function() { // variable defining the name of service var mServiceName = "humantaskProcessDemoService"; // // internal functions: pseudo code shown below for brevity // // This function is called when the form is loaded. function documentReady() { // initialize and populate UI here. // code to bind the SendButton click event to invoke _submitRequest() function // also invoke _setupValidation(); } // function is called (by documentReady() ) function _setupValidation() { // optional code to setup & initialize your form data validation } // Function returns the JSON data structure for this operation function getInputRequest() { // code that creates JSON object. For example: // var json = { "loanProcessRequest": {...} }; // return json; } // function called when the Send Request button is pressed. function _submitRequest() { // 1. validate the form by calling avcform_validate(). // 2. var jsonReq = getInputRequest(); // 3. get form UI data and populate jsonReq object // 4. serviceUrl = AE_AJAX_SERVICE_UTIL.getActiveVOSServiceUrl("JSON/" + mServiceName); // 5. invoke json request via: // AE_REQUESTS_UTIL.postJSON(serviceUrl, jsonReq, _showResponseCallback, ....); // } // validate the form function avcform_validate() { // check form date and validate (e.g. verify required fields have data etc.) // return true if user submitted data is valid } // Called by postJSON(..) code in _submitRequest() function. function _showResponseCallback(aJsonResponse) { // called to display response from a json invoke } // Called by postJSON(..) code in _submitRequest() function. function _showFaultCallback(aJsonFault) { // handle fault } // Called by postJSON(..) code in _submitRequest() function. function _communicationErrorCallback(aStatusCode, aError) { // error handler code } } // The jQuery 'ready' event is fired once the page (form) is loaded // and ready for processing. $(document).ready(function() { // Create Request Form JavaScript object var requestForm = new AeRequestForm$ID(); // initialize form requestForm.documentReady(); });