![]() Xojo Web projects offer two ways to handle the request received. This is the one that fires every time a client app (it may be a Web Browser, desktop or mobile app) connects to the URL associated with the IP address and port combination that is listening for incoming requests. If we were writing a Web App, then this would be the event we would use to attend, process and send the requested web pages, for example. However, for web services we need to add the HandleSpecialURLevent to our project. The main difference is that, in this case, we can use typical URL signatures when its about talk with web APIs, where the methods (i.e, the requested action by the clients or API consumers) is part of the URL itself. In addition, this is the event that will allow our Web apps to attend and process the callbacks from other external web services, as could be PayPal, for example.įor example, a valid URL that can be trapped and processed by HandleSpecialURL is: The unique consideration is that these URL need to include the word Special or API as part of their URL path. Let’s assume we have a file called “pvmag_logo.svg”, stored in the subfolder “img” in the resources-folder of our final app, the following code will read the content of this SVG-file into the web picture: // Only read it once per running App If mPVMAGLogo Is Nil Then Var logoSVGFile As FolderItem = ("img").Child("pvmag_logo.svg") Var svgData as string // Ensure to copy your svg-file into the right path, let's check if this worked If logoSVGFile Nil And logoSVGFile.Exists Then Var t As TextInputStream Try // As SVG consists of XML-based instructions, we can read it like text t = TextInputStream.Open( logoSVGFile ) t.Encoding = Encodings.UTF8 svgData = t.ReadAll Catch e As IOException MessageBox("Error accessing the SVG") End Try t.Close end if mPVMAGLogo = new WebPicture mPVMAGLogo.MIMEType = "image/svg+xml" // important to make the picture available to all sessions of the running app mPVMAGLogo.Session = Nil mPVMAGLogo.Where getCustimers is in this case one of our API methods. If you have many of SVG pictures this will bloat your code and slow down your searches (unless you exclude the location where you are storing these SVG data).Īs we learned above that it makes anyway sense to keep at least one physical copy of your picture file, let’s read our SVG-file with Xojo.You either will get too many results or (more dangerous!) you might replace bits in this string by mistake (believe me, it is just too easy to make this happen). Having fun with “Search & Replace” in the Xojo IDE.Or you need to hold a copy of the original file.You will need to put this string back to a file, in case you ever want to change your picture again.Open your SVG file (which is an XML-file) and copy & paste the content into your the default value of your string variable. ![]() The “easiest” way would be to use a property defined as string. SVG is often the best and easiest way to get some really cool and crisp outcomes. Look at the following articles to get a better understanding of what I mean: Why to use SVG-Files at all? They scale better and easier and you will get a crispier result. Caching means in this case that you are basically loading the pictures only once per running app, and then they stay in a property (so in your server’s memory). Why? Well, usually you will show the webtoolbar on all (at least many) web pages, and it will (almost) always be the same for all users (means for all sessions of a runnin Xojo Web 2 Application).Ĭonsequently “caching” these files is the way to go. ![]() Loading pictures separately and storing them in properties is essential for the webtoolbar. First you should read Xojo’s article how to optimize Web Applications:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |