當前位置: 首頁>>代碼示例>>Java>>正文


Java RequestCycle類代碼示例

本文整理匯總了Java中org.apache.wicket.request.cycle.RequestCycle的典型用法代碼示例。如果您正苦於以下問題:Java RequestCycle類的具體用法?Java RequestCycle怎麽用?Java RequestCycle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RequestCycle類屬於org.apache.wicket.request.cycle包,在下文中一共展示了RequestCycle類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getUrlString

import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
@Override
public String getUrlString(Class<? extends Page> pageClass, QueryFacetsSelection selection, SolrDocument document) {
    final PageParameters params = new PageParameters();
    if (selection != null) {
        params.mergeWith(paramsConverter.toParameters(selection));
    }

    if (document != null) {
        params.add(VloWebAppParameters.DOCUMENT_ID, document.getFirstValue(FacetConstants.FIELD_ID));
    }

    final String style = Session.get().getStyle();
    if (style != null) {
        params.add(VloWebAppParameters.THEME, style);
    }

    final CharSequence url = RequestCycle.get().urlFor(pageClass, params);
    final String absoluteUrl = RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse(url));
    return absoluteUrl;
}
 
開發者ID:acdh-oeaw,項目名稱:vlo-curation,代碼行數:21,代碼來源:PermalinkServiceImpl.java

示例2: newWebRequest

