public class MockClient implements Client { @Override public Response execute(Request request) throws IOException { Uri uri = Uri.parse(request.getUrl()); Log.d("MOCK SERVER", "fetching uri: " + uri.toString()); String responseString = ""; if(uri.getPath().equals("/path/of/interest")) { responseString = "JSON STRING HERE"; } else { responseString = "OTHER JSON RESPONSE STRING"; } return new Response(request.getUrl(), 200, "nothing", Collections.EMPTY_LIST, new TypedByteArray("application/json", responseString.getBytes())); } }
public class HomePage extends WebPage { public HomePage() { add(new Label("label", "<ul><li>test</li><li>test</li><li>test</li><li>test</li><li>test</li></ul>") .setEscapeModelStrings(false)); add(new WebComponent("html") { @Override protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { Response response = getRequestCycle().getResponse(); response.write("<ul>"); for (int i = 0; i < 5; i++) response.write("<li>test</li>"); response.write("</ul>"); } }); } }
@Override public void respond(final IRequestCycle requestCycle) { requestCycle.getResponse().reset(); delegate.respond(requestCycle); }
@Override public String renderRelativeUrl(Url url, Url baseUrl) { return url.toString(); } }
final IRequestMapper o=getRootRequestMapper(); setRootRequestMapper(new IRequestMapper() { [...] @Override public Url mapHandler(IRequestHandler r) { Url u=o.mapHandler(r); if (condition) u.setProtocol("https"); return u; } });
/** * Gets port that should be used to render the url * * @param url * url being rendered * @return port or {@code null} if none is set */ protected Integer resolvePort(final Url url) { return choose(url.getPort(), baseUrl.getPort(), request.getClientUrl().getPort()); }
/** * Gets the host name that should be used to render the url * * @param url * url being rendered * @return the host name or {@code null} if none is set */ protected String resolveHost(final Url url) { return choose(url.getHost(), baseUrl.getHost(), request.getClientUrl().getHost()); }
/** * Gets the protocol that should be used to render the url * * @param url * url being rendered * @return the protocol or {@code null} if none is set */ protected String resolveProtocol(final Url url) { return choose(url.getProtocol(), baseUrl.getProtocol(), request.getClientUrl() .getProtocol()); }
/** * Resolves current request to a {@link IRequestHandler}. * * @return RequestHandler instance */ protected IRequestHandler resolveRequestHandler() { return requestMapper.mapRequest(request); }
@Override public int getCompatibilityScore(Request request) { return delegate.getCompatibilityScore(request); }
@Override public void detach(IRequestCycle requestCycle) { delegate.detach(requestCycle); } }
/** * @see RequestHandlerExecutor#next() * @return the handler scheduled to be executed after current by the executor */ public IRequestHandler getRequestHandlerScheduledAfterCurrent() { return requestHandlerExecutor.next(); }
@Override public String getFilterPath() { return UrlUtils.normalizePath(filterPath); }
/** * @param name * * @return header string with specified name */ public String getHeader(String name) { return headers.getHeader(name); }
@Override protected void writeFooter(Response response, String encoding) { response.write(END_ROOT_ELEMENT); }
@Override public void respond(final IRequestCycle requestCycle) { requestCycle.getResponse().reset(); delegate.respond(requestCycle); }
/** * Gets port that should be used to render the url * * @param url * url being rendered * @return port or {@code null} if none is set */ protected Integer resolvePort(final Url url) { return choose(url.getPort(), baseUrl.getPort(), request.getClientUrl().getPort()); }
/** * Gets the host name that should be used to render the url * * @param url * url being rendered * @return the host name or {@code null} if none is set */ protected String resolveHost(final Url url) { return choose(url.getHost(), baseUrl.getHost(), request.getClientUrl().getHost()); }
/** * Gets the protocol that should be used to render the url * * @param url * url being rendered * @return the protocol or {@code null} if none is set */ protected String resolveProtocol(final Url url) { return choose(url.getProtocol(), baseUrl.getProtocol(), request.getClientUrl() .getProtocol()); }