I'm trying to get an obj model parsed for webGL content. I'm using Java Spring with thymeleaf and have my resource as an obj file in my resources/static/ folder. I need to get the contents of the obj file as a string to parse it in the javascript on the html web page and feed it into my WebGL, but I'm not sure on how to access it.  Do I need to do an ajax html call to return the data as a JSON? Or is there a way of just accessing that resource from the URL similar to embedding an image on a webpage.  I'm quite new to this web development business, so it might sound dumb but I am stuck here.  Thank you.
26387
I have a text file in the root of my web app  and I'd like to load it into a variable in javascript.. in groovy I would do this:  def fileContents = 'http://localhost/foo.txt'.toURL().text; println fileContents;   How can I get a similar result in javascript?
114745
I am trying to Preview and download document from LWC, From apex controller i am returning Map&lt;> contains ID and Document name, and iteration that map data in html file and passing map.key value to href url, but dynamic is not populating in URL.    &lt;template for:each={mapData} for:item="mapkey"&gt;                            Test: {mapkey.key}                                                         &lt;lightning-button-icon key={mapkey} icon-name="utility:download"  variant="bare" alternative-text="Settings"&gt;&lt;/lightning-button-icon&gt;                                &lt;a key={mapkey} style="color: #000000"  href ="/sfc/servlet.shepherd/document/download/{mapkey.Key}?operationContext=S1" target="_blank" preview= "{mapkey.value}"&gt;{mapkey.value}&lt;/a&gt;                          &lt;/template&gt;    JS Code:      .then(data =&gt; {            /// var conts = data;                   console.log('data map---&gt;'+data);     if(data){     // eslint-disable-next-line guard-for-in     for(let key in data) {    this.mapData.push({value: data[key], key:key}); //Here we are creating the array to show on UI.    }       } })   Apex Code:   @auraenabled /* Method will return a Map Contains Document ID and Name */ public static Map&lt;string,string&gt; getUrls( string searchstr){     Map&lt;string,string&gt; contdocidandtitle = new Map&lt;string,string&gt;();     system.debug('searchstr'+searchstr);             For(Document cd :[select id,folderid,name from document where folder.name =:searchstr]){         contdocidandtitle.put(cd.id,cd.name);                 }     return contdocidandtitle; }   Error is: sfc/servlet.shepherd/document/download/%7Bmapkey.Key%7D?operationContext=S1 in URL "mapkey.key" priniting instead of ID Help me with valuable suggestions.
39661
I created rest resource plugin in a custom module and need to send some JSON data with the request, and access it in the post function. At the moment my post function does not do anything but return some dummy JSON data so I know it is working.  It seems that whenever I try to pass JSON data with the request, it will give me this error: "Could not denormalize object of type , no supporting normalizer found."  If I then try to get this data using file_get_contents('php://input'), it will give me a 403 forbidden error. But if I try to return the same data that I get from file_get_contents('php://input') from the post function, I get the normalizer error again.  I wasn't able to find much information on even making this REST resource and even less on this issue now, so if anyone has any input I would greatly appreciate it, thanks!
17511
So this seems pretty basic but I can't get it to work.  I have an Object, and I am using reflection to get to it's public properties.  One of these properties is static and I'm having no luck getting to it.  Public Function GetProp(ByRef obj As Object, ByVal propName as String) as PropertyInfo     Return obj.GetType.GetProperty(propName)  End Function   The above code works fine for Public Instance properties, which up until now is all that I have needed.  Supposedly I can use BindingFlags to request other types of properties (private, static), but I can't seem to find the right combination.  Public Function GetProp(ByRef obj As Object, ByVal propName as String) as PropertyInfo     Return obj.GetType.GetProperty(propName, Reflection.BindingFlags.Static Or Reflection.BindingFlags.Instance Or Reflection.BindingFlags.Public)  End Function   But still, requesting any Static members return nothing.  .NET reflector can see the static properties just fine, so clearly I am missing something here.
2361
Given a string of JSON data, how can I safely turn that string into a JavaScript object?  Obviously I can do this unsafely with something like:  var obj = eval("(" + json + ')');   but that leaves me vulnerable to the JSON string containing other code, which it seems very dangerous to simply eval.
101900
The  documentation mentions these value providers:     Value providers include m (data from model), v (attribute data from   component), and c (controller action).   but I have only ever seen v. and c. in examples.  (In AngularJS 1.x, the model is simple JavaScript objects and the view updates based on the model. Something closer to that in Lightning Components would be welcome.)  Anyone have any insight or links to information about m.?
74032
Is there a way to load every label data and every SObject description data using only Javascript without any Apex Server-side code?  How do I import * from @salesforce/schema or @salesforce/label?  I am looking for a way to get all labels or all SObject describe information details to retrieve in LWC at once.  I can see that such syntax is provided by ES6 and is used widely by Salesforce itself, however, it is not possible to use the following syntax in LWC:   import * as schema from '@salesforce/schema'   import * as label from '@salesforce/label'   or this syntax  import {label, schema} from '@salesforce';   since both versions generate error     LWC1512: Missing resource value for @salesforce"   or      LWC1512: Missing resource value for @salesforce/label   Is there a way to load every label data and every SObject description data using only Javascript without any Apex Server-side code?  By the way, if we look as Salesforce Playground we could notice that   the same syntax is used to import everything from lwc  import * as Engine from 'lwc';   however, if we try to insert such line into any of Lightning Web Component, we would receive the following error     LWC1001: Invalid import. Namespace imports are not allowed on "lwc",   instead use named imports "import { LightningElement } from 'lwc'"   or   LWC1517: Invalid LWC import
123258
@RestResource(urlMapping='/Merchandise/*') global with sharing class MerchandiseManager {      @HttpGet     global static Merchandise__c getMerchandiseById() {         RestRequest req = RestContext.request;                 String merchId = req.requestURI.substring(                                   req.requestURI.lastIndexOf('/')+1);         Merchandise__c result =                         [SELECT Name,Description__c,Price__c,Total_Inventory__c                         FROM Merchandise__c                          WHERE Id = :merchId];         return result;     }      @HttpPost     global static String createMerchandise(String name,         String description, Decimal price, Double inventory) {         Merchandise__c m = new Merchandise__c(             Name=name,             Description__c=description,             Price__c=price,             Total_Inventory__c=inventory);         insert m;         return m.Id;     } }   i am trying to execute these from postman,    but throwing below error,how i can authenticate,please help urgent requirement.     {       "message": "Session expired or invalid",       "errorCode": "INVALID_SESSION_ID"   }
75696
Can I create a Controller that simply returns an image asset?  I would like to route this logic through a controller, whenever a URL such as the following is requested:  www.mywebsite.com/resource/image/topbanner   The controller will look up topbanner.png and send that image directly back to the client.  I've seen examples of this where you have to create a View - I don't want to use a View. I want to do it all with just the Controller.  Is this possible?
49912
I am trying to retrieve VersionData with a standard REST API call from a VisualForce Page a then upload it to a S3 bucket but end up with corrupted files. I believe this is an encoding problem on the client side as plain text or CSVs work like a charm. I can upload VersionData from Apex but there are heap and request size limitations so I need to send the data from the client.   This is the call and returned string, I tried changing mimeType and encoding on both sides (SF call and S3 upload) with no luck.   Any ideas how to properly process images or pdf files? Thanks a lot  THE PROBLEM IS NOW SOLVED  Files should not be treated as strings. I solved the problem by leaving jQuery's ajax as I did not succeed to request a response type. By switching to plain JS and making a GET call (XMLHttpRequest) with response type set to blob I received an Object, instead of a string. Base64 string can be then retreived using JS FileReader.
103743
I've been messing around with  for some time, just pushing it out as text and it hasn't hurt anybody (that I know of), but I'd like to start doing things properly.  I have seen so many purported "standards" for the JSON content type:  application/json application/x-javascript text/javascript text/x-javascript text/x-json   But which one is correct, or best? I gather that there are security and browser support issues varying between them.  I know there's a similar question, , but I'd like a slightly more targeted answer.
7837
Is DOM the only way to parse JSON?
33695
I have a Java bean like this:  class Person {   int age;   String name; }   I'd like to iterate over a collection of these beans in a JSP, showing each person in a HTML table row, and in the last row of the table I'd like to show the total of all the ages.  The code to generate the table rows will look something like this:  &lt;c:forEach var="person" items="${personList}"&gt;   &lt;tr&gt;&lt;td&gt;${person.name}&lt;td&gt;&lt;td&gt;${person.age}&lt;/td&gt;&lt;/tr&gt; &lt;/c:forEach&gt;   However, I'm struggling to find a way to calculate the age total that will be shown in the final row without resorting to scriptlet code, any suggestions?
34618
I create a small API for one project using Bathic Authentication. The API consists of some custom paths defined in routes in a custom module. Using JsonResponse() in the controller we send back a JSON object with data.  But in case the user does not have permissions to access the path the route gives back the 404 HTML page. How can I tell Drupal to return a JSON object for my API paths under every circumstances?  Another example: we defined just to accept GET in the route. Using POST will return a HTML error page - we want Drupal to send back JSON with error information.
31228
How can I fetch images from a server?  I've got this bit of code which allows me to draw some images on a canvas.  &lt;html&gt;   &lt;head&gt;     &lt;script type="text/javascript"&gt;       function draw(){         var canvas = document.getElementById('canv');         var ctx = canvas.getContext('2d');          for (i=0;i&lt;document.images.length;i++){           ctx.drawImage(document.images[i],i*150,i*130);         }     }     &lt;/script&gt;   &lt;/head&gt;   &lt;body onload="draw();"&gt;     &lt;canvas id="canv" width="1024" height="1024"&gt;&lt;/canvas&gt;     &lt;img src="http://www.google.com/intl/en_ALL/images/logo.gif"&gt;     &lt;img src="http://l.yimg.com/a/i/ww/beta/y3.gif"&gt;     &lt;img src="http://static.ak.fbcdn.net/images/welcome/welcome_page_map.png"&gt;   &lt;/body&gt; &lt;/html&gt;   Instead of looping over document.images, i would like to continually fetch images from a server.  for (;;) {     /* how to fetch myimage??? */     myimage = fetch???('http://myserver/nextimage.cgi');     ctx.drawImage(myimage, x, y); }
43479
JPEG, GIF and PNG can be displayed with the img tag and will work in all browsers, the object element can be use for displaying images specifying its MIME type, but what other graphic formats are supported by img or object tag in most browsers without installing plugins? (TIF, SVG, PCX, PICT, etc..)
41362
Pretty simple question. I have a VisualForce Page on which I have the following line:  &lt;apex:stylesheet value="{!URLFOR($Resource.MyStyleSheet)}" /&gt;   When I access this page via a SiteIt's not loading, and when I look in the console I see this error:     Failed to load resource: the server responded with a status of 404 (Not Found)   Do I just have to inline everything?