Javascript inside cffunction

I have a really stupid question, but I need to use some javascript in a cffunction in a cfc.
Is this possible?
I am trying to use google maps geocode to get the latitude and longitude for addresses and it works in a cfm page, but doesn't in the cffunction.
the below converts the data to json and sends it to a cfc, the cfc then write the data to a file.
the overall goal is to call the service and get this information back in cfml if all possible. we are using google maps api v3.
here is my code:
testget.cfm
<cfajaxproxy cfc="cfc.mycfc" jsclassname="gs">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
   var geocoder;
       geocoder = new google.maps.Geocoder();
       var address = 'your street, your city, your state, your zipcode';
    geocoder.geocode( {address: address}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK && results.length) {
     // You should always check that a result was returned, as it is
     // possible to return an empty results object.
     if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
      var e = new gs();
      var jsonObj = ColdFusion.JSON.encode(results[0].geometry.location);
      var json = e.updateLatLng(jsonObj);
</script>
mycfc.cfc
<cffunction name="updateLatLng" access="remote" >
<cfargument name="latlng" >
<cfset i = deserializeJSON(latlng) >
<cfset lat = i.Yd />
<cfset lng = i.$d />
<cffile action = "write"
file = "C:\ColdFusion8\wwwroot\dev.zipoodle.com\jsontest.txt"
output = "cfclat = #lat# and cfclng = #lng#" >
</cffunction>

it actually work as a proof of concept of sending the data to the cfc and writing to a text file.
<cffunction name="updateLatLng" access="remote">
<cfargument name="latlng">
<cfset i = deserializeJSON(latlng)>
<cfset lat = i.Yd />
<cfset lng = i.$d />
<cffile action = "write"
file = "C:\ColdFusion8\wwwroot\dev.zipoodle.com\jsontest.txt"
output = "cfclat = #lat# and cfclng = #lng#">
</cffunction>
This would actually take my geocode results and create a cf variables of lat and lng.  I thought then I could use these to update the db.
but I use flex a my application so using the cfm example would only work if I use this in my page and call it from flex. Which is an option, but the problem is getting the data back into flex from the cfc. If I used a cfajaxproxy and set the result handler to come back, then I need a platform to get the results from the cfc back to flex.
Does the geolocation have to occure after the record is created?  Is it ok to do it before like you where doing in your first post?
No I would prefer to get this information before creating the record, but I was afraid of the cftransaction waiting on the geocode data to come back...time out... Either way before or after doesn't matter to me, I would prefer before, becuase of a single entry, but I am open for suggestions.

Similar Messages

  • Handling ActiveX events with Javascript inside BSPs

    Hi,
    Has anyone any experience with handling events from ActiveX objects (using the <object> tag) with Javascript, inside BSPs?
    I'm developing solely for the IE browser. Reading other threads, I know that the usual way this is done is via the below code excerpt:
    <i><script type="text/javascript" for="MyObject" event="Object_Event">
         js_function();
    </script></i>
    I create a HTML page, with the <object>, <script..for..event> tags, etc. Everything works fine when the page is run from my local system. However, when the code is run from WebAS (Activate then Test (F8)), the ActiveX object loads fine. But the javascript does not respond to events thrown by the ActiveX object.
    I wonder if anyone can share their experiences on this issue.
    Thank you.
    Amos

    It's the Skype4COM (v1.0.0.17) wrapper for the SkypeAPI, available at https://developer.skype.com/Download
    (Note: NOT the v1.0.0.16, which comes with the Skype ActiveX Tools package).
    I'm trying to use javascript to handle the event "CallStatus", thrown by Skype4COM, as shown in the code excerpt below.
    <i><script language="javascript" type="text/javascript" for="Skype" event="CallStatus(Call, Status)">
                 handleCallStatus (Call, Status);
    </script></i>
    It works locally, but not when in a BSP.
    It's rather interesting to mess with Skype calls from a webpage. Do let us know how your experience goes
    Amos

  • Javascript inside jsp

    Hi,
    is it possible to call a javascript function or can i add events like onClick, onLoad inside the body tag when the response content type is set to "response.setContentType("application/vnd.ms-excel")" ??
    Currently the issue is none of the events or javascript function calls are getting executed as soon as i set the contenttype as above. so what should i do to call the script function or call some event. Since i am novice in this particular field please explain the solution in a simple way.
    Advance thanks,
    Yours sincerely
    Raghu

    This is the setting i am making to open the file as an excel sheet.
    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-Disposition", "filename=" + "abc.xls");
    response.setHeader("Cache-Control","no-cache");
    response.setHeader("Pragma","no-cache");
    response.setDateHeader("Expires",0);
    response.addHeader("Cache-control", "no-store");
    response.addHeader("Cache-control", "max-age=0");
    Is this all right?? And after this i write the contents to the excel sheet and then i need to call a javascript function to close the child window.
    Thanx

  • How to get the status of Javascript inside a java class

    Hi,
    Can anybody let me know the way by which I can get the status of Javascript (enabled/disabled) in browser inside a Java Class.
    I do have a trick -
    <input type="hidden" name="jstatus" value="disabled">
    <input type="submit" name="submit" onClick="doChecking()">
    <script language= javascript>
    function doChecking()
    document.form.jstatus.value = "enabled";
    submit();
    Now inside our java class we can check the value of "jstatus" if it is disabled then it is disabled else it is enabled.
    Ha ha wat a stupid trick...... ;-)
    Plz let me know a real approach to determine the Javascript status.
    Cheers !!!
    Irshad

    Actually, I don't think that trick is stupid at all. Javascript and Java are normally in no way related (javascript is just plain text content to your servlets / jsp's). So a good way of getting such information to your server is submitting it, like you do.
    Another possibility would be to do it with Ajax in the background, but that all depends on what you do with the information.

  • Formguide and javascript inside a pdf

    Hello,
    I´m trying FormGuide. I realize that the behavior of the script inside an event in a pdf/template is different when the pdf is opened directly in acrobat reader or when is opened using a formguide (preview pdf).
    For instance, if I have 2 javascript alerts on the change event of a field, only the first one will be shown when the value of that field is changed in formguide.
    Another example: if at the same event I have a javascript replace funcion, when I change the field in the guideform, the event is fire as expected, but I will get an xfaxm error message...
    I thought formguide would only make a mapping between the field in the flash screen with the field on the form, but that everything else would run inside the form. However, it seems formguide is "capturing" the events and script and is running them...
    If this is true, how can I define something like a replace function?Also, How can I use floating fields in a pdf, that will be changed as some field in formguide changes?
    Thank you

    You have a number of issues that you have brought up here. This are difficult without looking at exactly what you aer doing and what script you are running. Can you post your form to [email protected]?
    I will try and answer your questions:
    The replace() is supported in Form Guides
    All script will run in the Form Guide unless you call into the PDF directly (liek when you click the buttons to email, or print)
    Floating fields are resolved at runtime and are turned into Text. They are not inetractive.
    If you are trying to get script to execute in only your guide you can use:
    if ( xfa.host.name == Flash ) {
    script to execute.
    And of course you can do the not (!=) to only execute in Reader/Acrobat.

  • Protect javascript inside the PDF from de-compilation

    Hi Guys,
    I have developed an fillable PDF using acrobat, which will publish to public. some of the input field needed to be validated using some javascript.
    When I google the de-complilation pdf, I found that some free de-compilation pdf tool and easily de-compile the pdf and my javascript can be found inside the result.
    because these javascript is sensitive that I don't want it to be exposed to public, is there anything I can do to hide the javascript?

    The Reader Extension hash won't stop someone from extracting content; it can potentially make it a little harder but if you can open a file in a non-Adobe application you can always extract content, no matter what the settings are.
    DRM is the only reliable method of file-level security as it ensures only Adobe Reader or Acrobat can be used to open it. However when a secured file is running you still have access to the console, so determined snooping remains possible.

  • Putting javascript inside WEB-INF

    I could not call a javascript function test() from JSP. my function is defined in .js file places inside WEB-INF/javascript/script.js
    and my JSP is inside WEB-INF/jsp/report.jsp. Its says object expected. I have tried all ways but could not access that function from JSP. Both javascript and jsp are inside WEB-INF folder. This is required.
    Following is the code...
    <html><head><title>Main Menu</title>
    <script type="text/javascript" src="../javascript/tabpane.js"></script>
    <link type="text/css" rel="StyleSheet" href="../css/tabpane.css" />
    </head>
    <body><h1>Report types</h1>
    <div class="tab-pane" id="tab-pane-1">
    <script language="javascript">
    test();
    </script>

    I could not call a javascript function test() from
    JSP. my function is defined in .js file places inside
    WEB-INF/javascript/script.js
    and my JSP is inside WEB-INF/jsp/report.jsp. Its says
    object expected. I have tried all ways but could not
    access that function from JSP. Both javascript and
    jsp are inside WEB-INF folder. This is required.
    Following is the code...
    <html><head><title>Main Menu</title>
    <script type="text/javascript"
    src="../javascript/tabpane.js"></script>
    <link type="text/css" rel="StyleSheet"
    href="../css/tabpane.css" />
    </head>
    <body><h1>Report types</h1>
    <div class="tab-pane" id="tab-pane-1">
    <script language="javascript">
    test();
    </script>The script element includes a client-side script into the document. Client-side script is executed by web browser in this case, while WEB-INF is an "protected" area and is not accessible to web browser. So you can not put javascripts, images and css files into WEB-INF directory.

  • Passing xml field javascript inside xsl file.

    Hi all
    I have an xml file which looks something like this....
    <SCORE>
    <SCORE_ID>D6666</SCORE_ID>
    <RYM>200701</RYM>
    <LOB>P</LOB>
    <REC_C>.38</REC_C>
    <REC_P>.17</REC_P>
    <ENV_STR>dev<ENV_STR>
    </SCORE>
    I have an xsl file which has some html and slots for the fields(for xml file), which is working very well.
    The syntax for the slots looks something like this
    <xsl:value-of select="ENV_STR"/> which is working very well.
    I want to call a javascript function (which will open a new browser) which takes three parameters and these params will be field_name from XML file.
    So I was trying to put syntax (mentioned above) inside javascript but its an error (XLM Parsing failed.)
    <AHREF="#" onclick="display_report(<xsl:value-of select="ENV_STR"/>);return false">Click for Report</A-close for HREF>
    Can anybody suggest how can I do this?
    Thanks
    pb
    Message was edited by:
    Prashant
    Message was edited by:
    Prashant

    That's an XSLT FAQ. People seem to expect XPath to support macro substitutions for some reason. You need a predicate instead, something like:
    select="*[name() = $name]/element1/element2"

  • Use javascript inside page fragment

    Im trying to use javascript code inside a page fragment with the tag
    af:resource
    But the second time the page reloads i got this error: "ReferenceError: funciona is not defined"
    <af:resource type="javascript">
          function funciona() {
              alert(123);
    </af:resource>
    Im using JDeveloper 12c

    The resource is added to the af:document component to be included when the document is rendered. The resource is only processed on the initial creation of the document.
    are you sure, af:resourse tag presence under af:document.?

  • Using javascript inside jsp

    hello
    My front end is jsp.so in jsp i want to write a javascript function for validating the form fields given by the client. so give me any simple javasript sample program....thank you.

    See: www.google.com for more information

  • AdfCustomEvent.queue fails from javascript inside af:inlineframe - how to?

    Using JDev 11g; have an ADF page with an Inline Frame component which loads a HTML page in the Project which uses some javascript and I want to be able to send a payload back to the ADF application when a client event occurs. I've therefore flagged the Inline Frame as a ClientComponent, and added a ServerListener, then added the AdfCustomEvent.queue call into the frame HTML javascript file using ...
    function choosePart(bodyPart) {
    console.log("@@ firing choosePart for " + bodyPart);
    AdfCustomEvent.queue(AdfPage.PAGE.findComponent("pt1:ifbody"), "bodyPartClicked", {pobCode:bodyPart}, false);
    ... but it returns:
    AdfPage.PAGE is undefined
    ... to the Firebug Console and doesn't make it to the server-listener. At times, it will complain about AdfCustomEvent is undefined.
    My problem seems to be that the HTML/javascript referenced by the Inline Frame doesn't know anything about the ADF context in which it operates. My options then appear to be:
    a) add something to the HTML so that it can link back to the ADF context; or call the AdfCustomEvent.queue in a different way that does this
    b) use an f:verbatim instead of the af:inlineframe, and load the HTML directly into the ADF page where this context is established. My issue with this is that the HTML doc-type on the rendered ADF page includes the "http://www.w3.org/TR/html4/loose.dtd" specification, which compromises some of the HTML functionality; so to pull this off, I'd have to diagnose/correct here; which I'd rather keep off the critical path at this point.
    So wondering if anyone might have worked a), and can describe a solution.
    Thanks.

    For the record; reading on javascript sorted this out; just needed to use a "parent" prefix, and works fine.
    parent.AdfCustomEvent.queue(parent.AdfPage.PAGE.findComponent("pt1:ifbody"), "bodyPartClicked", {pobCode:bodyPart}, false);

  • Stellent  UCM :: calling javascript inside the custom component

    Hi Experts,
    I am new to the stellent content server (Oracle content server). Currently we are working on the project which needs to be integrated with the content server for the content selection. I did some prototype to pass back the selection value to the parent window using the javascript window.opener.<parent java script> from a dummy page. Now i am customizing the content server custom component. Unfortunately i cannot be able to call back the parent javascript from the custom component. Seems the window.opener is null.
    I have tried with windowUtils.getOpener() method which is available in the content server weblayout. Still i could not be able to call back.
    Guys i am looking forward your idea ? If anyone knows the way to resolve this issue or any other best suitable way to handle this please ping me back.
    Regards Thiva

    Hi Experts,
    I am new to the stellent content server (Oracle content server). Currently we are working on the project which needs to be integrated with the content server for the content selection. I did some prototype to pass back the selection value to the parent window using the javascript window.opener.<parent java script> from a dummy page. Now i am customizing the content server custom component. Unfortunately i cannot be able to call back the parent javascript from the custom component. Seems the window.opener is null.
    I have tried with windowUtils.getOpener() method which is available in the content server weblayout. Still i could not be able to call back.
    Guys i am looking forward your idea ? If anyone knows the way to resolve this issue or any other best suitable way to handle this please ping me back.
    Regards Thiva

  • Javascript inside my servlet

    Hi all
    In my servlet I have some javascript.
    In this javascript a variable is defined.
    How can I assign the value of the javascript variable to my java variable ?
    Here is some code to further explain :
    b.append("" +" <script language=\"javascript\"> " +
    " var myLocation = window.location.href; ");
                             ??? fullUrl = myLocation ???
         System.out.println("The Full Url is : " + fullUrl);
                                  b.append("" +
         "          alert(myLocation); " +
         " </script> ");

    I see no other way than to call your servlet with the javascript variable-value in the post/get statement.
    Regards mb

  • Calling javascript inside inline frame.

    How do I call a java script method which is on a page that is embedded in a RichInlineFrame?
    I'm using Jdeveloper 11g, JSP and JSFF pages and ADF faces.

    currenly , your JSPX will not recognize javascript included in the (map.jsp)
    Try putting your setIService('serviceName') function into parent page (JSPX) and it should call that function
    I think you want to refresh your iframe page (map.jsp) when user presses the button on the main page
    please let me know, how it goes one
    regards,

  • Open link in background when anchor's attribute "href" contains javascript

    Hi community,
    I support web enterprise-level application with some legacy parts, where some windows are opened by using window.open command inside of anchor's href attribute. (e.g. <a href="javascript:MyFunction('../someurl', '2')" ../> ... function MyFunction(url,
    id) { window.open(url, id) ...)
    Now I have to open link in the background by pressing ctrl + click (or middle click), but for IE (9, 10, 11) it always becomes focused.
    Are there any ways to open those new tabs in the background (only when ctrl is pressed)? 
    P.S. I know that it would be better to provide actual link inside of href attribute, but unfortunatelly I don't have such options, due to application specific.
    Thank you in advace for your help!

    Hi Rob,
    thank you a lot for reply!
    I think mine issue not related to security and popup blocker settings. What I try to achieve is similar behaviour as we have for links (<a>) with href attribute fullfilled with actual url. Specifically
    * by single click new tab should be opened focused (this is fine)
    * by shift + click it should be opened in new browser window (this is also fine)
    * by middle (ctrl + click) new tab should be opened in background. This feature doesn't work well, because new tab alway opens focused and this is what I'm trying to fix, or at least find official proof that IE works in this way with javascript
    inside href attribute
    Here is example:
    http://jsfiddle.net/hj3gud9j/
    It works as expected in chrome but not in IE
    Yours sincerely, 
    Eugene Novykov

Maybe you are looking for

  • Reg. lengh of header of alv grid.....have ur points.

    Hi all, -I want to show text on the right side of the header of ALV grid. -Secondly i have limit of around 60 characters in a line...i want to add more words in the same line..... <b>see the code...here..</b>   wa_listheader-typ = 'S'.   wa_listheade

  • Magic Mouse on Magic Charger

    The Magic Mouse that I use loses the connection after a few minutes of use. I must then shut it of and restart it again to be discovered. There seems to be no problem with Magic Charger, though I feel there might be a link to the "dropping" question.

  • Order-related intercompany

    Dear All, Can some one provide some details regarding the Order-related intercompany billing? Regards Sandeep

  • Printing envelopes

    I have a Photosmart Premium 309g and am using Windows 7 (this also happened with XP). I cannot get my printer to print half fold card envelopes from Hallmark Card Studio 2007 or 2010 Deluxe. I used to have a 1350 and it printed the envelopes just fin

  • Como configurar mi iPod con mi telefono

    CComo utilizar mi iPod con mi teléfono cell