Skip to main content
Delete spurious new
Source Link
Keith C
  • 137.3k
  • 29
  • 218
  • 458

If you add this method to your page's controller:

global with sharing class MyController {
    @RemoteAction
    global static String findLocation(String city, String country) {
         // Execute Apex logic here using only "city" and "country"
         return ...
    }
}

then Visualforce will generate a JavaScript function (named MyController.findLocation) that you can just call e.g. from your other findLocation function:

function findLocation() {
    var city;
    var country;
    ...
    MyController.findLocation(city, country, new function(result, event) {
        // Set the inputField value to the result in here
    });
    ...
}

This is the JavaScript Remoting for Apex Controllers approach mentioned in Seb__Wagner's answer. It has the (performance) advantage that no view state is transmitted: you just pass the values needed and it performs its action and returns the result (via a callback function).

If you add this method to your page's controller:

global with sharing class MyController {
    @RemoteAction
    global static String findLocation(String city, String country) {
         // Execute Apex logic here using only "city" and "country"
         return ...
    }
}

then Visualforce will generate a JavaScript function (named MyController.findLocation) that you can just call e.g. from your other findLocation function:

function findLocation() {
    var city;
    var country;
    ...
    MyController.findLocation(city, country, new function(result, event) {
        // Set the inputField value to the result in here
    });
    ...
}

This is the JavaScript Remoting for Apex Controllers approach mentioned in Seb__Wagner's answer. It has the (performance) advantage that no view state is transmitted: you just pass the values needed and it performs its action and returns the result (via a callback function).

If you add this method to your page's controller:

global with sharing class MyController {
    @RemoteAction
    global static String findLocation(String city, String country) {
         // Execute Apex logic here using only "city" and "country"
         return ...
    }
}

then Visualforce will generate a JavaScript function (named MyController.findLocation) that you can just call e.g. from your other findLocation function:

function findLocation() {
    var city;
    var country;
    ...
    MyController.findLocation(city, country, function(result, event) {
        // Set the inputField value to the result in here
    });
    ...
}

This is the JavaScript Remoting for Apex Controllers approach mentioned in Seb__Wagner's answer. It has the (performance) advantage that no view state is transmitted: you just pass the values needed and it performs its action and returns the result (via a callback function).

added 2 characters in body
Source Link
Keith C
  • 137.3k
  • 29
  • 218
  • 458

If you add this method to your page's controller:

global with sharing class MyController {
    @RemoteAction
    global static String findLocation(String city, String country) {
         // Execute Apex logic here using only "city" and "country"
         return ...
    }
}

then Visualforce will generate a JavaScript function (named MyController.findLocation) that you can just call e.g. from your other findLocationfindLocation function:

function findLocation() {
    var city;
    var country;
    ...
    MyController.findLocation(city, country, new function(result, event) {
        // Set the inputField value to the result in here
    });
    ...
}

This is the JavaScript Remoting for Apex Controllers approach mentioned in Seb__Wagner's answer. It has the (performance) advantage that no view state is transmitted: you just pass the values needed and it performs its action and returns the result (via a callback function).

If you add this method to your page's controller:

global with sharing class MyController {
    @RemoteAction
    global static String findLocation(String city, String country) {
         // Execute Apex logic here using only "city" and "country"
         return ...
    }
}

then Visualforce will generate a JavaScript function (named MyController.findLocation) that you can just call e.g. from your other findLocation function:

function findLocation() {
    var city;
    var country;
    ...
    MyController.findLocation(city, country, new function(result, event) {
        // Set the inputField value to the result in here
    });
    ...
}

This is the JavaScript Remoting for Apex Controllers approach mentioned in Seb__Wagner's answer. It has the (performance) advantage that no view state is transmitted: you just pass the values needed and it performs its action and returns the result (via a callback function).

If you add this method to your page's controller:

global with sharing class MyController {
    @RemoteAction
    global static String findLocation(String city, String country) {
         // Execute Apex logic here using only "city" and "country"
         return ...
    }
}

then Visualforce will generate a JavaScript function (named MyController.findLocation) that you can just call e.g. from your other findLocation function:

function findLocation() {
    var city;
    var country;
    ...
    MyController.findLocation(city, country, new function(result, event) {
        // Set the inputField value to the result in here
    });
    ...
}

This is the JavaScript Remoting for Apex Controllers approach mentioned in Seb__Wagner's answer. It has the (performance) advantage that no view state is transmitted: you just pass the values needed and it performs its action and returns the result (via a callback function).

Source Link
Keith C
  • 137.3k
  • 29
  • 218
  • 458

If you add this method to your page's controller:

global with sharing class MyController {
    @RemoteAction
    global static String findLocation(String city, String country) {
         // Execute Apex logic here using only "city" and "country"
         return ...
    }
}

then Visualforce will generate a JavaScript function (named MyController.findLocation) that you can just call e.g. from your other findLocation function:

function findLocation() {
    var city;
    var country;
    ...
    MyController.findLocation(city, country, new function(result, event) {
        // Set the inputField value to the result in here
    });
    ...
}

This is the JavaScript Remoting for Apex Controllers approach mentioned in Seb__Wagner's answer. It has the (performance) advantage that no view state is transmitted: you just pass the values needed and it performs its action and returns the result (via a callback function).