Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

Generic Service Mappings - can't map the array pointer

I have a generic service which returns an array of JSON objects. when I try to map the array pointer $ to the list component, it will not map (lst name does not change green)

My Javascript:

pre
Appery.areas = Appery.createClass(null, {

Code: Select all

 init : function(requestOptions) { 
     this.__requestOptions = $.extend({}, requestOptions); 
     console.log("request options: ",this.__requestOptions); 
 }, 

 process : function(settings) { 
     settings.beforeSend(settings); 
     if (this.__requestOptions.echo) { 
         settings.success(this.__requestOptions.echo); 
     } else { 
         console.log('Default implementation is used. Please define your own.'); 
         var areas = [ 
             "AB (Aberdeen)", 
             "AL (St. Albans)", 
             "B (Birmingham)", 
             "BA (Bath)", 
             "BB (Blackburn)", 
             "BD (Bradford)", 
             "BH (Bournemouth)", 
             "BL (Bolton)", 
             "BN (Brighton)", 
             "BR (Bromley)", 
             "BS (Bristol)", 
             "CA (Carlisle)", 
             "CB (Cambridge)", 
             "CF (Cardiff)", 
             "CH (Chester)", 
             "CM (Chelmsford)", 
             "CO (Colchester)", 
             "CR (Croydon)", 
             "CT (Canterbury)", 
             "CV (Coventry)", 
             "CW (Crewe)", 
             "DA (Dartford)", 
             "DD (Dundee)", 
             "DE (Derby)", 
             "DH (Durham)", 
             "DG (Dumfries)", 
             "DL (Darlington)", 
             "DN (Doncaster)", 
             "DT (Dorchester)", 
             "DY (Dudley)", 
             "E (East London)", 
             "EC (East Central London)", 
             "EH (Edinburgh)", 
             "EN (Enfield)", 
             "EX (Exeter)", 
             "FK (Falkirk)", 
             "FY (Blackpool)", 
             "G (Glasgow)", 
             "GL (Gloucester)", 
             "GU (Guildford)", 
             "HA (Harrow)", 
             "HD (Huddersfield)", 
             "HG (Harrogate)", 
             "HP (Hemel Hempstead)", 
             "HR (Hereford)", 
             "HU (Hull)", 
             "HX (Halifax)", 
             "IG (Ilford)", 
             "IP (Ipswich)", 
             "IV (Inverness)", 
             "KA (Kilmarnock)", 
             "KT (Kingston upon Thames)", 
             "KY (Kirkcaldy)", 
             "GU (Guildford)", 
             "L (Liverpool)", 
             "LA (Lancaster)", 
             "LD (Llandrindod)", 
             "LE (Leicester)", 
             "LL (Wales postcodes)", 
             "LN (Lincoln)", 
             "LS (Leeds)", 
             "LU (Luton)", 
             "M (Manchester)", 
             "ME (Medway)", 
             "ML (Motherwell)", 
             "MK (Milton Keynes)", 
             "N (North London)", 
             "NE (Newcastle)", 
             "NG (Nottingham)", 
             "NN (Northampton)", 
             "NP (Newport)", 
             "NR (Norwich)", 
             "NW (North West London)", 
             "OL (Oldham)", 
             "OX (Oxford)", 
             "PA (Paisley)", 
             "PE (Peterborough)", 
             "PH (Perth)", 
             "PL (Plymouth)", 
             "PO (Portsmouth)", 
             "PR (Preston)", 
             "RG (Reading)", 
             "RH (Redhill)", 
             "RM (Romford)", 
             "S (Sheffield)", 
             "SA (Swansea)", 
             "SE (South East London)", 
             "SG (Stevenage)", 
             "SK (Stockport)", 
             "SL (Slough)", 
             "SM (Sutton)", 
             "SN (Swindon)", 
             "SO (Southampton)", 
             "SP (Salisbury)", 
             "SR (Sunderland)", 
             "SS (Southend on Sea)", 
             "ST (Stoke-on-Trent)", 
             "SW (South West London)", 
             "SY (Shrewsbury)", 
             "TA (Taunton)", 
             "TD (Galasheils)", 
             "TF (Telford)", 
             "TN (Tonbridge)", 
             "TQ (Torquay)", 
             "TR (Truro)", 
             "TS (Cleveland)", 
             "TW (Twickenham)", 
             "UB (Southall)", 
             "WA (Warrington)", 
             "W (West London)", 
             "WC (West Central London)", 
             "WD (Watford)", 
             "WF (Wakefield)", 
             "WN (Wigan)", 
             "WR (Worcester)", 
             "WS (Walsall)", 
             "WV (Wolverhampton)", 
             "YO (York)" 
         ]; 

         var responseData = ""; 

         //lines separated by a comma 
         for (var i = 0; i < areas&#46;length - 1; i++) { 
             responsedata += '{"area" : "' + area[i] + '"},'; 
         } 
         &#47;&#47;last line no comma 
         responseData += '{"area" : "' + area[areas&#46;length -1] + '"}'; 

         settings&#46;success([ 
             responseData 
         ]); 
     } 
     settings&#46;complete('success'); 
 } 

});/pre

Service Response definition:

Image

My Mappings:

Image

(By the way this is the third time I have tried to post this question but it keeps entering a black hole)

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Generic Service Mappings - can't map the array pointer

Hi Terry,

Your post was blocked as it has many html code inserts. Do you need any further assistance here?

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

Generic Service Mappings - can't map the array pointer

emThis reply was created from a merged topic originally titled Generic Service./em

I have tried to create a Generic rest service containind a list of areas return ed as an array.

I am using the visual editor to map the array to a list component, but i can't map the array pointer ${i} to the list component.

Service response:

Image

Mapping:

Image

My javascript

preAppery&#46;areas = Appery&#46;createClass(null, {

Code: Select all

init : function(requestOptions) { 
    this&#46;__requestOptions = $&#46;extend({}, requestOptions); 
    console&#46;log("request options: ",this&#46;__requestOptions); 
}, 

process : function(settings) { 
    settings&#46;beforeSend(settings); 
    if (this&#46;__requestOptions&#46;echo) { 
        settings&#46;success(this&#46;__requestOptions&#46;echo); 
    } else { 
        console&#46;log('Default implementation is used&#46; Please define your own&#46;'); 
        var areas = [ 
            "AB (Aberdeen)", 
            "AL (St&#46; Albans)", 
            "B (Birmingham)", 
            "BA (Bath)", 
            "BB (Blackburn)", 
            "BD (Bradford)", 
            "BH (Bournemouth)", 
            "BL (Bolton)", 
            "BN (Brighton)", 
            "BR (Bromley)", 
            "BS (Bristol)", 
            "CA (Carlisle)", 
            "CB (Cambridge)", 
            "CF (Cardiff)", 
            "CH (Chester)", 
            "CM (Chelmsford)", 
            "CO (Colchester)", 
            "CR (Croydon)", 
            "CT (Canterbury)", 
            "CV (Coventry)", 
            "CW (Crewe)", 
            "DA (Dartford)", 
            "DD (Dundee)", 
            "DE (Derby)", 
            "DH (Durham)", 
            "DG (Dumfries)", 
            "DL (Darlington)", 
            "DN (Doncaster)", 
            "DT (Dorchester)", 
            "DY (Dudley)", 
            "E (East London)", 
            "EC (East Central London)", 
            "EH (Edinburgh)", 
            "EN (Enfield)", 
            "EX (Exeter)", 
            "FK (Falkirk)", 
            "FY (Blackpool)", 
            "G (Glasgow)", 
            "GL (Gloucester)", 
            "GU (Guildford)", 
            "HA (Harrow)", 
            "HD (Huddersfield)", 
            "HG (Harrogate)", 
            "HP (Hemel Hempstead)", 
            "HR (Hereford)", 
            "HU (Hull)", 
            "HX (Halifax)", 
            "IG (Ilford)", 
            "IP (Ipswich)", 
            "IV (Inverness)", 
            "KA (Kilmarnock)", 
            "KT (Kingston upon Thames)", 
            "KY (Kirkcaldy)", 
            "GU (Guildford)", 
            "L (Liverpool)", 
            "LA (Lancaster)", 
            "LD (Llandrindod)", 
            "LE (Leicester)", 
            "LL (Wales postcodes)", 
            "LN (Lincoln)", 
            "LS (Leeds)", 
            "LU (Luton)", 
            "M (Manchester)", 
            "ME (Medway)", 
            "ML (Motherwell)", 
            "MK (Milton Keynes)", 
            "N (North London)", 
            "NE (Newcastle)", 
            "NG (Nottingham)", 
            "NN (Northampton)", 
            "NP (Newport)", 
            "NR (Norwich)", 
            "NW (North West London)", 
            "OL (Oldham)", 
            "OX (Oxford)", 
            "PA (Paisley)", 
            "PE (Peterborough)", 
            "PH (Perth)", 
            "PL (Plymouth)", 
            "PO (Portsmouth)", 
            "PR (Preston)", 
            "RG (Reading)", 
            "RH (Redhill)", 
            "RM (Romford)", 
            "S (Sheffield)", 
            "SA (Swansea)", 
            "SE (South East London)", 
            "SG (Stevenage)", 
            "SK (Stockport)", 
            "SL (Slough)", 
            "SM (Sutton)", 
            "SN (Swindon)", 
            "SO (Southampton)", 
            "SP (Salisbury)", 
            "SR (Sunderland)", 
            "SS (Southend on Sea)", 
            "ST (Stoke-on-Trent)", 
            "SW (South West London)", 
            "SY (Shrewsbury)", 
            "TA (Taunton)", 
            "TD (Galasheils)", 
            "TF (Telford)", 
            "TN (Tonbridge)", 
            "TQ (Torquay)", 
            "TR (Truro)", 
            "TS (Cleveland)", 
            "TW (Twickenham)", 
            "UB (Southall)", 
            "WA (Warrington)", 
            "W (West London)", 
            "WC (West Central London)", 
            "WD (Watford)", 
            "WF (Wakefield)", 
            "WN (Wigan)", 
            "WR (Worcester)", 
            "WS (Walsall)", 
            "WV (Wolverhampton)", 
            "YO (York)" 
        ]; 

        var responseData = ""; 

        &#47;&#47;lines separated by a comma 
        for (var i = 0; i < areas&#46;length - 1; i++) { 
            responsedata += '{"area" : "' + area[i] + '"},'; 
        } 
        &#47;&#47;last line no comma 
        responseData += '{"area" : "' + area[areas&#46;length -1] + '"}'; 

        settings&#46;success([ 
            responseData 
        ]); 
    } 
    settings&#46;complete('success'); 
} 

});/pre

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Generic Service Mappings - can't map the array pointer

Hello,

Please use a mapping arrow $-mobilelistitem_9 instead of $-mobilelist_8
It is possible to use a mapping from $ to components-containers (listitem, grid, html, checkbox, radiobutton), but not a single components (list, label, image, etc)

Return to “Issues”