|
|
|
|
|
|
|
|
|
|
|
|
|
|
Using cookies in Lotus Domino applications is in your future (continued)
You should now be able to create a cookie and change its value by changing the value of the dropdown.
If you're getting errors, remember that Javascript is case sensitive. You can also download the demonstration database for this article from http://www.touchdown.com.au/dpcookies.zip.
We don't yet know if our example is working properly because we can't see what is inside the cookie.
We will now add the functionality required to view the value of the cookie.
Reading and viewing the cookie value
The first step is to create the HTTP_COOKIE field.
To read cookie values on a Lotus Domino form, you need a field named HTTP_COOKIE. The presence of this field on the Domino form makes the cookies available to formulas in other fields on the form.
Create the HTTP_COOKIE field and put it at the top of the form. Set the field type to "Editable". Add the following formula to the field:
Domino will automatically fill it with the current cookie data.
The end user doesn't need to see this field, so we'll hide it. Select the field and right click on it. Then select "Text Properties" from the menu. On the blinds tab, select "Hide Paragraph from Web Browsers".
If you don't hide the HTTP_COOKIE field, then you get to see the raw contents of the cookies, which can be quite interesting and useful for troubleshooting.
Step two is to display the value of our cookie.
Create a new field named DisplayCookieValue. Type <BR> <BR> <BR> after the DisplayCookieValue field. Set the type of the field to "Text" and "Computed for display".
In this field, place the following formula:
@ReplaceSubstring( @Word(@RightBack(HTTP_COOKIE;"mycookie=");";";1) ; "%20" ; " " )
|
It's important to understand that the HTTP_COOKIE field contains one big chunk of text, containing all the cookies and all their values. The above formula parses out the specific cookie required and then parses out the value of that cookie.
Cookies also contain the escape character %20 as a replacement for spaces, so we need to substitute these values as we extract the values from the cookie.
For readability and usability, we'll put some explanatory text onto the form immediately before the DisplayCookieValue field:
The current value of mycookie is: <BR>
|
Select the entire contents of the page and turn on "Pass-thru HTML". Save the form.
All done: testing the solution Fortune cookie says: "You are nearly there."
Okay, our demonstration application is finished, and it should all work now. Refresh the page in your Web browser.
You should now be able to change the value of the dropdown and see the value of the cookie change after the page has refreshed.
Uses for cookies Fortune cookie says: "Life for you is a dashing and bold adventure."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Advertisement --
Learn Notes and Domino 8 at your place and pace!
Learn Notes and Domino in your office and/or home! TLCC's highly acclaimed distance learning courses for users, developers, and admins will enhance your career and your resume.
The many included activities and demos will make you a pro! Expert instructor help is a click away.
Click here to try a FREE demo course!! |
-- Advertisement --
Struggling with exporting Notes data to spreadsheets? No More!
Try IntelliPRINT, The world's leading Reporting, Dashboards, and Analysis solution for Notes & Domino
- Don't spend unproductive time maintaining different versions of the same spreadsheet
- Preserve data integrity and security in multi-user environments
- Create reports in minutes INSIDE Notes
- Get freedom from iterative report requests, deliver self-serve capabilities
Experience Reporting, Dashboards, and Analysis INSIDE Notes.
Try IntelliPRINT NOW! |
|
|
|
|
|
|
|
|
|
|