how to store gwt user interface settings in persistent cookies, so that user can get them on next visit? I have user interface designed using gwt. Some user prefer to see few columns from the interface every time they visit application.so what needs to be done
You can use local storage for that.
http://www.gwtproject.org/doc/latest/DevGuideHtml5Storage.html
HTML5 Storage is technology for caching data on client-side. There are two types: LocalStorage (shared by all browser tabs, stored on disk, 5 MB per webapp) and SessionStorage (accessible only within one tab, stored in memory). In your case, you should use LocalStorage to allow user close his browser and then reload settings from disk.
GWT has built-in API for using LocalStorage. See details at http://www.gwtproject.org/javadoc/latest/com/google/gwt/storage/client/Storage.html
Also let me propose you some sample code (you'll need to provide some details to be more concrete):
import com.google.gwt.storage.client.Storage;
...
Storage storage = Storage.getLocalStorageIfSupported();
if (storage != null) {
//adding your settings to storage
storage.setItem("some setting key", "some setting");
//removing your settings from storage
storage.removeItem("some setting key to remove");
//clearing the whole storage contents
storage.clear();
}
Related
I am wanting to use Firestore to retrieve user info and other data linked to that user once they have logged in via firebase auth. On the home page of the app I use .onAppear{ pulluserData() }. I understand that Firestore functions are asynchronous so how can I wait for this data to be pulled before displaying it to the user on the home screen?
Here is my function to check the database:
func checkDatabase() async {
//Function that will check the database. Will be good to add a listener eventually
if self.pullUserData{
await dbm.readUser(userID: "VSWAq7QCw3dbGYwMdtClbbANGVe2")
}
}
and the actual database function:
func readUser(userID: String)async{
//Function that will be used to read user info from the database
let userRef = database.collection("users")
do{
let doc = try await userRef.document(userID).getDocument().data()
print("The doc is: ")
print(doc as Any)
}
catch {
}
}
There are a number of ways to do this but the two most common ways are to (1) use a launch screen to indicate a loading state that disappears to a view identical to the launch screen (to continue the appearance of loading) that is only removed when the database returns (i.e. Twitter); (2) load the user right into the app and allow them to move freely while either indicating that data is loading or displaying cached data.
Remember that Firestore maintains a local cache on the device which means that data will be available immediately when the app launches. This data may be out of sync with the server but it will update as soon as the app establishes a connection with Firestore, which is usually instant. What I would recommend is launching the user right into the app without the use of a loading screen and relying on the cached data to get the UI up as fast as possible.
And if we're only talking about user-specific data (data that is specific to the user that the user has full control over) then that data will only change when the user changes it, which would have been the last time they used the app, which means that the locally-cached data on their device (assuming they use only one device) will always reflect the state of the server (in theory, anyway). And if it doesn't then it doesn't; the fresh data will update instantly anyway.
You may then wonder what happens if the user launches the app without connection. In that case, the cached data is displayed and the user is almost none the wiser. And because Firestore is offline capable, the user can freely edit their data and it will write to the server when connection eventually establishes.
I am trying to use .getText and want to use that retrieved text, on another page(Search box).
Can I get any help?
I am using Java Selenium.
Thanks
In advance.
You can use the sessionStorage and store the text using getText() add data
to the session storage and it will be accessible to any page from the same site opened in that window.
Update
SessionStorage can store up to approx 5MB of data which will be store on the browser and will be available to the pages which will be open in that tab, It means once you close the tab it will be deleted and not accessible. It expires on the closure of the tab.
String text = driver.findElement(By.xpath("//*[text()='Google offered in: ']")).getText();
WebStorage s = (WebStorage) new Augmenter().augment(driver);
SessionStorage ss =s.getSessionStorage();
ss.setItem("Text", text);
driver.findElement(By.name("q")).sendKeys(ss.getItem("Text"),Keys.ENTER);
How to pass storage (User session) data to side menu ionic 5?
you could just use
window.localStorage.setItem("key","value")
to store values session like. With
window.localStorage.getItem("key")
you can get back your stored value.
I want to store my smarttv aplication's status. Example: I have a multipaged document and I want to store where the user left the program to open this page when the user reopens the program.
What is the efficient way to achieve this?
Given that you are talking about pages and cookies, I'll assume you are using the HTML / JavaScript API.
According to Samsung's list of JavaScript properties, the cookie property is supported. This is defined in the DOM Level 1 specification and Quirks Mode has a guide to using cookies from JavaScript.
You can use the official Samsung SDK to save a small quantity of data on the persistent memory of the device.
SDK: localData
This API allow you to save and read a value:
# saves current page state
sf.core.localData("currentPage", "home");
# reads current page state
var previousPage = sf.core.localData("currentPage");
Otherwise you can use the readFile API:
SDK: readFile
Can someone explain the difference between this two frontends
Zend_Cache_Frontend_Capture and Zend_Cache_Frontend_Page?
the Capture is the default one for page caching ... the weird thing is, it makes the id with get variables, but there is no options to set make_id_with_get_variables like its the case in
Page frontend....
can someone explain this ?
Here is my effort to explain the differences between the two.
To start out, let's look at Zend_Cache_Frontend_Capture. The reference states that this class is designed to work only with Zend_Cache_Backend_Static.
You would use Zend_Cache_Frontend_Capture to cache entire pages that have no relation to the user accessing the site. You use this frontend when you have static data (that could change from time to time) that has no relation to the current user, that is, it is the same for all users (like an RSS feed or dynamically created JavaScript file for example.
Looking further into the Zend_Cache_Backend_Static, you will see that this backend is a bit special. It requires rules in your .htaccess file to assist with serving the cache. Once you have cached something with Frontend_Capture/Backend_Static, PHP and Zend Framework are NOT used in order to serve the cached data. Apache sees that the cache file exists based on your .htaccess and serves the content directly to the user without invoking PHP.
Zend_Cache_Frontend_Page on the otherhand works differently. With it, you can cache content not only based on the request URI, but also based on information in a cookie, session, GET, or POST parameters. By default, caching based on cookie, session, get, and post is disabled, so for this to have any effect on a user logged into your site, you have to tell the cache if there are any pages you want to cache based on that information.
Once I create a cache and tell it I want to cache based on cookie and session, I can now cache a dynamically generated page that is specific to one user. So if person A accesses /accounts/, the page can be cached for that specific user containing the list of their accounts that was pulled from the database. Now when person B accesses /accounts/, they do not see the cache for person A, so the page is now cached separately for them with each respective user's information in their own cache.
In summation:
Use the Capture frontend when you have data you can cache that is the same for ALL users. This will be a higher performance cache since PHP and ZF is not needed once the page is cached. The downside is having to add caching rules to .htaccess
Use the Page frontend if you want to cache pages with dynamic output based not only on request URI, but the cookies, session data, or get/post parameters.
Hope that is clear and helps you understand the differences.
EDIT:
I believe I see what the problem is, not sure if this is classified as a bug or not though.
Zend_Controller_Action_Helper_Cache::preDispatch() generates the cache ID based on the request URI (which includes the query string). Since the jQuery ticker appends a query string to the URL, you are caching one copy of the feed for each request URI. (Look for $reqUri in the aforementioned class method).
I see a couple of options: 1) See if you can get the ticker to not append the query string (at least for that specific URL) or 2) Manually start the Capture cache and pass your own ID, rather than letting the cache helper generated it based on the request URI.