I am new to openui5 and developing web application. The page should not active when i reload the page. I am searching to do that using openui5 but i not getting idea about that.
Please help me anyone.
Use some session storage to check whether the page is reloaded and if reloaded just kill it. for example assuming you want to kill the page:
oStorage = jQuery.sap.storage("session");
$(window).load(function() {
if(!oStorage.get("is_reloaded")){
oStorage.put("is_reloaded",false);
}
checkNoOfVisits();
});
function checkNoOfVisits(){
if(oStorage.get("is_reloaded")){
window.stop();
}
else{
oStorage.put("is_reloaded",true);
}
}
Related
I am working with ionic application, ionic CLi 4.5.0
I am using using ionic serve & open preview in browser & when edit any file live reload load to root page but I need to load last woreking/loaded page
suppose root page is home so liveload always load at http://localhost:8100/#/home
if my last working/open page is http://localhost:8100/#/login and I make change in any file liveload still load at http://localhost:8100/#/home but I need to load at http://localhost:8100/#/login
It will always load the rootpage which you configured in your app.compontent.ts. If it is text change, it will do a hot-reload feature. If you make any changes in your component, it will restart from the root page.
The simple way to do is to store the session in observable object or session storage after successful login.
ionViewDidEnter() {
this.storage.get(LOCALSTORAGE.TOKEN).then((val) => {
if (val)
this.navCtrl.setRoot(HomePage);
});
}
Using an observable object,
private tokenString: BehaviorSubject<string>;
setTokenObject(val) {
if (val)
this.tokenString.next(val);
else
console.log(val);
}
getTokenObject() {
return this.tokenString.asObservable();
}
Updating the token in login success for the first time
this.tokenString.next(token); // here token should read it from your login response
Hope this helps!
When developing with Ionic 2 how does one stay on the current page when making code changes? In Ionic 1 livereload would take you back to your current url - however in ionic 2 there are no urls.
Is there a setting that will make livereload keep me on the current page?
I'm open to enabling URLs as well if that's what it takes to not have to manually navigate back to my page on every code change. However I haven't been able to find how to do that in the v2 docs yet.
To stop live reloading in Ionic2 following changes I have done in the configurations file : ionic.config.js.
In ionic.config.js
watch: {
sass: ['app/**/*.scss'],
html: ['app/**/*.html'],
livereload: [
'www/build/**/*.html',
'www/build/**/*.js',
'www/build/**/*.css'
]
}
above section edited to :
watch: {
sass: ['app/**/*.scss'],
html: ['app/**/*.html'],
}
Then stopped ionic serve by q, and again started. Auto refreshing got stopped, we have to manually refresh to reflect the latest changes.
You could set the this.rootPage in your app.component.ts to the page you are working on. I often do this if i am working on say the foobar.ts page for a while ill change it to
this.rootPage = FooBar;
And then change it back to the default root page when i am done.
Actually ionic.config.js has been deprecated . So i found a way may , go to this node_modules\#ionic\app-scripts\config . Change in file called watch.js
srcFiles: {
paths: ['{{SRC}}/**/*.(ts|html|s(c|a)ss)'],
options: { ignored: ['{{SRC}}/**/*.spec.ts', '{{SRC}}/**/*.e2e.ts', '**/*.DS_Store'] },
callback: watch.buildUpdate
},
No, there is no way to do what you are asking for, because ionic 2 is not using urls. Actually they are handling the pages as a variable on window, so when you or the live reload refresh the page it will go to the initial state. By the way actually there are no plans for implement the angular router, let's wait until the RC, maybe they would like to implement it
i've a requirement as below after use logs-in:
- user will first see a nda agreement page, where he has to sign on it and submit
- then after sumit, it has to load shell and then he cont with other screens in shell
the key here is, if any time the user refreshes the screen.. it should always takes him to shell and not the the nda screen. as we've to remember the user's decision and load only shell.
-wt is the best way to handle this?
-i hope (prefer) to do this in the same ui5 project only.. rather than 2 different projs.
-how do we remember the user's decision? its a kind of session handling within ui5!
-do we've to use content.plastAt() from nda page to shell? how to achieve this..!
You can do the following in a few ways, lets tackle the NDA remember feature.
You can use javascript's session storage api for example, this will make sure that a refresh will keep the value but a completely new session will show the NDA again.
Now if you want Ui5 based solution for the NDA you can set the first screen as the NDA and in the submit button to navigate to the next page and detach the NDA page from the shell.
Another way to achieve this is by using a modal popup with the NDA and on click just remove the popup
and save the data in the session storage.
Hope this gave you a clear idea.
BR,
Saar
you need to use Session Storage to meet your requirement
In the NDA sign on page check sessionStorage data and in the controller of NDA write this code
onInit: function() {
var oView = this.getView();
oView.addEventDelegate({
onBeforeShow : jQuery.proxy(function(evt) {
this.onBeforeShow();
}, this)
});
},
onBeforeShow: function(){
if(SessionStorage['UserName'])
{
sap.ui.getCore().getEventBus().publish("nav", "to", {
id : "idShell",//id to navigate to shell Page
data : {}
});
}
else
{
// DO SOMTHING
}
}
I have created a story reading chrome app.
My problem is that whenever the app is relaunched it starts from the first page of the story.
How can i save the last state of the app so that it reloads from the point where it was left?
You can save state of the app using the chrome.storage API.
Suppose you want to store the index of the page, and you have some function to go to a page:
function goToIndex(index){
chrome.storage.local.set({lastIndex: index}, function() {
/* actual work */
});
}
And when your app initializes, read the value (note, it's all asynchronous):
// Safe default if the storage is empty; should be the first page
var defaultIndex = 0;
chrome.storage.local.get({lastIndex : defaultIndex}, function(result) {
goToIndex(result.lastIndex);
});
Optionally, this will also sync progress across browsers for logged in users, which is a nice feature. You can do it by using chrome.storage.sync instead of chrome.storage.local, but beware of rather harsh rate limits. It is best to implement your own rate limiting if you use this.
For some time now I try to figure out how these guys were able to add "Sign online here" button which is "install App" button on their fan-page tab:
http://www.facebook.com/GuinnessIreland?v=app_165491161181
I've read around the web and couldn't come up with any solid solution. The FBML and FBJS documentation left me with nothing.
So please, if anyone can help me with this.
NOTE: To make multiple tests on the Ajax request that are sent, do not accept the App install. It behaves differently after that.
I had some problems with finding out about it as well. There is no info about this kind of behavior in wiki or anywhere. I got it working after trying some possible solutions and the simplest one is to make user interact with content embedded in fan page tab such as click on something etc. Then you need to post an ajax request with requirelogin parameter to pop up to come out. The simple example would be:
user_ajax = function() {
var ajax = new Ajax();
ajax.responseType = Ajax.RAW;
ajax.requireLogin = true;
ajax.ondone = function(data) {
new Dialog(Dialog.DIALOG_POP).showMessage('Status', data, button_confirm = 'Okay');
}
var url = "http://yourappurl.com/request_handler"
ajax.post(url);
}
And the trigger for it:
Interaction
Then if user is known to be using your application (fan page tab) you can prompt him for additional permission like publish stream or email communication by calling:
Facebook.showPermissionDialog('publish_stream,email');
Hope this solves the problem.