List of usage examples for org.apache.wicket Component getRequest
public final Request getRequest()
From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.behaviors.MultiUpdatingTimerBehavior.java
License:Apache License
@Override public void renderHead(final Component component, final IHeaderResponse response) { super.renderHead(component, response); response.render(JavaScriptHeaderItem.forScript( "if (typeof(Wicket.TimerHandles) === 'undefined') {Wicket.TimerHandles = {}}", WICKET_TIMERS_ID)); final WebRequest request = (WebRequest) component.getRequest(); if (!isStopped() && (!headRendered || !request.isAjax())) { headRendered = true;/*from ww w . ja va 2 s . co m*/ response.render(OnLoadHeaderItem.forScript(getJsTimeoutCall(updateInterval))); } }
From source file:com.pushinginertia.wicket.core.util.ComponentUtils.java
License:Open Source License
/** * Constructs a URL by using the same port and scheme/protocol as what was used to request the current page. * @param component component the call is being made from (used to obtain the container request) * @param absolutePath absolute path to append after the host name (can be null), a leading '/' will be added if * omitted/* w w w . j a va 2 s . co m*/ * @return */ public static String constructUrl(final Component component, final String absolutePath) { ValidateAs.notNull(component, "component"); return constructUrl(component.getRequest(), absolutePath); }
From source file:com.pushinginertia.wicket.core.util.ComponentUtils.java
License:Open Source License
/** * Constructs a URL by using the same port and scheme/protocol as what was used to request the current page. * @param component component the call is being made from (used to obtain the container request) * @param hostName host name to use in the constructed URL * @param absolutePath absolute path to append after the host name (can be null), a leading '/' will be added if * omitted/*from www . j a v a 2s . c o m*/ * @return */ public static String constructUrl(final Component component, final String hostName, final String absolutePath) { ValidateAs.notNull(component, "component"); return constructUrl(component.getRequest(), hostName, absolutePath); }
From source file:com.pushinginertia.wicket.core.util.ComponentUtils.java
License:Open Source License
/** * Constructs the full URL to redirect to for a given target page and its parameters, with the option to override * the host name./*from w ww. j a v a2 s . c o m*/ * @param component component the call is being made from (used to obtain the container request) * @param hostName host name to use in the constructed URL * @param targetPage target page * @param pageParameters parameters for the target page (may be null) * @return full URL * @see org.apache.wicket.request.UrlRenderer#renderFullUrl(org.apache.wicket.request.Url) */ public static String constructRedirectUrl(final Component component, final String hostName, final Class<? extends Page> targetPage, final PageParameters pageParameters) { ValidateAs.notNull(component, "component"); ValidateAs.notNull(targetPage, "targetPage"); final HttpServletRequest req = (HttpServletRequest) component.getRequest().getContainerRequest(); final String relativePath = component.urlFor(targetPage, pageParameters).toString(); final String requestURI = req.getRequestURI(); String absolutePath; try { absolutePath = RequestUtils.toAbsolutePath(requestURI, relativePath); } catch (final StringIndexOutOfBoundsException e) { // sometimes the wicket method throws an exception when the input is something like: // requestPath="/404", relativePagePath="../../../page-name" // strip all leading occurrences of "../" from the relativePath final StringBuilder sb = new StringBuilder(relativePath); while (sb.indexOf("../") == 0) { sb.delete(0, 3); } absolutePath = sb.toString(); } catch (final RuntimeException e) { // this call can throw StringIndexOutOfBoundsException: String index out of range: -1 // it seems to be a wicket bug but I need to log the input to figure out how to reproduce it LOG.error("Error constructing absolute path for inputs requestPath=[" + requestURI + "], relativePagePath=[" + relativePath + "]", e); throw e; } return constructUrl(component, hostName, absolutePath); }
From source file:org.apache.openmeetings.web.util.CallbackFunctionHelper.java
License:Apache License
public static StringValue getParam(Component cmp, String name) { return cmp.getRequest().getRequestParameters().getParameterValue(name); }
From source file:org.artifactory.webapp.wicket.application.RepoBrowsingAwareUnauthorizedComponentInstantiationListener.java
License:Open Source License
@Override public void onUnauthorizedInstantiation(Component component) { WebRequest webRequest = (WebRequest) component.getRequest(); RequestUtils.removeRepoPath(webRequest, true); delegate.onUnauthorizedInstantiation(component); }
From source file:org.sakaiproject.scorm.ui.player.util.Utils.java
License:Educational Community License
public final static String generateUrl(IBehavior behavior, RequestListenerInterface rlix, Component component, boolean isRelative) { if (component == null) throw new IllegalArgumentException("Behavior must be bound to a component to create the URL"); final RequestListenerInterface rli = IBehaviorListener.INTERFACE; String relativePagePath = component.urlFor(behavior, rli).toString(); String url = null;/*from w w w. jav a 2s. c o m*/ if (!isRelative) { WebRequest webRequest = (WebRequest) component.getRequest(); HttpServletRequest servletRequest = webRequest.getHttpServletRequest(); //url.append(servletRequest.getContextPath()).append("/"); //String requestUrl = servletRequest.getRequestURL().toString(); //url = RequestUtils.toAbsolutePath(requestUrl, relativePagePath); String contextPath = servletRequest.getContextPath(); String relativePath = relativePagePath.replaceAll("\\.\\.\\/", ""); url = new StringBuilder(contextPath).append("/").append(relativePath).toString(); } else { url = relativePagePath; } return url; }
From source file:org.sakaiproject.scorm.ui.ResourceNavigator.java
License:Educational Community License
public void displayResource(final SessionBean sessionBean, Object target) { if (null == sessionBean) return;// w w w .j a v a 2 s . c o m if (sessionBean.isEnded() && target != null) { ((AjaxRequestTarget) target).appendJavascript( "window.location.href='" + sessionBean.getCompletionUrl() + "';initResizing();"); } String url = getUrl(sessionBean); // Don't bother to display anything if a null url is returned. if (null == url) return; if (log.isDebugEnabled()) log.debug("Going to " + url); Component component = getFrameComponent(); WebRequest webRequest = (WebRequest) component.getRequest(); HttpServletRequest servletRequest = webRequest.getHttpServletRequest(); String fullUrl = new StringBuilder(servletRequest.getContextPath()).append("/").append(url).toString(); if (useLocationRedirect()) { component.add(new AttributeModifier("src", new Model(fullUrl))); if (target != null) { ((AjaxRequestTarget) target).addComponent(component); ((AjaxRequestTarget) target).appendJavascript("initResizing();"); } } else if (target != null) { // It's critical to the proper functioning of the tool that this logic be maintained for SjaxCall // This is due to a bug in Firefox's handling of Javascript when an iframe has control of the XMLHttpRequest ((AjaxRequestTarget) target) .appendJavascript("parent.scormContent.location.href='" + fullUrl + "';initResizing();"); } }
From source file:sf.wicklet.ext.behaviors.ajax.AjaxRefreshTimerBehavior.java
License:Apache License
@Override public void renderHead(final Component component, final IHeaderResponse response) { super.renderHead(component, response); response.render(JavaScriptHeaderItem.forScript( "if (typeof(Wicket.TimerHandles) === 'undefined') {Wicket.TimerHandles = {}}", TIMERS_ID)); final WebRequest request = (WebRequest) component.getRequest(); if (!isStopped() && (!headRendered || !request.isAjax())) { headRendered = true;/*w ww . j a v a2s . c om*/ response.render(OnLoadHeaderItem.forScript(getJsTimeoutCall(updateInterval))); } }