Custom Unit and AJAX / SOAP

20 May '13, 08:01 AM
56,749 Views
Forum Forum Starter - Level 2

Hi, Is it possible to manually fire the execute() method of a custom unit? Or similarly, is it possible for a custom unit to have Ajax attached to an anchor (or button with onClick) that can call a method in the java service associated with the custom unit? Eg: Have a Link that fires the service method before the OK link so that the processing can be encapsulated within the unit.

 
x 0
Follow
Answer Answer at this question and get points!
Forum Starter - Level 2

Still hoping for some input for this and I've made progress.

Question

How do you debug a Web Service in Web Ratio?

My Web Service uses a Custom Unit that will perform some business logic and then save a database record using code in the Custom Unit Service java class.

The Web Service is published because when I use a browser to point to the service a blank page is displayed (no error, but no results). Any slight error in the URI generates the appropriate Tomcat error, so the blank page is just an empty result of a correctly fired Web Service.

Furthermore, the javascript code (listed below) fires off correctly, and returns successfully for both methods. But as per the browser test, no results are provided. I have a System.out.println() in the Custom Unit java code, but this doesn't get written out to any Tomcat log files.

This is what I'm trying to achieve specifically the section describing the intention to fire some javascript (see ""processSingleOption()"" below) but I haven't been able to get it working.

NOTE: This is the solution using javascript where the other wiki help request is trying to use Links to fire off the MarkerResponse Custom Unit.

I have created a Web service within WebRatio as per Getting started with Web Services and I would like to invoke if from my Javascript in my Custom Unit style template.

The Web Service looks like this:

image?

The style unit creates a button to fire the javascript like this:

