I am new with VisualForce and I am trying to get a list of objects from Apex to my VisualForce file.
My Apex class is this:
public class MapCECompleto_Controller {
List<Object> results;
public static String GOOGLE_MAPS_API = 'https://maps.googleapis.com/maps/api/js?key=';
public static String getGoogleMapsApi(){
String developerNameIntegracion = 'Google_' + Label.SalesforceOrg; //Google_dev
String authToken = IntegracionHelperClass.getAuthToken(developerNameIntegracion);
String googleMapsURLWithToken = GOOGLE_MAPS_API + authToken;
System.debug('googleMapsURLWithToken ---- '+ googleMapsURLWithToken);
return googleMapsURLWithToken;
}
@RemoteAction
public static PageReference getCompleteList(){
List<Object> recordsToReturn = new List<Object>();
List<SObject1> listOne = [SELECT Id,Direccion__c, Estado__c, Name FROM SObject1];
if(!listOne.isEmpty()){
for(SObject1 iItem: listOne){
if(iItem.Estado__c == HelperClass.ESTADO_ACTIVADO){
Map<String, Object> oneMap = new Map<String, Object>();
oneMap.put('Name', iItem.Name);
oneMap.put('Direccion', iItem.Direccion__c);
oneMap.put('Objeto', 'Object 1');
oneMap.put('Id',iItem.Id );
recordsToReturn.add(oneMap);
}
}
}
List<SObject2> listTwo = [SELECT Id,EstadoSolicitud__c,Direccion__c,, Name, FROM SObject2];
if(!listTwo.isEmpty()){
for(SObject2 iItem: listTwo){
if(iItem.EstadoSolicitud__c == HelperClass.ESTADO_NUEVA || iItem.EstadoSolicitud__c == HelperClass.ESTADO_EN_GESTION){
Map<String, Object> twoMap = new Map<String, Object>();
twoMap.put('Name',iItem.Name );
twoMap.put('Direccion', iItem.Direccion__c);
twoMap.put('Objeto','Object 2');
twoMap.put('Id',iItem.Id );
recordsToReturn.add(twoMap);
}
}
}
List<SObject3> listThree = [SELECT Id,Direccion__c, Name FROM SObject3 LIMIT 3];
if(!listThree.isEmpty()){
for(SObject3 iItem: listThree){
Map<String, Object> threeMap = new Map<String, Object>();
threeMap.put('Name', iItem.Name);
threeMap.put('Direccion',iItem.Direccion__c);
threeMap.put('Objeto','Object 3');
threeMap.put('Id',iItem.Id);
recordsToReturn.add(threeMap);
}
}
List<SObject4> listFour = [SELECT Id, Direccion__c, Name FROM SObject4 LIMIT 3];
if(!listFour.isEmpty()){
for(SObject4 iItem :listFour){
Map<String, Object> fourthMap = new Map<String, Object>();
fourthMap.put('Name', iItem.Name);
fourthMap.put('Direccion',iItem.Direccion__c);
fourthMap.put('Objeto','Object 4');
fourthMap.put('Id',iItem.Id);
recordsToReturn.add(fourthMap);
}
}
System.debug('recordsToReturn ------ '+ recordsToReturn);
results = recordsToReturn;
return null;
}
}
And my VF file:
<apex:page controller="MapCECompleto_Controller" action=" {!getCompleteList}">
<apex:pageBlock title="Transactions">
<head>
<script type="text/javascript" src="{!googleMapsApi}"></script>
<script type="text/javascript">
$(document).ready(
function(){
var myOptions= {
zoom: 20,
mapTypeId: google.maps.MapTypeId.HYBRID,
mapTypeControl: true
}
var map;
var marker;
var geocoder = new google.maps.Geocoder();
var nombre = '';
console.log('aqui1');
Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.QX_VF_MapCECompleto_Controller.getListaDatosCompletos}',function(result, event){
}
}
)
</script>
<style>
#map{
font-family: Arial;
font-size: 12px;
line-height: normal !important;
height: 500px;
background: transparent;
}
</style>
</head>
<body>
<div id='map'></div>
</body>
</apex:pageBlock>
</apex:page>
But the problem is that when I save the file I inmidiatly get this error message that I have not being able to solve: Return type of an Apex action method must be a PageReference. Found: core.apexpages.el.adapters.ApexListELAdapter