XForms: how to deal with instance data that changes? - javascript

At the moment I am working on an XForms application to mutate XML data. This data comes from a local XML file. The file is exported from another application in a static way and read into the application. The problem is that every time the data changes (the XML structure remains the same). How can I fix this in XForms? I use XSLTForms in my application.

XSLTForms cannot directly access local data files because Javascript is never allowed to do that for security reasons.
For a local only treatment, it's always possible to run a local HTTP server which can be minimal.
If the data file is changing independantly, there is another problem: according to the client-server architecture, XForms can only periodically try to check the file contents.
-Alain

Related

How does two client javascript files interact with each other, when the server is running separately?

I have created a django application. There are two different html pages, which run different scripts in each other. I want to share data between the two script files, so while I update the variables in one script, I can send the updated data to the other script file, and make the corresponding changes to the variable present in the other script file.
As I researched, one way I found to do that is to use websockets, where a regular connection is built with the django server and the client. But, it is limited to single client. So, through websockets, I can not share data between two different client pages. What other methods, can I use to share data between the two script files in the client?
Edit 1: The changes in one script file has to be reciprocated instantly or after really less time delay in the second script file.
Edit 2: The clients for the server can be running on different devices(one on phone and other on computer). Thus, having a solution to save data in localstorage doesnt work
Edit 3: I tried making api calls. The instant change in variable happens in one script file, an api call is made that makes change in the database. While, the other script is constantly making api calls at regular intervals to get the value of the variable that is saved. But, this creates a time delay, and therefore, was looking for a websocket like solution, where instead of communication between server and client, we have communication between two different clients operating in the same server
Use built in window.localStorage to store things on the clients browser for the life of the session. See https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage for reference.

Is there a way to get a variable from a global.asax .NET file into an Angular typescript file?

I have an asp.net web api and an Angular app that all lives in the same project file. My Angular app just uses .ts and .html files, and was wondering if there is a way to get a variable from my .NET global.asax into the Angular app somehow?
You could use an ASP.NET HiddenField control. With it, you can pass a variable value from the server to the client or the other way too.
This SO post on the HiddenField control usage may be helpful.
There are a couple different ways you can pass data from your web application to your client code. How you would go about it will depend on the type of web application you have (WebForms, MVC, API), and the amount of security you need. There are other ways then the following as well, if you provided more detail about what you are trying to do, then better suggestions can maybe be made.
You could set up an AJAX call in the client code to request the info from the server at runtime.
You could set the info in a cookie, and use the client code to read the contents of the cookie.
If you are using a web application that renders web pages, you can have the value rendered as a variable declaration in some client code.
If you are using a web application that renders web pages, you could also have the value rendered as a hidden field.
Please keep in mind that any data handled by the client side code exists on the client, and therefore can be accessed and even manipulated by the client. (Malisciously or accidentally)

How to structure this application using node/express.js?

I'm implementing an application that takes a file from a developer describing a UI with data bindings using a custom language I implement. My server takes the file (from a repo or directly) and creates a webpage (which implements the specified UI) that requests a .json (which specifies the data), which are served to the client. The server is responsible for, other than serving, keeping the data updated periodically from an exeternal SQL server. The application then allows the user to manipulate the data locally (think spreadsheet, with initial data from that SQL server).
I have the node part down (creation and maintenance of data structure), but I'm not sure how to serve the application itself. It will possibly have many scripts which will need to be served together. Do I place them directly in a HTML or .jade file to be served? Another option is to keep everything server-side and just have a UI which queries the data, but updates (via said user manipulation of data) are done in the server. This may make it lighter on the client, but I don't want to clog the server.
Would appreciate any help, let me know if anything needs clarification!

Best way to cache 1.5MB of data at the client side

I have a flash application that uses a large set (~1.5MB) of data. This data is likely to stay the same for a long time so I would like to use a caching method. The data should stay cached even if the user closes his browser (and restarts his computer).
At the moment, I'm using javascript files that are dynamically created and contain the data that will be transfered to flash later on. The server checks the If Modified since argument and returns a Not Modified if possible.
This method has the drawback that I still have to wait for the request to finish - I would like to rely on the old data while everything is set up and check for a new version later on.
tldr:
Is there a possibility to store data in a local cache (in the browser or my flash application) so that it isn't deleted when the browser is closed and is available without another request to the server?
You can use web storage.
I have stored more than 300 records for the same domain without problems in localStorage.
Here is a good document about web storage http://diveintohtml5.info/storage.html
I have never used it from flash but I found this at github https://github.com/shoito/as3webstorage

Caching meta data in JavaScript client

I am working with force.com architecture that uses a lot of JavaScript client side. I need to cache some meta data across page requests.
As far as I'm aware it is impossible to cache JavaScript across page requests as the global name space will be reloaded. One thing I was thinking that could be done if I was in a Java EE architecture which is ugly but would word be to generate a MetaData.js file with all the meta data at runtime.
This file could be cached across requests and the only cost would be instantiated an object from a self invoking function which is cheap.
However, I can create a MetaData.js file at runtime in force.com so I was wondering is there anything else I could do?
IS there a reason why you can't store that data on the server? With PHP in a $_SESSION for example.

Categories

Resources