• Pradeep Bandarpalli
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
Hi,
My requirement is to zip the content in client side controller using javascript library JSZIP, i have included it as a static resource. Below is the code. 

Component:
<aura:component >
    
    <ltng:require scripts="/resource/jszip" />
    
    <ui:button label="Press" press="{!c.onPress}" />
    
</aura:component>

Controller: 
({
onPress : function(component) {
        var packageXml = '<?xml version="1.0" encoding="UTF-8"?>' + 
            '<Package xmlns="http://soap.sforce.com/2006/04/metadata">' +
            '<version>35.0</version>' +
            '</Package>' ;
        
        zipFile = new JSZip();
        zipFile.file('package.xml',packageXml,{base64: 'true'});
        var data = zipFile.generate();
        alert(data);
}
})

I click on Press button, while locker service is enabled I am facing issue and when Locker service disabled the alert is showed as expected (attached the outputs).

Locker service enabled:
When locker service enabled

Locker service disabled:
When locker service disabled
Thank you for help.
HI,
I have a simple requirement, get a list of custom object records from client side controller and display it on the page. Below is my code

I have a wrapper object created and used in the component attribute as type.

Wrapper Class:
public class DemoWrpClass {
    
    @AuraEnabled 
    public String compName;
    
    @AuraEnabled
    public String compType;
    
    public DemoWrpClass() {
    }
    
}

Component:
<aura:component >
    <aura:attribute name="items" type="DemoWrpClass[]" />
    
    <ui:button label="Press" press="{!c.onPress}" />
    
    <aura:iteration items="{!v.items}" var="item">
        <p>{!item.compName}</p>
        <p>{!item.compType}</p>
        <br />
    </aura:iteration>
    
</aura:component>

Controller:
({
    onPress : function(component) {
        var items = [];
        for(var i=0;i<5;i++){
            var item = [];
            item.compName = "Name"+i;
            item.compType = "Type"+i;
            items.push(item);
        }
        component.set("v.items", items);
    }
})

I am the getting the result when Locker Service is disabled, below is the image
Expected Output
But when the Locker service is enabled I am not getting any output, result is blank. Through Lightning CLI I got to know the error is Invalid SecureWindow API, now I dont understand how to implement SecureWindow in my code here. I want the expected output when Locker service is enabled. Please help. Thanks in advance.
HI,
I have a requirement to create a new Event from a custom lightning component. the code i used is below

<aura:component >
 <aura:attribute name="newEvent" type="Event"
                    default="{ 'sobjectType': 'Event',
                             'Subject':'',
                             'Description':''
                             }"/>
<div>
<ui:inputText aura:id="subject" class="slds-input" value="{!v.newEvent.Subject}"
                                                      placeholder="Enter Subject"/>
<ui:inputTextArea aura:id="comment" class="slds-input" value="{!v.newEvent.Description}" 
                                                          placeholder="provide your comments"/>
<button class="slds-button slds-button--neutral" onclick="{!c.cancel}">Cancel</button>
<button class="slds-button slds-button--neutral slds-button--brand" onclick="{!c.save}">Save</button>
</div>
</aura:component>

---controller----
({
    save : function(component) {
        var event = component.get("v.newEvent");
        window.alert(event);        //getting undefined
}
})

I am getting values as undefined. In case if I use sObject as Task instead of an Event, this is working Good and values passed are getting displayed. Is this due to the confusion between lightning events and sObject Event or anything ? Any help here is very much appreciated.
Thank You!
HI, 
I have a requirement when a certain location is searched, I want its latitude and longitude details and a marker pointing on the map. I have tried with L.GeoSearch and L.Control.Geocoder.Nominatim() but nothing worked for me. Any help here is very much appreciated.

My code with L.GeoSearch
---Component----
<aura:component >
 <aura:attribute name="map" type="Object"/>
     <ltng:require styles="/resource/leaflet/leaflet.css,
                          /resource/lgeosearch/l.geosearch.css" />
    <ltng:require scripts="/resource/leaflet/leaflet.js,
                           /resource/lgeosearch/l.control.geosearch.js,
                           /resource/lgeosearch/l.geosearch.provider.openstreetmap.js"
                  afterScriptsLoaded="{!c.jsLoaded}"/>
    <div id="map"></div>
