[ Pobierz całość w formacie PDF ]
.But what did we just do with the AdapterErrorList? Nothing, really, it seems.Weonly assigned the Adapter property back to the LoginFormAdapter.Which means thatif anything goes wrong, it will be displayed inside the HTML that is produced by theLoginFormAdapter.And that means the same Login form where the user tried tologin, as we will see later, when we re finally ready to try to Login to our WebSnapapplication. 27 0672324806 CH22 12/12/02 2:39 PM Page 858858 CHAPTER 22 Web Server Programming with WebSnapFIGURE 22.17 Final preview of Login form in the Web Page Editor.EndUserSessionAdapterAnd that s not all, because we now have to tell the WebSnap application that theLogin page is ready to be used.In other words, should anyone (who is not yet loggedin) want to enter a page with the Login Required option set, this person must be sentto the Login page we just made.To specify the Login page, we must go back to thefirst Page Module (the pmHome unit), select the EndUserSessionAdapter component, andset its LoginPage property to Login (the name of your Login Page Module).You can now save everything and run the WAD application.Remember that youhave to start the Web App Debugger to view and login to the WebSnap application.For a more interesting demo (with more than just the login and home page), we willadd session support to our WebSnap application.WebSnap SessionsApart from the ability to login to a Web site, which is very useful of course, weshould also be able to maintain state in WebSnap applications; in other words,session management.Using WebBroker, this can be done in three ways: using fatURLs, using hidden fields, or using cookies.Using WebSnap, however, this can bedone somewhat easier.In the previous section, we used the TLoginFormAdapter andthe TWebUserList components to enable the login functionality in our WebSnapapplication.You might not have realized it, but this also requires the maintenance ofstate logged in or not in your current session.The thing is that it was doneimplicitly and behind our back (like many of the WebSnap features).But you can usethe same techniques to store any information in the user s session, using theTSessionsService component.The TSessionsService component is able to storename=value pairs for us with little effort. 27 0672324806 CH22 12/12/02 2:39 PM Page 859WebSnap Sessions 859TSessionsServiceTo spoil the surprise right from the start, TSessionsService is in fact using cookies tostore session IDs, but not the session values themselves.(Those are stored in memoryin the TSessionsService object, which is the reason why they don t work for CGIexecutables that are shutdown between requests, and why we must keep our WADWeb App Debugger executable up and running to remain logged in).Login andSession support works best in ISAPI applications.Let s continue with the WebSnap application to show how we can use theTSessionsService component to maintain some session information.First, add a newPage Module to obtain some session-related state information such as the date-of-birth of the particular visitor (it might be a nice idea to be able to greet a visitor onhis or her birthday).Click File, New Other; go to the WebSnap tab and select the WebSnap Page ModuleWizard to add a new page.Set its Name/Title to Birthday, and make sure it uses anTAdapterPageProducer component because we will be using an Adapter componentitself in a moment (see Figure 22.18).FIGURE 22.18 New WebSnap Page Module Birthday.Click OK and save the Page Module in pmBirthday.cpp.On the TWebPageModule, we now need to drop a regular TAdapter component, whichwill be used to request the date of birth for this particular visitor.While we re at it,we might as well ask for his or her name (it wouldn t be nice to congratulatesomeone with the message  congratulations visitor on your birthday! ).It would, ofcourse, be so much more personal to use a person s own name. 27 0672324806 CH22 12/12/02 2:39 PM Page 860860 CHAPTER 22 Web Server Programming with WebSnapTAdapter FieldsWhat we need to do first, is to right-click the Adapter component to start the AdapterFields Editor to define two new adapter fields named Name and Birthday.When youclick Insert inside the Adapter Fields Editor, the Add Web Component dialog pops up(see Figure 22.19).Here, you can define what kind of AdapterField you want.FIGURE 22.19 Add new AdapterField.Both the Name and Birthday should be a regular (string) AdapterField, so just add twoAdapterField components and name them Name and Birthday, see Figure 22.20.FIGURE 22.20 Birthday.Adapter1.Fields overview [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • szamanka888.keep.pl