Read property file on both java and angularjs - angularjs

I'm using a properties file in project. I want to read the properties file both java and angularjs. suggest me a best location to place the properties file which can accessible by java and also by angularjs.

By design it should be src/resources folder.
Well by opportunity, it can be placed in webapp too.

From what I know angularjs is meant to execute on browser. I do not recommend downloading properties into browser as web assets similar to css/js. So I would recommend keeping properties in src/main/resources/. If you need, host a small rest end point giving these properties as a json map in response. This can be used by angularjs on client side(browser)

Ideally properties which have confidential information shoild never be sent to browser.
Any one can get access to those information by debugging in tools like chrome,etc.
Sending such information should not create problems for your system. In those cases you shld hv 2 properties in src/ resources folder. One contains db passwords etc. Other with open information.

Related

problem when read files from local computer in pyscript

When I run the Python file, the file works correctly, but when I run the Python file with the script, it gives an error in read txt file(file not found).
how can i solve this problem؟
Software written in any language (Python, JavaScript, WASM) cannot access local files directly. This is a browser security restriction. The browser can access files on behalf of your application using the <input type="file"> DOM element link.
In Python and JavaScript, you must provide the user with a file input selector. The user selects the file and your application can the retrieve the file data from the browser.
In JavaScript this functionality is implemented with the FileReader class. This class can be used in Python via the create_proxy() function to proxy event callbacks.
If you are just getting started with Pyscript, I have written a number of articles link.
See this issue report.
Code running in a webpage is sandboxed and can't freely access files on the computer hosting the browser.
(It would be a terrible security problem if just visiting a webpage would give the author of the page access to your files).
If you want to access a file on the user's computer, use <input type="file"> and have the user select it. I don't know if you can access it directly or if you would need to use a JavaScript FileReader and then pass the results from JS to PyScript … but one of those two approaches should be possible.

Can I have a config.json file to hand to my clients so they can change values on their website?

Using react-app and webpack, I was wondering if it's possible to bundle a config.json file such that you can access it after the site builds and be able to change values within it and have that be reflected on the website. This is mainly so that I can have values in my config.json file like "header__1" or "about__description" in my config.json file and hand them over to my clients so that they may change values themselves w/o having to consult me.
Welcome to stackoverflow Shaun,
since you're writing a web application with react and it is all about Javascript, you can't work with files like you can with desktop clients. Neither should you (read more here).
If you want your web clients to be modifiable by the customer you should add something like a config page to your app. The values that change should then be stored in the localStorage of the browser or something similar.
EDIT: Of cause a config file could be loaded from an external source. But then you have to differ between users and their individual configurations (which might be not what you want). Files bundled with webpack can't be edited (permanently) on the users side.

Issue with accessing css from build file

I am having an issue where my grunt build file is building correctly, but the website I'm working on is not getting all of the css files. It is only getting the master.css file. I'm using nodejs, with kraken, on top of express. I can't tell if there is some configuration option I need to change, I don't really know where I would do that.
For anyone interested, the issue was with the changing structure of the project. Going from angular to a dustjs w/ backbone combo changes the project form a SPA structure to a multi-page structure. This makes a huge difference because now instead of sending everything at once we are sending pages as they are needed, this also means that when a user switches to a different view, the server will be building an html version of that view and sending it back as fully fleshed out html. When the server builds the page it has access to the file structure, which means that the build folder that was necessary for the angular project, is no longer necessary.

Using AngularJS in local HTML

What are the best practices for using AngularJS in local HTML? By that, I mean HTML files opened directly from the local file system, not from a web server.
I have had some luck in replacing partials that are in separate files with partials within script tags. And replacing Ajax calls with including JS files that contain the JSON data. However, I wondered if there are any guidelines for doing this, or even helper libraries?
BTW, my use case is a desktop application that generates HTML reports that are server using a local web server. In some cases users want to create a ZIP file that contains an HTML report, which they can email to someone else. Given the sensitivity of these reports, people may have objections to using a cloud service. Having HTML in a zip file gives them control of their data.

Loading Facelets templates from database

In my application (CMS for internal purposes) I'm facing the problem how to serve pages stored in the database with dynamic URL (e.g. http://example.com/page3) using the JSF. Generally, let's say I want to grab the page content from the database, put it inside jsf file and serve it as /page3. Is there any way how to obtain the request URL from JSF, search the database for the article (instead of searching *xhtml in the WAR), build dynamically the JSF XHML file and return it to JSF as InputStream for example? I've found this answed by Thomas Maerz, but it failed with
Unable to create a new instance of 'com.test.CustomResourceResolver': java.lang.InstantiationException: com.test.CustomResourceResolver
on my glassfish v4 (Mojarra 2.2), and I also found that ResourceResolver is deprecated in JSF2.2.
I've googled a lot, but this seems to be not very common/documented part of JSF.
Thank you for any help.
I did not understand fully the problem, but for url change you can use prettyfaces, for dynamic forms you can use primefaces ext and I am not suggest keep form in the database, if I know your target I can suggest more useful answer.

Resources