HttpServletRequest httpServletReq = requestCycle.getWebRequest().getHttpServletRequest(); String remoteAddr = httpServletReq.getHeader("X-Forwarded-For"); if (remoteAddr == null)
/** * @see org.apache.wicket.markup.html.WebPage#configureResponse() */ protected void configureResponse() { super.configureResponse(); if (getWebRequestCycle().getResponse() instanceof WebResponse) { getWebRequestCycle().getWebResponse().getHttpServletResponse().setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }
@Override protected void logRuntimeException(RuntimeException e) { // do not log unauthorized exceptions if (!(e instanceof org.apache.wicket.authorization.UnauthorizedInstantiationException)) super.logRuntimeException(e); }
public void onRequest() { WebRequestCycle wrc = (WebRequestCycle) RequestCycle.get(); wrc.setRequestTarget(new ProxyResponseTarget()); wrc.setRedirect(false); }
/** * Create and process the request cycle using the current request and response information. * * @param cycle */ public void processRequestCycle(WebRequestCycle cycle) { try { cycle.request(); if (cycle.wasHandled() == false) { cycle.setRequestTarget(new WebErrorCodeResponseTarget( HttpServletResponse.SC_NOT_FOUND)); } cycle.detach(); createRequestCycle(); } finally { cycle.getResponse().close(); } postProcessRequestCycle(cycle); }
(application instanceof WebApplication) && !(getWebRequest().isAjax())) final WebResponse currentResponse = getWebResponse(); try if (getWebRequest() instanceof ServletWebRequest) ((ServletWebRequest)getWebRequest()).setWicketRedirectUrl(Strings.replaceAll( page.urlFor(IRedirectListener.INTERFACE).toString(), "../", "").toString()); setResponse(redirectResponse); setResponse(currentResponse); if (getWebRequest() instanceof ServletWebRequest) ((ServletWebRequest)getWebRequest()).setWicketRedirectUrl(null); String stripped = Strings.replaceAll(redirectUrl, "../", "").toString(); int index = stripped.indexOf("?"); String sessionId = getApplication().getSessionStore().getSessionId(request, true); ((WebApplication)application).addBufferedResponse(sessionId, setResponse(currentResponse); if (ex instanceof AbortException) logRuntimeException(ex);
Page newLastRenderedPage = cycle.getResponsePage(); if (newLastRenderedPage == null) Class<? extends Page> responseClass = cycle.getResponsePageClass(); if (responseClass != null) Session.set(cycle.getSession()); IRequestTarget target = cycle.getRequestTarget(); if (target instanceof IPageRequestTarget)
public ICrypt newCrypt() { WebRequestCycle rc = (WebRequestCycle)RequestCycle.get(); // get http session, create if necessary HttpSession session = rc.getWebRequest().getHttpServletRequest().getSession(true); // retrieve or generate encryption key from session final String keyAttr = rc.getApplication().getApplicationKey() + "." + getClass().getName(); String key = (String)session.getAttribute(keyAttr); if (key == null) { // generate new key key = session.getId() + "." + UUID.randomUUID().toString(); session.setAttribute(keyAttr, key); } // build the crypt based on session key ICrypt crypt = new SunJceCrypt(); crypt.setKey(key); return crypt; } }
protected ClientInfo newClientInfo() if (getApplication().getRequestCycleSettings().getGatherExtendedBrowserInfo()) Session session = getSession(); if (session.getMetaData(BROWSER_WAS_POLLED_KEY) == null) String url = "/" + getRequest().getURL(); throw new RestartResponseException(newBrowserInfoPage(url));
IRequestTarget currentTarget = cycle.getRequestTarget(); if (currentTarget instanceof IPageRequestTarget) String url = cycle.urlFor(requestTarget).toString(); String path = application.getClass().getName(); path = path.substring(path.lastIndexOf('.') + 1); cycle.request(requestTarget); cycle.getResponse().close();
if (cycle.getResponse() instanceof WebResponse) final MockHttpServletResponse httpResponse = (MockHttpServletResponse)cycle.getWebResponse() .getHttpServletResponse(); cycle = setupRequestAndResponse(false); servletRequest.setRequestToRedirectString(redirectLocation); cycle.request(); cycle.request();
@Override protected void onExceptionLoop(RuntimeException e) { super.onExceptionLoop(e); try { getWebResponse().getHttpServletResponse().sendError( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, null); } catch (IOException e1) { // ignore } }
/** * @see org.apache.wicket.RequestCycle#newClientInfo() */ protected ClientInfo newClientInfo() { if (getApplication().getRequestCycleSettings().getGatherExtendedBrowserInfo()) { Session session = getSession(); if (session.getMetaData(BROWSER_WAS_POLLED_KEY) == null) { // we haven't done the redirect yet; record that we will be // doing that now and redirect session.setMetaData(BROWSER_WAS_POLLED_KEY, Boolean.TRUE); String url = "/" + getRequest().getURL(); throw new RestartResponseException(new BrowserInfoPage(url)); } // if we get here, the redirect already has been done; clear // the meta data entry; we don't need it any longer is the client // info object will be cached too session.setMetaData(BROWSER_WAS_POLLED_KEY, (Boolean)null); } return new WebClientInfo(this); }
final IRequestTarget target = cycle.getRequestTarget(); session.createAutoPageMapName(), current.getPageClass(), current.getPageParameters()); url = cycle.urlFor(redirect);
public void renderHead(IHeaderResponse response) { if (loadWicketAjax) { //TODO: cache wicket sources? new AbstractDefaultAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void respond(AjaxRequestTarget target) { } }.renderHead(response); } final WebRequestCycle requestCycle = (WebRequestCycle) RequestCycle.get(); final WebRequest req = (WebRequest) requestCycle.getRequest(); if (!req.isAjax()) { for (CachedHeaderContributor contrib : referencesCache.values()) { contrib.rendered = false; } for (ModuleSet set : moduleSetsCache.values()) { set.rendered = false; } for (Module mod : moduleCache.values()) { mod.rendered = false; } } localContext.renderHead(response); }
@Override protected void onBeforeRender() { super.onBeforeRender(); IRequestTarget target = ((WebRequestCycle)RequestCycle.get()).getRequestTarget(); if(target instanceof AjaxRequestTarget){ //if refreshed by ajax render it again ((AjaxRequestTarget)target).appendJavascript(getInitJs()); } }
WebRequestCycle requestCycle = createRequestCycle(); AjaxRequestTarget target = getApplication().newAjaxRequestTarget(link.getPage()); requestCycle.setRequestTarget(target); WebRequestCycle requestCycle = createRequestCycle(); AjaxRequestTarget target = getApplication().newAjaxRequestTarget(link.getPage()); requestCycle.setRequestTarget(target);
/** * @see org.apache.wicket.Application#newRequestCycle(org.apache.wicket.Request, * org.apache.wicket.Response) */ @Override public RequestCycle newRequestCycle(final Request request, final Response response) { return new WebRequestCycle(this, (WebRequest)request, (WebResponse)response); }
/** * By default returns the WebApplication's default request cycle processor. Typically, you don't * override this method but instead override {@link WebApplication#newRequestCycleProcessor()}. * <p> * <strong>if you decide to override this method to provide a custom processor per request * cycle, any mounts done via WebApplication will not work and and * {@link #onRuntimeException(Page, RuntimeException)} is not called unless you deliberately put * effort in it to make it work.</strong> * </p> * * @see org.apache.wicket.RequestCycle#getProcessor() */ public IRequestCycleProcessor getProcessor() { return ((WebApplication)getApplication()).getRequestCycleProcessor(); }
(application instanceof WebApplication) && !(getWebRequest().isAjax())) final WebResponse currentResponse = getWebResponse(); try if (getWebRequest() instanceof ServletWebRequest) ((ServletWebRequest)getWebRequest()).setWicketRedirectUrl(Strings.replaceAll( page.urlFor(IRedirectListener.INTERFACE).toString(), "../", "").toString()); setResponse(redirectResponse); setResponse(currentResponse); if (getWebRequest() instanceof ServletWebRequest) ((ServletWebRequest)getWebRequest()).setWicketRedirectUrl(null); String sessionId = getApplication().getSessionStore().getSessionId(request, true); ((WebApplication)application).addBufferedResponse(sessionId, bufferId, setResponse(currentResponse); logRuntimeException(ex); IRequestCycleProcessor processor = getProcessor(); processor.respond(ex, this); return;