<input title=""<c:out value=""${<wr:UnitId/>.signInputLabel}""/>"" onclick=""processSingleOption<c:out value=""${<wr:UnitId/>.signInputLabel}""/>();"" type=""submit"" id=""button:<wr:Id context=""link""/>"" name=""button:<wr:Id context=""link""/>"" value=""<c:out value=""${<wr:UnitId/>.signName}""/>""""/>

The javascript processSingleOption() is as follows:

//
// Use AJAX to save the single option.
//
function processSingleOption<c:out value=""${<wr:UnitId/>.signInputLabel}""/>() {
    try
    {                
        var optionOid = <c:out value=""${<wr:UnitId/>.singleOptionOid}""/>;
        var theURL = ""http://localhost:8080/Stigmergy/StigmergyService/StimgergyListener/saveContribution.do"";
        theURL = theURL  + ""?PositionIndex="" + <c:out value=""${<wr:UnitId/>.positionIndex}""/>;
        theURL = theURL  + ""&optionOid="" + optionOid;
        theURL = theURL  + ""&isRevoking="" + <c:out value=""${<wr:UnitId/>.revoking}""/>;  
        //alert (""Contribution '<c:out value=""${<wr:UnitId/>.signInputLabel}""/>' : "" + theURL );

        // define the iteraction with the server -- true for as asynchronous.
        req = getXMLHttpRequest();
        req.onreadystatechange = handleHttpResponseSearch;
        req.open(""GET"", theURL, true);
        req.send(null); 
    }
    catch(e)
    {
        alert(""There was an error saving. "" + e);
    }
}

//
// If we have a valid login then validate the rest of the form
//
function handleHttpResponseSearch()
{

  if (req.readyState == XMLHTTPREQUEST_READY_STATE_COMPLETED)
  {
    if (req.status == 200)
    {
        // Process the data.
        //var jsonExpression = ""("" + req.responseText + "")"";
        //var response = eval(jsonExpression);
        alert(""Success:"" + req.responseText);
    }
    else
    {
      alert(""Error in response: HTTP ""
        + req.status
        + "" ""
        + req.statusText);
    }
  }
}

 
x 0
Answer at this question and get points!

Related questions

Access wsdl in https Ajax and FCK Editor (WebRatio 5.x) ajax and javascript AJAX events problem to external JavaScript Ajax is not working in own style project Ajax link success callback? Ajax onchange and jQuery 2.x (with migrate plugin) incompatible Ajax on change selection field and modify units Ajax web app with javascript history object using the WebRatio Autocomplete template Ayuda Simple List Component Layout personalizado Button to go on another page Can not get generate and run option for DataService Project Cannot invoke method selectSingleNode() on null object Can't generate and run database or start tomcat server! CelsiusToFahrenheit Example Como abrir una ventana en ajax desde una master page Como usar la función autocomplete en un field com.webratio.rtx.RTXException: An error occurred dispatching the SOAP message Could not create service Criptare dati sensibili nel database CSV Component with utf8 encoding Custom components Custom descriptors Custom Plug-in Custom Time Unit Custom Unit: Difficult example in Guide ... any suggestions? Data flow from a page which is not visible anymore Description: Unknown tag 'wr:LinkResource' Disabilitare campi durante evento AJAX Dynamic link labelling for Custom Unit Encoding Confirm Dialog Exception REST Post request Exposing SOAP Web SERVICE on port different from 80 file analysis then update MySQL database forward/backward navigation and bookmark in ajax web app Generation errors on ajax enabled page with many components, ajax links and selective refresh Generation options problem Getting started with Web Services Google Map Unit Guardar Saltos de LINEA Hiding form components based on page conditions How can I add a credit card payment gateway or integrate paypal in my web app logic? How can I invoke a Rest Web Service having dynamic parameters? how can i open a pdf file using download dialog How complex can Custom Unit output be? How to add an image in a modal/pop-up window? How to change smtp port How to get a wr:AjaxURL tag working How to keep current page/block of List/Hierarchy (Index) components after ajax link clickwith selective refresh? How to localize AJAX waiting dialog? How to open a window ajax in a BPM activity? How to run the example from Custom Unit Guide? How to use LandmarkMenu as AJAX navigation how to use the landmark menu as AJAX navigation invoke rest web service that returns a pdf invoking a webservice using REST Is there any custom unit store or repository? Do you create/sell custom units? java.lang.NullPointerException javascript history object More Custom Unit questions: example of Content and Operation Unit? Need help with Landmark No cloud accounts available No database on my cloud account Overlays for Google Map Unit. Parameters order in a webservice request Personalizzazione del login component Problema generando la logica de un proyecto Problema Invocation Unit Problemas al invocar webservice Problems with Custom components: Can't get values from output parameters on ok flow. Problem with application runnung Progress bar when uploading big file(s) in a form? Properties of the XSD Resource (File) Publish a web service publish web service for storing information in PostgreSQL DB following XSD Resource "Run Now" on a job scheduled to run later Scroll ajax problem selection fields on cascade Selezione sul giorno "Events Planning" Status ProcessInstance and activityInstance in spanish Stored procedure component Sync DataService Project with Mobile Project Twitter Unit - Get Geo location of twitt Update fields based on selection of other fields Usage of the Gantt Unit Uso de la componente chart de webRatio usuarios y grupos ¿Visor de imágenes y reproductor de video para la versión 7.2? Image viewer and video player for version 7.2? Web project without initial login form - how to create custom logins? Webratio Add-ons no permite login WebRatio and MySQL Webratio don't recognize JSON library WebRatio Mobile Platform Community edition - Restful request WebRatio Platform 7.2 Community Cloud Edition WebService DateTime value is not parsed to Date. Web service provider newline problem web service request using XSD Web service - Synchronize XSD When stars web ratio between dofollow and nofollow backlink has affected? When using web services, what kind authentication is used? which of these three models is closer to webratio/ifml way of creating web applications wr-ajaxDivs break layout on ajax pages. XML Out Unit and Soap Request Response Unit XML Schema Definition Support XML Schema Definition Support