</aura:component>

---Controller----
({
    jsLoaded : function(component, event, helper) {
        var osmTileUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
        var basemap = new L.TileLayer(osmTileUrl, {maxZoom: 18});
        var map = new L.Map('map', {
            layers: [basemap],
            center: new L.LatLng(53.2, 5.8), zoom: 12
        });
        new L.Control.GeoSearch({
            provider: new L.GeoSearch.Provider.Google()
        }).addTo(map);
        var googleGeocodeProvider = new L.GeoSearch.Provider.Google(),
            addressText = 'Amsterdam';
      googleGeocodeProvider.GetLocations( addressText, function ( results ) {
            latLng= new L.LatLng(results[0].center.lat, results[0].center.lng);
            marker = new L.Marker (latLng);
            map.addlayer(marker);
});

code with Control.Geocoder:
<aura:component >
<aura:attribute name="map" type="Object"/>
  <ltng:require styles="/resource/leaflet/leaflet.css,
                          /resource/leafletcontrolgeocoder/Control.Geocoder.css" />
    <ltng:require scripts="/resource/leaflet/leaflet.js,
                           /resource/leafletcontrolgeocoder/Control.Geocoder.js"
                  afterScriptsLoaded="{!c.jsLoaded}"/>
    <div id="map"></div>
</aura:component>

controller:
({
    jsLoaded : function(component, event, helper) {
        var map = L.map('map').setView([17.3700, 78.4800], 12);
        L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
            attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
        }).addTo(map);
        geocoder = new L.Control.Geocoder.Nominatim();
        window.alert(geocoder);
        var yourQuery = "New York NY";
        geocoder.geocode(yourQuery, function(results) {
            latLng= new L.LatLng(results[0].center.lat, results[0].center.lng);
            marker = new L.Marker (latLng);
            map.addlayer(marker);
        });
        component.set("v.map", map);
        }
    }

---CSS---> width:100%; height:100%;

Where I am going wrong? Thank you for your support.
Hi,
My requirement is to zip the content in client side controller using javascript library JSZIP, i have included it as a static resource. Below is the code. 

Component:
<aura:component >
    
    <ltng:require scripts="/resource/jszip" />
    
    <ui:button label="Press" press="{!c.onPress}" />
    
</aura:component>

Controller: 
({
onPress : function(component) {
        var packageXml = '<?xml version="1.0" encoding="UTF-8"?>' + 
            '<Package xmlns="http://soap.sforce.com/2006/04/metadata">' +
            '<version>35.0</version>' +
            '</Package>' ;
        
        zipFile = new JSZip();
        zipFile.file('package.xml',packageXml,{base64: 'true'});
        var data = zipFile.generate();
        alert(data);
}
})

I click on Press button, while locker service is enabled I am facing issue and when Locker service disabled the alert is showed as expected (attached the outputs).

Locker service enabled:
When locker service enabled

Locker service disabled:
When locker service disabled
Thank you for help.
HI,
I have a requirement to create a new Event from a custom lightning component. the code i used is below

<aura:component >
 <aura:attribute name="newEvent" type="Event"
                    default="{ 'sobjectType': 'Event',
                             'Subject':'',
                             'Description':''
                             }"/>
<div>
<ui:inputText aura:id="subject" class="slds-input" value="{!v.newEvent.Subject}"
                                                      placeholder="Enter Subject"/>
<ui:inputTextArea aura:id="comment" class="slds-input" value="{!v.newEvent.Description}" 
                                                          placeholder="provide your comments"/>
<button class="slds-button slds-button--neutral" onclick="{!c.cancel}">Cancel</button>
<button class="slds-button slds-button--neutral slds-button--brand" onclick="{!c.save}">Save</button>
</div>
</aura:component>

---controller----
({
    save : function(component) {
        var event = component.get("v.newEvent");
        window.alert(event);        //getting undefined
}
})

I am getting values as undefined. In case if I use sObject as Task instead of an Event, this is working Good and values passed are getting displayed. Is this due to the confusion between lightning events and sObject Event or anything ? Any help here is very much appreciated.
Thank You!
HI, 
I have a requirement when a certain location is searched, I want its latitude and longitude details and a marker pointing on the map. I have tried with L.GeoSearch and L.Control.Geocoder.Nominatim() but nothing worked for me. Any help here is very much appreciated.

My code with L.GeoSearch
---Component----
<aura:component >
 <aura:attribute name="map" type="Object"/>
     <ltng:require styles="/resource/leaflet/leaflet.css,
                          /resource/lgeosearch/l.geosearch.css" />
    <ltng:require scripts="/resource/leaflet/leaflet.js,
                           /resource/lgeosearch/l.control.geosearch.js,
                           /resource/lgeosearch/l.geosearch.provider.openstreetmap.js"
                  afterScriptsLoaded="{!c.jsLoaded}"/>
    <div id="map"></div>
</aura:component>

---Controller----
({
    jsLoaded : function(component, event, helper) {
        var osmTileUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
        var basemap = new L.TileLayer(osmTileUrl, {maxZoom: 18});
        var map = new L.Map('map', {
            layers: [basemap],
            center: new L.LatLng(53.2, 5.8), zoom: 12
        });
        new L.Control.GeoSearch({
            provider: new L.GeoSearch.Provider.Google()
        }).addTo(map);
        var googleGeocodeProvider = new L.GeoSearch.Provider.Google(),
            addressText = 'Amsterdam';
      googleGeocodeProvider.GetLocations( addressText, function ( results ) {
            latLng= new L.LatLng(results[0].center.lat, results[0].center.lng);
            marker = new L.Marker (latLng);
            map.addlayer(marker);
});

code with Control.Geocoder:
<aura:component >
<aura:attribute name="map" type="Object"/>
  <ltng:require styles="/resource/leaflet/leaflet.css,
                          /resource/leafletcontrolgeocoder/Control.Geocoder.css" />
    <ltng:require scripts="/resource/leaflet/leaflet.js,
                           /resource/leafletcontrolgeocoder/Control.Geocoder.js"
                  afterScriptsLoaded="{!c.jsLoaded}"/>
    <div id="map"></div>
</aura:component>

controller:
({
    jsLoaded : function(component, event, helper) {
        var map = L.map('map').setView([17.3700, 78.4800], 12);
        L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
            attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
        }).addTo(map);
        geocoder = new L.Control.Geocoder.Nominatim();
        window.alert(geocoder);
        var yourQuery = "New York NY";
        geocoder.geocode(yourQuery, function(results) {
            latLng= new L.LatLng(results[0].center.lat, results[0].center.lng);
            marker = new L.Marker (latLng);
            map.addlayer(marker);
        });
        component.set("v.map", map);
        }
    }

---CSS---> width:100%; height:100%;

Where I am going wrong? Thank you for your support.
i am trying to build a lightning component that shows nearby contacts based on the users current location. i am getting an error when trying to access the users current location through navigator.geoLocation. I get the following error.
"Uncaught error in actionCallback : navigator.geoLocation is undefined"

Here is my component and its controller logic.

Component:
<aura:component >
    
   <aura:attribute name="latitude" type="Decimal"/>
    <aura:attribute name="longitude" type="Decimal"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
  
</aura:component>
Controller:
({
	doInit : function(component, event, helper) {
        if(navigator.geoLocation){
            console.log("capability is there");
            
        }else{
            console.log("No Capability");
        }
        navigator.geoLocation.getCurrentPosition(function(position){
            this.latitude=component.set("v.latitude",position.coords.latitude);
            this.longitude=component.set("v.longitude", position.coords.longitude);
            console.log("Latitude is:"+this.latitude);
            console.log("Longitude is:" +this.longitude);
        });
		
	}
})
debugging  console log shows that my else part is only written to console. does that mean that geolocation is not supported in lightning? Am i doing anything wrong ? Any help would be appreciated.