use of org.apache.tapestry5.http.services.Response in project tapestry-5 by apache.
the class LinkImplTest method null_parameter_value.
/**
* TAP5-922
*
* @since 5.3
*/
@Test
public void null_parameter_value() {
Response response = mockResponse();
String expectedURI = "/ctx/foo?barney=&fred=flintstone";
train_encodeURL(response, expectedURI, expectedURI);
replay();
Link link = new LinkImpl("/ctx/foo", false, LinkSecurity.INSECURE, response, null, null);
link.addParameter("fred", "flintstone");
link.addParameter("barney", null);
assertEquals(link.toURI(), expectedURI);
verify();
}
use of org.apache.tapestry5.http.services.Response in project tapestry-5 by apache.
the class TapestryModule method contributeRequestHandler.
/**
* Continues a number of filters into the RequestHandler service:
* <dl>
* <dt>StaticFiles</dt>
* <dd>Checks to see if the request is for an actual file, if so, returns true to let the servlet container process
* the request</dd>
* <dt>CheckForUpdates</dt>
* <dd>Periodically fires events that checks to see if the file system sources for any cached data has changed (see
* {@link org.apache.tapestry5.internal.services.CheckForUpdatesFilter}). Starting in 5.3, this filter will be null
* in production mode (it will only be active in development mode).
* <dt>ErrorFilter</dt>
* <dd>Catches request errors and lets the {@link org.apache.tapestry5.services.RequestExceptionHandler} handle them
* </dd>
* <dt>StoreIntoGlobals</dt>
* <dd>Stores the request and response into the {@link org.apache.tapestry5.http.services.RequestGlobals} service (this
* is repeated at the end of the pipeline, in case any filter substitutes the request or response).
* <dt>EndOfRequest</dt>
* <dd>Notifies internal services that the request has ended</dd>
* </dl>
*/
public void contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration, Context context, @Symbol(TapestryHttpSymbolConstants.PRODUCTION_MODE) boolean productionMode) {
RequestFilter staticFilesFilter = new StaticFilesFilter(context);
RequestFilter storeIntoGlobals = new RequestFilter() {
public boolean service(Request request, Response response, RequestHandler handler) throws IOException {
requestGlobals.storeRequestResponse(request, response);
return handler.service(request, response);
}
};
RequestFilter fireEndOfRequestEvent = new RequestFilter() {
public boolean service(Request request, Response response, RequestHandler handler) throws IOException {
try {
return handler.service(request, response);
} finally {
endOfRequestEventHub.fire();
}
}
};
if (productionMode) {
configuration.add("CheckForUpdates", null, "before:*");
} else {
configuration.addInstance("CheckForUpdates", CheckForUpdatesFilter.class, "before:*");
}
configuration.add("StaticFiles", staticFilesFilter);
configuration.add("StoreIntoGlobals", storeIntoGlobals);
configuration.add("EndOfRequest", fireEndOfRequestEvent);
configuration.addInstance("ErrorFilter", RequestErrorFilter.class);
}
use of org.apache.tapestry5.http.services.Response in project tapestry-5 by apache.
the class PageTester method runComponentEventRequest.
private TestableResponse runComponentEventRequest() {
while (true) {
response.clear();
try {
boolean handled = requestHandler.service(request, response);
if (!handled)
throw new RuntimeException(String.format("Request for path '%s' was not handled by Tapestry.", request.getPath()));
Link link = response.getRedirectLink();
if (link != null) {
setupRequestFromLink(link);
continue;
}
return response;
} catch (IOException ex) {
throw new RuntimeException(ex);
} finally {
registry.cleanupThread();
}
}
}
use of org.apache.tapestry5.http.services.Response in project tapestry-5 by apache.
the class AjaxLinkComponentEventResultProcessor method processResultValue.
public void processResultValue(Link value) throws IOException {
JSONObject response = new JSONObject();
response.in(InternalConstants.PARTIAL_KEY).put("redirectURL", value.toRedirectURI());
masterProcessor.processResultValue(response);
}
use of org.apache.tapestry5.http.services.Response in project tapestry-5 by apache.
the class AjaxPageNameComponentEventResultProcessor method processResultValue.
/**
* Obtains a page render {@link org.apache.tapestry5.http.Link} for the named, then builds a JSON response for the
* client.
*
* @param value
* page name
* @throws IOException
*/
public void processResultValue(String value) throws IOException {
Link link = linkSource.createPageRenderLink(value, false);
masterProcessor.processResultValue(link);
}
Aggregations