Inherits from: WOMessage NSObject
Implements: WOActionResults
Package: com.apple.yellow.webobjects
A WOResponse object represents an HTTP response that an application returns to a Web server to complete a cycle of the request-response loop. The composition of a response occurs during the third and final phase of this loop, a phase marked by the propagation of the appendToResponse message through the objects of the application. The WOApplication object first sends this message, passing in a newly-created WOResponse object as an argument. WOElement objects, which represent the dynamic and static HTML elements on a page, respond to the message by appending their HTML representation to the content of the WOResponse object. WOApplication, WOSession, and WOComponent objects can also respond to the message by adding information to the WOResponse object.
A WOResponse has two major parts: HTML content and HTTP information. The content is what is displayed in a Web browser; it can include escaped HTML, which is HTML code shown "as is," uninterpreted. The other information encapsulated by a WOResponse object is used when handling the response. This HTTP data includes headers, status codes, and version string. See the HTTP specification or HTTP documentation for descriptions of these items.
The WOMessage class-from which WOResponse inherits-declares most of the methods you use when constructing a response. These methods can be divided into two groups, those that add to a response's HTML content and those that read and set HTTP information. To the methods provided by WOMessage, the WOResponse class adds two methods that escape HTML ( appendContentHTMLAttributeValue and appendContentHTMLString). For images and other binary data, use appendContentData (declared in the WOMessage class). You can obtain and set the entire content of the response with WOMessage's content and setContent methods. The following example shows a sequence of appendContent... messages that compose an HTTP "POST" message:
aResponse.appendContentString("<form method=\"POST\" action=\""); aResponse.appendContentHTMLAttributeValue(aContext.url()); aResponse.appendContentCharacter('"'); aResponse.appendContentString(">");
The remaining WOResponse instance methods set and read the the HTTP status code. WOResponse also provides two class methods that allow you to escape string objects.
WOActionResultsgenerateResponse
- Creation
- WOResponse
- Working with HTTP status
- setStatus
- status
- Working with HTML content
- appendContentHTMLAttributeValue
- appendContentHTMLString
- generateResponse
- stringByEscapingHTMLString
- stringByEscapingHTMLAttributeValue
- Controlling Client Caching
- disableClientCaching
public WOResponse()
public static String stringByEscapingHTMLAttributeValue(String aString)
Character | Escaped character |
& | & |
" | " |
\t | |
\n | |
\r | |
< | < |
> | > |
public static String stringByEscapingHTMLString(String aString)
Character | Escaped character |
& | & |
" | " |
< | < |
> | > |
public void appendContentHTMLAttributeValue(String aValue)
aResponse.appendContentHTMLAttributeValue("<B>");
would transform the argument to "<B>".
See Also: setContentEncoding ( WOMessage class)
public void appendContentHTMLString(String aString)
See Also: setContentEncoding ( WOMessage class)
public void disableClientCaching()
Attempts to disable caching in the client browser by appending a "no-cache" Cache-Control response directive to the HTTP response and by appending Expires and Date values that equal (they are both set to the current date and time).
This method shouldn't be invoked more than once for a given response.
public WOResponse generateResponse()
See Also: generateResponse (WOComponent)
public void setStatus(int anInt)
See Also: status
public int status()
By default, the status is 200 ("OK" status).
See Also: setStatus