/** * Retrieves default charset configured in application * * @return charset */ private static String getDefaultEncoding() { return Application.get().getRequestCycleSettings().getResponseRequestEncoding(); }
/** * Url encodes a string * * @param string * string to be encoded * @return encoded string */ protected String urlEncode(String string) { try { return URLEncoder.encode(string, Application.get().getRequestCycleSettings() .getResponseRequestEncoding()); } catch (UnsupportedEncodingException e) { log.error(e.getMessage(), e); return string; } }
/** * Returns a decoded value of the given value * * @param value * @return Decodes the value */ protected String urlDecode(String value) { try { value = URLDecoder.decode(value, Application.get().getRequestCycleSettings() .getResponseRequestEncoding()); } catch (UnsupportedEncodingException ex) { log.error("error decoding parameter", ex); } return value; }
public String decode(String s) { Application app = null; try { app = Application.get(); } catch (WicketRuntimeException ignored) { log.warn("No current Application found - defaulting encoding to UTF-8"); } return decode(s, app == null ? "UTF-8" : app.getRequestCycleSettings().getResponseRequestEncoding()); }
public String encode(String s) { Application app = null; try { app = Application.get(); } catch (WicketRuntimeException ignored) { log.warn("No current Application found - defaulting encoding to UTF-8"); } return encode(s, app == null ? "UTF-8" : app.getRequestCycleSettings().getResponseRequestEncoding()); }
/** * Get the default encoding * * @return default encoding */ public String getCharacterEncoding() { if (defaultEncoding == null) { return Application.get().getRequestCycleSettings().getResponseRequestEncoding(); } else { return defaultEncoding; } }
/** * Get the default encoding * * @return default encoding */ public String getCharacterEncoding() { if (defaultEncoding == null) { return Application.get().getRequestCycleSettings().getResponseRequestEncoding(); } else { return defaultEncoding; } }
/** * Calls encode with the application response request encoding as returned by * Application.get().getRequestCycleSettings().getResponseRequestEncoding() * * @param s * Value to encode * @return String encoded using default Application request/respose encoding */ public String encode(String s) { Application app = null; try { app = Application.get(); } catch (WicketRuntimeException ignored) { log.warn("No current Application found - defaulting encoding to UTF-8"); } return encode(s, app == null ? "UTF-8" : app.getRequestCycleSettings() .getResponseRequestEncoding()); }
/** * Calls decode with the application response request encoding as returned by * Application.get().getRequestCycleSettings().getResponseRequestEncoding() * * @param s * Value to encode * @return String encoded using default Application request/respose encoding */ public String decode(String s) { Application app = null; try { app = Application.get(); } catch (WicketRuntimeException ignored) { log.warn("No current Application found - defaulting encoding to UTF-8"); } return decode(s, app == null ? "UTF-8" : app.getRequestCycleSettings() .getResponseRequestEncoding()); }
@Override public void respond(IRequestCycle requestCycle) { WebResponse r = (WebResponse) requestCycle.getResponse(); // Determine encoding final String encoding = Application.get().getRequestCycleSettings().getResponseRequestEncoding(); r.setContentType("application/json;charset=" + encoding); // Make sure it is not cached r.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); r.setHeader("Cache-Control", "no-cache, must-revalidate"); r.setHeader("Pragma", "no-cache"); r.write(responseJson.toString()); }
public void respond(IRequestCycle requestCycle) { WebResponse webResponse = (WebResponse) requestCycle.getResponse(); // Determine encoding final String encoding = Application.get().getRequestCycleSettings() .getResponseRequestEncoding(); webResponse.setContentType("application/json;charset=" + encoding); // Make sure it is not cached webResponse.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); webResponse.setHeader("Cache-Control", "no-cache, must-revalidate"); webResponse.setHeader("Pragma", "no-cache"); webResponse.write(response.toString()); }
/** * Additional header configs for ajax redirects */ protected void configureAjaxRedirect() { // Set the encoding (see Wicket-2348) final String encoding = Application.get() .getRequestCycleSettings() .getResponseRequestEncoding(); // Set content type based on markup type for page setCharacterEncoding(encoding); setContentType("text/xml; charset=" + encoding); setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); setHeader("Cache-Control", "no-cache, must-revalidate"); setHeader("Pragma", "no-cache"); }
public void respond(RequestCycle requestCycle) { WebResponse r = (WebResponse)requestCycle.getResponse(); // Determine encoding final String encoding = Application.get() .getRequestCycleSettings() .getResponseRequestEncoding(); r.setCharacterEncoding(encoding); r.setContentType("text/xml; charset=" + encoding); // Make sure it is not cached by a r.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); r.setHeader("Cache-Control", "no-cache, must-revalidate"); r.setHeader("Pragma", "no-cache"); Iterator<T> comps = getChoices(val); renderer.renderHeader(r); while (comps.hasNext()) { final T comp = comps.next(); renderer.render(comp, r, val); } renderer.renderFooter(r); }
/** * @see org.apache.wicket.behavior.AbstractBehavior#beforeRender(org.apache.wicket.Component) */ @Override public void beforeRender(Component component) { super.beforeRender(component); final RequestCycle requestCycle = RequestCycle.get(); // Temporarily replace the web response with a String response webResponse = requestCycle.getResponse(); // Determine encoding final String encoding = Application.exists() ? Application.get() .getRequestCycleSettings() .getResponseRequestEncoding() : "UTF-8"; // Set content type based on markup type for page webResponse.setContentType("text/" + getMarkupType(component) + "; charset=" + encoding); // Create a new response object final Response response = newResponse(); if (response == null) { throw new IllegalStateException("newResponse() must not return null"); } // and make it the current one requestCycle.setResponse(response); }
/** * @see org.apache.wicket.IRequestTarget#respond(org.apache.wicket.RequestCycle) */ public void respond(RequestCycle requestCycle) { WebResponse response = (WebResponse)requestCycle.getResponse(); final String encoding = Application.get() .getRequestCycleSettings() .getResponseRequestEncoding(); // Set content type based on markup type for page response.setCharacterEncoding(encoding); response.setContentType("text/xml; charset=" + encoding); // Make sure it is not cached by a client response.setDateHeader("Expires", System.currentTimeMillis()); response.setHeader("Cache-Control", "no-cache, must-revalidate"); response.setHeader("Pragma", "no-cache"); response.write("<?xml version=\"1.0\" encoding=\""); response.write(encoding); response.write("\"?><ajax-response></ajax-response>"); }
private void setResponse(final ServletWebRequest request, final String responseContent) { final Application app = Application.get(); final String encoding = app.getRequestCycleSettings().getResponseRequestEncoding(); final String contentType; if (wantsHtml(request)) { contentType = "text/html; charset=" + encoding; } else { contentType = APPLICATION_JSON; } TextRequestHandler textRequestHandler = new TextRequestHandler(contentType, encoding, responseContent); RequestCycle.get().scheduleRequestHandlerAfterCurrent(textRequestHandler); // touch page and commit request so page gets released (detached) final Session session = Session.get(); final IPageManager pageManager = session.getPageManager(); final Page page = container.getPage(); pageManager.touchPage(page); pageManager.commitRequest(); }
public void respond(RequestCycle requestCycle) { final WebResponse response = (WebResponse) requestCycle.getResponse(); final Application app = Application.get(); final String encoding = app.getRequestCycleSettings().getResponseRequestEncoding(); response.setCharacterEncoding(encoding); response.setContentType("text/xml; charset=" + encoding); // Make sure it is not cached by a client response.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); response.setHeader("Cache-Control", "no-cache, must-revalidate"); response.setHeader("Pragma", "no-cache"); response.write("<?xml version=\"1.0\" encoding=\""); response.write(encoding); response.write("\"?>"); response.write("<ajax-response>"); response.write(responseText); response.write("</ajax-response>"); }
public void respond(RequestCycle requestCycle) { final WebResponse response = (WebResponse) requestCycle.getResponse(); final Application app = Application.get(); final String encoding = app.getRequestCycleSettings().getResponseRequestEncoding(); response.setCharacterEncoding(encoding); response.setContentType("text/xml; charset=" + encoding); // Make sure it is not cached by a client response.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); response.setHeader("Cache-Control", "no-cache, must-revalidate"); response.setHeader("Pragma", "no-cache"); response.write("<?xml version=\"1.0\" encoding=\""); response.write(encoding); response.write("\"?>"); response.write("<ajax-response>"); response.write(responseText); response.write("</ajax-response>"); }
/** * @see org.apache.wicket.IRequestTarget#respond(org.apache.wicket.RequestCycle) */ public void respond(RequestCycle requestCycle) { final Application app = Application.get(); // Determine encoding final String encoding = app.getRequestCycleSettings().getResponseRequestEncoding(); // Set content type based on markup type for page final WebResponse response = (WebResponse) requestCycle.getResponse(); response.setCharacterEncoding(encoding); response.setContentType("text/plain; charset=" + encoding); // Make sure it is not cached by a client response.setHeader("Expires", Time.now().subtract(Duration.minutes(1)).toDateString()); response.setHeader("Cache-Control", "no-cache, must-revalidate"); response.setHeader("Pragma", "no-cache"); response.setLastModifiedTime(Time.now()); // set filename response.setAttachmentHeader(getFilename()); response.write(getContent()); }