Table of Contents Previous Section
Recording Extra Information
There may be occasions when you want to have the WOStatisticsStore object record more information than it usually does. For example, it may be useful to know the value of a certain component variable each time the page is accessed. This is most easily accomplished by overriding descriptionForResponse:inContext: in your component and having it return the desired information.For example, the HelloWorld example's Hello component could return the value of its visitorName instance variable along with the component name:
// WebScript Hello.mThe response component receives the descriptionForResponse:inContext: message after it receives the message appendToResponse:inContext:. The default implementation of descriptionForResponse:inContext: prints the page name. Unlike other methods invoked during the component action request-response loop, descriptionForResponse:inContext: is not sent to all components and dynamic elements on the page; it is sent only to the top-level response component.
- (NSString *)descriptionForResponse:(WOResponse *)response inContext:(WOContext *)context {
return [NSString stringWithFormat:@"%@/%@",
[self name], visitorName];
} //Java Hello.java
public String descriptionForResponse(WOResponse response, WOContext context) {
return new String(this.name() + visitorName);
}
Note that this method receives the response and context objects as arguments, just as appendToResponse:inContext: does. This means you can add such information as the HTTP header keys, or any other information recorded in these objects, to your description string. This description string is then appended to the log file in the CLFF format as discussed in "Maintaining a Log File".
- All its descriptions are written in the CLFF log file (if any).
- All its descriptions appear in the WOStats page under "Last User's Statistics."
- All its descriptions are added to all previous descriptions, and these totals appear in the WOStats page under "Detailed Statistics."
Table of Contents Next Section