Adding meaningful bookmarks
Moderators: Jon, Steve, Ian, Dave
-
- Ebase Staff
- Posts: 89
- Joined: Mon Sep 10, 2007 11:48 am
Adding meaningful bookmarks
How can I add browser bookmarking to my Xi apps? At the moment the URL I see looks something like ..ufsmain?ebz=22_1358159990193&ebd=0 and returns an error if you try to use it as a bookmark. I understand that bookmarking is an issue for session-based systems such as Xi, but this really doesn’t help me much. Ideally what I want is to be able to provide bookmarks that will return the exact state of the Xi app at the moment the bookmark was taken. Any suggestions?
0 x
-
- Ebase Staff
- Posts: 89
- Joined: Mon Sep 10, 2007 11:48 am
Adding meaningful bookmarks
The HTM5 JavaScript History API allows you to replace the page's URL with one of your own design, and this URL can contain parameters that can be used to restore a form's state when called from a bookmark. Please refer to http://html5doctor.com/history-api/ for a full discussion on the subject.
The JavaScript of interest is
For example,
would replace the page URL with
Consider a simple application example: a form allows a user to choose from a list of products, and (via immediate validation) displays information about what’s been selected. The form can also receive a PRODUCT_ID as a parameter and will automatically present details for that particular product. At any point of execution we’d like the user to be able to bookmark the page in front of them.
One way to do this is define a JavaScript function in a client script called, say, changeURL and bind it to the jQuery ready event on the list of products. The changeURL function simply reads the current value of the PRODUCT_ID field and uses it to write a new page URL containing PRODUCT_ID as a parameter, e.g.…ufsmain?formid=FORM_NAME&PRODUCT_ID=1.
A second, more powerful (and general) way of solving the problem is to use the Xi V4.4 Snapshot functionality. The idea here is to take a Snapshot whenever you want to save the current state of the form for bookmarking and to use the snapshot ID as a parameter on the bookmark URL. If a snapshot ID is received when the form runs then (on the Before Form event, for example) the Snapshot state is restored. The changeURL function is used as before, i.e. is bound to the ready event of any control that will a cause of state in our app (and that we want to able to restore from a bookmark link). In this solution the changeURL simply writes a new URL containing the current Snapshot ID.
The first solution is lightweight but requires you to add Before From processing of the bookmark URL parameters if you want present your form in a particular state, e.g. receive a PRODUCT_ID with value of 1 and then go and get the corresponding product details from a database, etc.
The second solution bypasses the need for any additional processing apart from the Snapshot restore from a Snapshot ID parameter value. In this sense it is generic and solves the requirement for a bookmark URL to be able to restore an app to a particular state without having to process any passed in application values. The cost though is the potentially frequent taking of Snapshots as the application runs. Each Snapshot will generate an amount of data in the Xi database repository that will need to be removed/archived at some point.
You can download examples of both approaches from
http://www.ebaseftp.com/download/forum/ ... ksDemo.zip
The first solution is demonstrated in form BOOKMARK_DEMO1 and the second, using the Snapshot, is shown in BOOKMARK_DEMO2.
The JavaScript of interest is
Code: Select all
window.history.pushState('string', 'Title', 'new URL');
Code: Select all
window.history.pushState('string', 'Title', 'ufsmain?formid=BOOKMARK_DEMO1&PRODUCT_ID=1');
Code: Select all
http://domain:port/webapp/ufsmain?formid=BOOKMARK_DEMO1&PRODUCT_ID=1
One way to do this is define a JavaScript function in a client script called, say, changeURL and bind it to the jQuery ready event on the list of products. The changeURL function simply reads the current value of the PRODUCT_ID field and uses it to write a new page URL containing PRODUCT_ID as a parameter, e.g.…ufsmain?formid=FORM_NAME&PRODUCT_ID=1.
A second, more powerful (and general) way of solving the problem is to use the Xi V4.4 Snapshot functionality. The idea here is to take a Snapshot whenever you want to save the current state of the form for bookmarking and to use the snapshot ID as a parameter on the bookmark URL. If a snapshot ID is received when the form runs then (on the Before Form event, for example) the Snapshot state is restored. The changeURL function is used as before, i.e. is bound to the ready event of any control that will a cause of state in our app (and that we want to able to restore from a bookmark link). In this solution the changeURL simply writes a new URL containing the current Snapshot ID.
The first solution is lightweight but requires you to add Before From processing of the bookmark URL parameters if you want present your form in a particular state, e.g. receive a PRODUCT_ID with value of 1 and then go and get the corresponding product details from a database, etc.
The second solution bypasses the need for any additional processing apart from the Snapshot restore from a Snapshot ID parameter value. In this sense it is generic and solves the requirement for a bookmark URL to be able to restore an app to a particular state without having to process any passed in application values. The cost though is the potentially frequent taking of Snapshots as the application runs. Each Snapshot will generate an amount of data in the Xi database repository that will need to be removed/archived at some point.
You can download examples of both approaches from
http://www.ebaseftp.com/download/forum/ ... ksDemo.zip
The first solution is demonstrated in form BOOKMARK_DEMO1 and the second, using the Snapshot, is shown in BOOKMARK_DEMO2.
0 x
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
Who is online
Users browsing this forum: No registered users and 16 guests