@Override protected boolean isActive() { return RequestCycle.get() .getRequest() .getRequestParameters() .getParameterValue(ActionContext.ITEM_PARAM_NAME) .toString("") .equals(this.title); }
@Override protected void respond(AjaxRequestTarget target) { final RequestCycle requestCycle = RequestCycle.get(); final String value = requestCycle.getRequest().getQueryParameters().getParameterValue(QUERY).toString(); final IRequestHandler handler = this.newRequestHandler(value); requestCycle.scheduleRequestHandlerAfterCurrent(handler); }
@Override protected Response getRealResponse() { return RequestCycle.get().getResponse(); } }
@Override public void initialize() { if (!ajaxRequestScheduled) { RequestCycle.get().scheduleRequestHandlerAfterCurrent(target); ajaxRequestScheduled = true; } } };
/** * Constructor for root node * * @param id the node-id * @param object the wrapped object * @param pageClass {@link Page} to redirect to * @param parameters the page parameters */ public TreeNode(int id, T object, Class<? extends Page> pageClass, PageParameters parameters) { this(id, ROOT, object, RequestCycle.get().urlFor(pageClass, parameters)); }
@Override public final void onRequest() { Attributes a = new Attributes(RequestCycle.get().getRequest(), RequestCycle.get() .getResponse(), null); resource.respond(a); super.onRequest(); } }
@Override protected final void onTimer(AjaxRequestTarget target) { stop(target); RequestCycle requestCycle = RequestCycle.get(); IRequestParameters requestParameters = requestCycle.getRequest().getRequestParameters(); WebClientInfo clientInfo = newWebClientInfo(requestCycle); clientInfo.getProperties().read(requestParameters); Session.get().setClientInfo(clientInfo); onClientInfo(target, clientInfo); }
public static String getBaseURL() { final RequestCycle requestCycle = RequestCycle.get(); final Request request = requestCycle.getRequest(); final String currentPath = request.getUrl().toString(); String fullUrl = requestCycle.getUrlRenderer().renderFullUrl(request.getUrl()); if (org.apache.commons.lang3.StringUtils.isNotBlank(currentPath)) { final int beginPath = fullUrl.lastIndexOf(currentPath); fullUrl = fullUrl.substring(0, beginPath - 1); } final Optional<String> contextPath = Optional.ofNullable(requestCycle.getRequest().getContextPath()); final Optional<String> filterPath = Optional.ofNullable(requestCycle.getRequest().getFilterPath()); return fullUrl + contextPath.orElse("") + filterPath.orElse(""); }
public void addToastrMessage(ToastrType toastrType, String message) { ToastrSettings settings = getDefaultSettings(); settings.getToastrType().setValue(toastrType); settings.getNotificationTitle().setValue(message); if (!((WebRequest) RequestCycle.get().getRequest()).isAjax()) { component.add($b.onReadyScript((ISupplier<CharSequence>) () -> generateJs(settings, false))); } else { AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class); target.appendJavaScript(generateJs(settings, true)); } }
protected Map<String, String> getParameters() { final Request request = RequestCycle.get().getRequest(); final IRequestParameters parameters = request.getPostParameters(); return parameters.getParameterNames() .stream() .collect(Collectors.toMap( name -> name, name -> parameters.getParameterValue(name).toString() )); }
private void afterParse(Component tableComponent) { tableComponent.getPage().endComponentRender(tableComponent); Application.get() .getComponentPreOnBeforeRenderListeners() .remove(PathSetupListener.INSTANCE); RequestCycle.get().setResponse(originalResponse); originalResponse = null; cellExporter = null; }
public static String getLinkForUser(ODocument doc) { String id = doc.field(OrienteerUser.PROP_RESTORE_ID); PageParameters params = new PageParameters(); params.add(PARAMETER_ID, id); CharSequence url = RequestCycle.get().urlFor(new SharedResourceReference(RES_KEY), params); return RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse(url)); }
@Override public void onRequest() { RequestCycle.get().scheduleRequestHandlerAfterCurrent(EmptyAjaxRequestHandler.getInstance()); getLogger().info(String.format("Keeping session with id %s alive.", Session.get().getId())); }
private void updateId() { RequestCycle requestCycle = RequestCycle.get(); if (requestCycle != null) { id = getSessionStore().getSessionId(requestCycle.getRequest(), false); } }
/** * Build value to Origin header based on RequestCycle Url * * @return Origin header */ protected String createOriginHeader(){ Url url = RequestCycle.get().getRequest().getUrl(); return url.getProtocol() + "://" +url.getHost() + ":" + url.getPort(); }
@Override public CharSequence getBeforeSendHandler(Component component) { IRequestHandler handler = new ResourceReferenceRequestHandler( AbstractPostAjaxBehavior.INDICATOR); CharSequence url = RequestCycle.get().urlFor(handler); return String.format("" + "$('#%s-working-indicator').remove(); " + "$('#%s').after('<img id=\"%s-working-indicator\" src=\"%s\" class=\"working-indicator\"></img>');", component.getMarkupId(), component.getMarkupId(), component.getMarkupId(), url); }
@Programmatic @Override public Locale getLocale() { // Request Cycle can be null, e.g. during the start of an application RequestCycle requestCycle = RequestCycle.get(); if (!Application.exists() || requestCycle == null) { // eg if request from RO viewer return null; } return RequestCycle.get().getRequest().getLocale(); }
private boolean isActiveItem(IModel<String> urlModel) { String currentUrl = RequestCycle.get().getRequest().getUrl().getPath(); String url = urlModel.getObject(); return url!=null && currentUrl.equals(url.replaceFirst("^/", "")); } }
/** * Indicates whether the query contains the specified parameter * * @param name the name of the query parameter * @return {@code true} if the parameter is found */ public static boolean hasQueryParameter(final String name) { final RequestCycle requestCycle = RequestCycle.get(); final IRequestParameters parameters = requestCycle.getRequest().getQueryParameters(); return parameters.getParameterNames().stream().anyMatch(name::equals); }