import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
@Override
public WebRequest newWebRequest(HttpServletRequest servletRequest, String filterPath) {
	return new ServletWebRequest(servletRequest, filterPath) {

		@Override
		public boolean shouldPreserveClientUrl() {
			if (RequestCycle.get().getActiveRequestHandler() instanceof RenderPageRequestHandler) {
				RenderPageRequestHandler requestHandler = 
						(RenderPageRequestHandler) RequestCycle.get().getActiveRequestHandler();
				
				/*
				 *  Add this to make sure that the page url does not change upon errors, so that 
				 *  user can know which page is actually causing the error. This behavior is common
				 *  for main stream applications.   
				 */
				if (requestHandler.getPage() instanceof BaseErrorPage) 
					return true;
			}
			return super.shouldPreserveClientUrl();
		}
		
	};
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:24,代碼來源:GitPlexWebApplication.java

示例3: respond

import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
@Override
protected void respond(AjaxRequestTarget target) {
	IRequestParameters params = RequestCycle.get().getRequest().getPostParameters();
	
	String tooltipId = params.getParameterValue("tooltip").toString();
	String commitHash = params.getParameterValue("commit").toString();
	RevCommit commit = getProject().getRevCommit(commitHash);
	String authoring;
	if (commit.getAuthorIdent() != null) {
		authoring = commit.getAuthorIdent().getName();
		if (commit.getCommitterIdent() != null)
			authoring += " " + DateUtils.formatAge(commit.getCommitterIdent().getWhen());
		authoring = "'" + JavaScriptEscape.escapeJavaScript(authoring) + "'";
	} else {
		authoring = "undefined";
	}
	String message = JavaScriptEscape.escapeJavaScript(commit.getFullMessage());
	String script = String.format("gitplex.server.blameMessage.show('%s', %s, '%s');", tooltipId, authoring, message); 
	target.appendJavaScript(script);
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:21,代碼來源:BlameMessageBehavior.java

示例4: MarkdownEditor

import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
/**
 * @param id 
 * 			component id of the editor
 * @param model
 * 			markdown model of the editor
 * @param compactMode
 * 			editor in compact mode occupies horizontal space and is suitable 
 * 			to be used in places such as comment aside the code
 */
public MarkdownEditor(String id, IModel<String> model, boolean compactMode) {
	super(id, model);
	this.compactMode = compactMode;
	
	String cookieKey;
	if (compactMode)
		cookieKey = "markdownEditor.compactMode.split";
	else
		cookieKey = "markdownEditor.normalMode.split";
	
	WebRequest request = (WebRequest) RequestCycle.get().getRequest();
	Cookie cookie = request.getCookie(cookieKey);
	if (cookie!=null && "true".equals(cookie.getValue())) {
		initialSplit = true;
	} else {
		initialSplit = !compactMode;
	}
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:28,代碼來源:MarkdownEditor.java

示例5: storeRecentOpened

import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
private void storeRecentOpened(String blobPath) {
	List<String> recentOpened = getRecentOpened();
	recentOpened.remove(blobPath);
	recentOpened.add(0, blobPath);
	while (recentOpened.size() > MAX_RECENT_OPENED)
		recentOpened.remove(recentOpened.size()-1);
	String encoded;
	try {
		encoded = URLEncoder.encode(Joiner.on("\n").join(recentOpened), Charsets.UTF_8.name());
	} catch (UnsupportedEncodingException e) {
		throw new RuntimeException(e);
	}
	Cookie cookie = new Cookie(COOKIE_RECENT_OPENED, encoded);
	cookie.setMaxAge(Integer.MAX_VALUE);
	WebResponse response = (WebResponse) RequestCycle.get().getResponse();
	response.addCookie(cookie);
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:18,代碼來源:QuickSearchPanel.java

示例6: AdvancedSearchPanel

import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
public AdvancedSearchPanel(String id, IModel<Project> projectModel, IModel<String> revisionModel) {
	super(id);
	
	this.projectModel = projectModel;
	this.revisionModel = revisionModel;
	
	WebRequest request = (WebRequest) RequestCycle.get().getRequest();
	Cookie cookie = request.getCookie(COOKIE_SEARCH_TYPE);
	if (cookie != null) {
		try {
			option = (SearchOption) Class.forName(cookie.getValue()).newInstance();
		} catch (Exception e) {
			logger.debug("Error restoring search option from cookie", e);
		}
	}
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:17,代碼來源:AdvancedSearchPanel.java

示例7: isInstantiationAuthorized

import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) {
    if (componentClass == CmsPage.class) {
        RequestCycle requestCycle = RequestCycle.get();
        String pageId = requestCycle.getRequest().getQueryParameters().getParameterValue("pageId").toString("");
        PageRoleTable pageRoleTable = Tables.PAGE_ROLE.as("pageRoleTable");
        RoleTable roleTable = Tables.ROLE.as("roleTable");
        DSLContext context = Spring.getBean(DSLContext.class);
        List<String> roles = context.select(roleTable.NAME).from(roleTable).innerJoin(pageRoleTable).on(roleTable.ROLE_ID.eq(pageRoleTable.ROLE_ID)).where(pageRoleTable.PAGE_ID.eq(pageId)).fetchInto(String.class);
        Roles r = new Roles();
        if (roles != null && !roles.isEmpty()) {
            r.addAll(roles);
        }
        return hasAny(r);
    } else {
        return super.isInstantiationAuthorized(componentClass);
    }
}
 
開發者ID:PkayJava,項目名稱:MBaaS,代碼行數:19,代碼來源:AnnotationsRoleAuthorizationStrategy.java

示例8: init

import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
@Override
protected void init() {
    super.init();

    getRequestCycleListeners().add(new AbstractRequestCycleListener() {
        @Override
        public void onBeginRequest(RequestCycle cycle) {
            super.onBeginRequest(cycle);

            if (cycle.getRequest() instanceof ServletWebRequest) {
                ServletWebRequest req = (ServletWebRequest) cycle.getRequest();
                AttributePrincipal principal = (AttributePrincipal) req.getContainerRequest().getUserPrincipal();
                String user = req.getContainerRequest().getRemoteUser();
                System.out.println("Principal: " + principal);
                System.out.println("Attributes:");
                for (Entry<String, Object> e : principal.getAttributes().entrySet()) {
                    System.out.println(e.getKey() + ":" + e.getValue() + "(" + e.getValue().getClass() + ")");
                }
                System.out.println("Principal Name: " + principal.getName());
                System.out.println("Principal Class: " + principal.getClass());
                System.out.println("Remote User: " + user);
            }
        }
    });
}
 
開發者ID:merzlikinvs,項目名稱:cas-playground,代碼行數:26,代碼來源:ExampleApplication.java

示例9: onRequestHandlerScheduled

import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
@Override
public void onRequestHandlerScheduled(RequestCycle cycle, IRequestHandler handler) {
    if (handler instanceof RenderPageRequestHandler) {
        Class<? extends IRequestablePage> pageClass = ((RenderPageRequestHandler) handler).getPageClass();
        if (REQUEST_LOGGER.isTraceEnabled()) {
            REQUEST_LOGGER.trace("REQUEST CYCLE: Scheduled redirect to page {}", pageClass);
        }
        if (PageError.class.isAssignableFrom(pageClass)) {
            REQUEST_LOGGER.info("REQUEST CYCLE: Scheduled redirect to error page {}", pageClass);
        }
    } else {
        if (REQUEST_LOGGER.isTraceEnabled()) {
            REQUEST_LOGGER.trace("REQUEST CYCLE: Scheduled request handler {}",
                    WebComponentUtil.debugHandler(handler));
        }
    }
    super.onRequestHandlerScheduled(cycle, handler);
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:19,代碼來源:LoggingRequestCycleListener.java

示例10: onConfigure

import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
@Override
protected void onConfigure() {
    super.onConfigure();

    ServletWebRequest req = (ServletWebRequest) RequestCycle.get().getRequest();
    HttpServletRequest httpReq = req.getContainerRequest();
    HttpSession httpSession = httpReq.getSession();

    Exception ex = (Exception) httpSession.getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
    if (ex == null) {
        return;
    }

    String key = ex.getMessage() != null ? ex.getMessage() : "web.security.provider.unavailable";
    error(getString(key));

    httpSession.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);

    clearBreadcrumbs();
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:21,代碼來源:PageLogin.java

示例11: getBaseURL

import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
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("");
    }
 
開發者ID:opensingular,項目名稱:singular-server,代碼行數:19,代碼來源:DispatcherPageUtil.java

示例12: init

import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
/**
 * @see org.apache.wicket.Application#init()
 */
@Override
public void init()
{
	super.init();

	// TODO STEP 7b: uncomment to enable injection of fortress spring beans:
	getComponentInstantiationListeners().add(new SpringComponentInjector(this));

	// Catch runtime exceptions this way:
	getRequestCycleListeners().add( new AbstractRequestCycleListener()
	{
		@Override
		public IRequestHandler onException( RequestCycle cycle, Exception e )
		{
			return new RenderPageRequestHandler( new PageProvider( new ErrorPage( e ) ) );
		}
	} );
	getMarkupSettings().setStripWicketTags(true);

	getRequestCycleSettings().setRenderStrategy( RequestCycleSettings.RenderStrategy.ONE_PASS_RENDER);
}
 
開發者ID:shawnmckinney,項目名稱:fortress-saml-demo,代碼行數:25,代碼來源:WicketApplication.java

示例13: SSOLoginHOTPPage

import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
public SSOLoginHOTPPage() {
    final SSOLoginData loginData = SSOUtils.getSsoLoginData(this);
    if (loginData == null) {
        RequestCycle.get().setResponsePage(new SSOLoginErrorPage(new Model<String>("No login data found")));
    }

    final LoginBean loginBean = new LoginBean();
    Form<Void> form = new Form<Void>("form") {
        @Override
        protected void onSubmit() {
            doOnSubmit(loginBean, loginData);
        }
    };
    add(form);
    form.add(new PasswordTextField("hotp", new PropertyModel<String>(loginBean, "hotp")));

    errorMessageLabel = new Label("message", errorMessageModel);
    errorMessageLabel.setVisible(StringUtils.hasLength(errorMessageModel.getObject()));
    form.add(errorMessageLabel);
}
 
開發者ID:payneteasy,項目名稱:superfly,代碼行數:21,代碼來源:SSOLoginHOTPPage.java

示例14: randomizeOncePerRequestCycle

import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
private void randomizeOncePerRequestCycle() {
    if (lastRandomizedRequestCycle != RequestCycle.get()) {
        lastRandomizedRequestCycle = RequestCycle.get();
        Assertions.assertThat(lastRandomizedRequestCycle == RequestCycle.get())
                .as("RequestCycle.get() always returns a different instance?!?")
                .isTrue(); //sanity check
        final List<ICarouselImage> imgs = new ArrayList<ICarouselImage>();
        for (int i = 1; i <= 5; i++) {
            final String path = "FrameworkSlogan_" + i + ".jpg";
            final PackageResourceReference resource = new PackageResourceReference(getClass(), path);
            final Url url = RequestCycle.get().mapUrlFor(resource, null);
            imgs.add(new CarouselImage(url.toString()));
        }
        Collections.shuffle(imgs);
        frameworkSloganImgs = imgs;
    }
}
 
開發者ID:subes,項目名稱:invesdwin-nowicket,代碼行數:18,代碼來源:Introduction.java

示例15: init

import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
/**
 * @see org.apache.wicket.Application#init()
 */
@Override
public void init()
{
	super.init();

	// Enable injection of fortress spring beans:
	getComponentInstantiationListeners().add(new SpringComponentInjector(this));

	// Catch runtime exceptions this way:
	getRequestCycleListeners().add( new AbstractRequestCycleListener()
	{
		@Override
		public IRequestHandler onException( RequestCycle cycle, Exception e )
		{
			return new RenderPageRequestHandler( new PageProvider( new ErrorPage( e ) ) );
		}
	} );
	getMarkupSettings().setStripWicketTags(true);
	getRequestCycleSettings().setRenderStrategy( RequestCycleSettings.RenderStrategy.ONE_PASS_RENDER);
}
 
開發者ID:shawnmckinney,項目名稱:role-engineering-sample,代碼行數:24,代碼來源:WicketApplication.java


注:本文中的org.apache.wicket.request.cycle.RequestCycle類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。