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


Java Session類代碼示例

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


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

示例1: newManageContainer

import org.apache.wicket.Session; //導入依賴的package包/類
private WebMarkupContainer newManageContainer() {
	WebMarkupContainer container = new WebMarkupContainer("manage");
	container.setVisible(SecurityUtils.canModify(getPullRequest()));
	container.add(new Link<Void>("synchronize") {

		@Override
		public void onClick() {
			GitPlex.getInstance(PullRequestManager.class).check(getPullRequest());
			Session.get().success("Pull request is synchronized");
		}
		
	});
	container.add(new Link<Void>("delete") {

		@Override
		public void onClick() {
			PullRequest request = getPullRequest();
			GitPlex.getInstance(PullRequestManager.class).delete(request);
			Session.get().success("Pull request #" + request.getNumber() + " is deleted");
			setResponsePage(RequestListPage.class, RequestListPage.paramsOf(getProject()));
		}
		
	}.add(new ConfirmOnClick("Do you really want to delete this pull request?")));
	return container;
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:26,代碼來源:RequestOverviewPage.java

示例2: loadStringResource

import org.apache.wicket.Session; //導入依賴的package包/類
@Override
public String loadStringResource(Component component, String key, Locale locale, String style, String variation) {
    if (locale == null) {
        locale = Session.exists() ? Session.get().getLocale() : Locale.getDefault();
    }

    ResourceBundle.Control control = new UTF8Control();
    try {
        return ResourceBundle.getBundle(bundleName, locale, control).getString(key);
    } catch (MissingResourceException ex) {
        try {
            return ResourceBundle.getBundle(bundleName, locale,
                    Thread.currentThread().getContextClassLoader(), control).getString(key);
        } catch (MissingResourceException ex2) {
            return null;
        }
    }
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:19,代碼來源:Utf8BundleStringResourceLoader.java

示例3: getUrlString

import org.apache.wicket.Session; //導入依賴的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

示例4: AllFacetValuesPage

import org.apache.wicket.Session; //導入依賴的package包/類
public AllFacetValuesPage(PageParameters params) {
    super(params);

    this.selectionModel = Model.of(parametersConverter.fromParameters(params));
    final StringValue facetValue = params.get(SELECTED_FACET_PARAM);
    if (facetValue.isEmpty()) {
        Session.get().error("No facet provided for all values page");
        throw new RestartResponseException(new FacetedSearchPage(selectionModel));
    }

    final String facet = facetParamMapper.getFacet(facetValue.toString());

    if (vloConfig.getFacetsInSearch().contains(facet)) {
        // create a new model so that all values will be retrieved
        setModel(new FacetFieldModel(facet, facetFieldsService, selectionModel)); // gets all facet values
    }
    if (getModelObject() == null) {
        Session.get().error(String.format("Facet '%s' could not be found", facet));
        ErrorPage.triggerErrorPage(ErrorPage.ErrorType.PAGE_NOT_FOUND, params);
    }

    addComponents();
}
 
開發者ID:acdh-oeaw,項目名稱:vlo-curation,代碼行數:24,代碼來源:AllFacetValuesPage.java

示例5: processTheme

import org.apache.wicket.Session; //導入依賴的package包/類
/**
 * Sets the theme from the page parameters if applicable. An present but
 * empty theme value will reset the theme (by unsetting the style).
 *
 * @param parameters page parameters to process
 * @see VloWebAppParameters#THEME
 * @see Session#setStyle(java.lang.String)
 */
private void processTheme(PageParameters parameters) {
    final StringValue themeValue = parameters.get(VloWebAppParameters.THEME);
    if (!themeValue.isNull()) {
        if (themeValue.isEmpty()) {
            // empty string resets theme
            logger.debug("Resetting theme");
            Session.get().setStyle(null);
        } else {
            // theme found, set it as style in the session
            final String theme = themeValue.toString().toLowerCase();
            logger.debug("Setting theme to {}", theme);
            Session.get().setStyle(theme);
        }

        /*
         * Remove theme parameter to prevent it from interfering with 
         * further processing, specifically the parameters check in 
         * the simple page search
         */
        parameters.remove(VloWebAppParameters.THEME, themeValue.toString());
    }
}
 
開發者ID:acdh-oeaw,項目名稱:vlo-curation,代碼行數:31,代碼來源:VloBasePage.java

示例6: NotificationPage

import org.apache.wicket.Session; //導入依賴的package包/類
public NotificationPage() {
	super();

	// Create the modal window.
	this.addNotificationModal = new AddNotificationModal("addNotificationModal", this);
	this.add(this.addNotificationModal);

	// add notificationList
	if (((AuthenticatedSession) Session.get()).getUser() != null) {
		// logged in users see their notifications
		final NotificationList notificationList = new NotificationList("notificationList", this);
		notificationList.setOutputMarkupId(true);
		this.add(notificationList);
	} else {
		final Label notificationListLabel = new Label("notificationList", "Log in to check your notifications.");
		notificationListLabel.setOutputMarkupId(true);
		this.add(notificationListLabel);
	}

	this.form = new Form<Void>("form");
	this.form.add(this.addAddButton());
	this.form.add(this.addDeleteAllButton());
	this.add(this.form);

	this.addNotificationRules();
}
 
開發者ID:bptlab,項目名稱:Unicorn,代碼行數:27,代碼來源:NotificationPage.java

示例7: buildMainLayout

import org.apache.wicket.Session; //導入依賴的package包/類
private void buildMainLayout() {
	this.loginForm = new WarnOnExitForm("loginForm");

	this.emailInput = new TextField<String>("emailInput", Model.of(""));
	this.loginForm.add(this.emailInput);

	this.passwordInput = new PasswordTextField("passwordInput", Model.of(""));
	this.loginForm.add(this.passwordInput);

	this.addLoginButton();
	this.addRegisterLink();

	this.add(this.loginForm);

	this.logoutForm = new Form<Object>("logoutForm");

	this.addLogoutButton();

	this.add(this.logoutForm);

	if (((AuthenticatedSession) Session.get()).getUser() != null) {
		this.loginForm.setVisible(false);
	} else {
		this.logoutForm.setVisible(false);
	}
}
 
開發者ID:bptlab,項目名稱:Unicorn,代碼行數:27,代碼來源:LoginPage.java

示例8: isInstantiationAuthorized

import org.apache.wicket.Session; //導入依賴的package包/類
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) {
	// if it's not a wicket page --> allow
	if (!Page.class.isAssignableFrom(componentClass)) {
		return true;
	}

	// if it's a page that does not require authentication --> allow
	for (Class<? extends WebPage> clazz : PAGES_WO_AUTH_REQ) {
		if (clazz.isAssignableFrom(componentClass)) {
			return true;
		}
	}

	// if it's any other wicket page and user is not logged in -->
	// redirect to login page
	if (!((UQSession) Session.get()).isAuthenticated()) {
		throw new RestartResponseAtInterceptPageException(LoginPage.class);
	}
	return true;
}
 
開發者ID:U-QASAR,項目名稱:u-qasar.platform,代碼行數:22,代碼來源:UQasarRedirectWithoutLoginStrategy.java

示例9: getValidPageInstance

import org.apache.wicket.Session; //導入依賴的package包/類
protected Page getValidPageInstance() throws LinkInvalidTargetRuntimeException {
	Page pageInstance = pageInstanceModel.getObject();
	if (pageInstance == null) {
		throw new LinkInvalidTargetRuntimeException("The target page instance was null");
	}
	
	Class<? extends Page> validPageClass = getValidExpectedPageClass(pageInstance);
	
	if (validPageClass == null) {
		throw new LinkInvalidTargetRuntimeException("The target page instance '" + pageInstance + "' had unexpected type :"
				+ " got " + pageInstance.getClass().getName() + ", "
				+ "expected one of " + Joiner.on(", ").join(Collections2.transform(expectedPageClassModels, GET_NAME_FROM_CLASS_MODEL_FUNCTION)));
	}
	
	if (! bypassPermissions) {
		if (!Session.get().getAuthorizationStrategy().isActionAuthorized(pageInstance, Page.RENDER)) {
			throw new LinkInvalidTargetRuntimeException("The rendering of the target page instance '" + pageInstance
					+ "' was not authorized.");
		}
	}
	
	return pageInstance;
}
 
開發者ID:openwide-java,項目名稱:owsi-core-parent,代碼行數:24,代碼來源:CorePageInstanceLinkGenerator.java

示例10: getDeleteLink

import org.apache.wicket.Session; //導入依賴的package包/類
protected MarkupContainer getDeleteLink(String id, final IModel<? extends T> itemModel) {
	return AjaxConfirmLink.<T>build()
			.title(getDeleteConfirmationTitleModel(itemModel))
			.content(getDeleteConfirmationTextModel(itemModel))
			.yes(getDeleteConfirmationYesLabelModel(itemModel))
			.no(getDeleteConfirmationNoLabelModel(itemModel))
			.onClick(new AbstractAjaxAction() {
				private static final long serialVersionUID = 1L;
				@Override
				public void execute(AjaxRequestTarget target) {
					try {
						doDeleteItem(itemModel);
						Session.get().success(getString("common.delete.success"));
					} catch (Exception e) {
						Session.get().error(getString("common.delete.error"));
					}
					target.add(getPage());
					dataProvider.detach();
					FeedbackUtils.refreshFeedback(target, getPage());
				}
			})
			.create(id, ReadOnlyModel.of(itemModel));
}
 
開發者ID:openwide-java,項目名稱:owsi-core-parent,代碼行數:24,代碼來源:AbstractGenericItemListPanel.java

示例11: LinkBreadCrumbElementPanel

import org.apache.wicket.Session; //導入依賴的package包/類
public LinkBreadCrumbElementPanel(String id, BreadCrumbElement breadCrumbElement, BreadCrumbMarkupTagRenderingBehavior renderingBehavior) {
	super(id, breadCrumbElement.getLabelModel());
	
	Link<Void> breadCrumbLink = new BookmarkablePageLink<Void>("breadCrumbElementLink", breadCrumbElement.getPageClass(),
			breadCrumbElement.getPageParameters()) {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onConfigure() {
			super.onConfigure();
			
			setVisible(Session.get().getAuthorizationStrategy().isInstantiationAuthorized(getPageClass()));
		}
	};
	breadCrumbLink.setBody(getModel());
	breadCrumbLink.add(renderingBehavior);
	add(breadCrumbLink);
	
	add(
			Condition.componentVisible(breadCrumbLink).thenShowInternal()
	);
}
 
開發者ID:openwide-java,項目名稱:owsi-core-parent,代碼行數:23,代碼來源:LinkBreadCrumbElementPanel.java

示例12: setDefaultResponsePageIfNecessary

import org.apache.wicket.Session; //導入依賴的package包/類
private void setDefaultResponsePageIfNecessary()
{
    // This does not work because it was Spring Security that intercepted the access, not
    // Wicket continueToOriginalDestination();

    String redirectUrl = getRedirectUrl();
    
    if (redirectUrl == null || redirectUrl.contains(".IBehaviorListener.")
            || redirectUrl.contains("-logoutPanel-")) {
        log.debug("Redirecting to welcome page");
        setResponsePage(getApplication().getHomePage());
    }
    else {
        log.debug("Redirecting to saved URL: [{}]", redirectUrl);
        if (isNotBlank(form.urlfragment) && form.urlfragment.startsWith("!")) {
            Url url = Url.parse("http://dummy?" + form.urlfragment.substring(1));
            UrlRequestParametersAdapter adapter = new UrlRequestParametersAdapter(url);
            LinkedHashMap<String, StringValue> params = new LinkedHashMap<>();
            for (String name : adapter.getParameterNames()) {
                params.put(name, adapter.getParameterValue(name));
            }
            Session.get().setMetaData(SessionMetaData.LOGIN_URL_FRAGMENT_PARAMS, params);
        }
        throw new NonResettingRestartException(redirectUrl);
    }
}
 
開發者ID:webanno,項目名稱:webanno,代碼行數:27,代碼來源:LoginPage.java

示例13: AnnotationPage

import org.apache.wicket.Session; //導入依賴的package包/類
public AnnotationPage()
{
    super();
    LOG.debug("Setting up annotation page without parameters");
    commonInit();
    
    Map<String, StringValue> fragmentParameters = Session.get()
            .getMetaData(SessionMetaData.LOGIN_URL_FRAGMENT_PARAMS);
    if (fragmentParameters != null) {
        // Clear the URL fragment parameters - we only use them once!
        Session.get().setMetaData(SessionMetaData.LOGIN_URL_FRAGMENT_PARAMS, null);
        
        StringValue project = fragmentParameters.get(PAGE_PARAM_PROJECT_ID);
        StringValue document = fragmentParameters.get(PAGE_PARAM_DOCUMENT_ID);
        StringValue focus = fragmentParameters.get(PAGE_PARAM_FOCUS);
        
        handleParameters(null, project, document, focus, false);
    }
}
 
開發者ID:webanno,項目名稱:webanno,代碼行數:20,代碼來源:AnnotationPage.java

示例14: bind

import org.apache.wicket.Session; //導入依賴的package包/類
@Override
public void bind(Request request, Session newSession)
{
	if (getAttribute(request, Session.SESSION_ATTRIBUTE_NAME) != newSession)
	{
		// call template method
		onBind(request, newSession);
		for (BindListener listener : getBindListeners())
		{
			listener.bindingSession(request, newSession);
		}

		HttpSession httpSession = getHttpSession(request, false);

		if (httpSession != null)
		{
			// register an unbinding listener for cleaning up
			String applicationKey = Application.get().getName();
			httpSession.setAttribute("Wicket:SessionUnbindingListener-" + applicationKey,
				new SessionBindingListener(applicationKey, newSession));
		}
		// register the session object itself
		setAttribute(request, Session.SESSION_ATTRIBUTE_NAME, newSession);
	}
}
 
開發者ID:baholladay,項目名稱:WicketRedisSession,代碼行數:26,代碼來源:RedisSessionStore.java

示例15: SignInPage

import org.apache.wicket.Session; //導入依賴的package包/類
public SignInPage(PageParameters params) {
super(params);
    
add(new StartPageHeaderPanel("header"));
add(new FooterPanel("footer"));

   add(new Label("title", new ResourceModel("page.title.signin")));

   add(new Label("message", new AbstractReadOnlyModel<String>() {
       @Override
       public String getObject() {
         OntopolySession session = (OntopolySession)Session.findOrCreate();
         return session.getSignInMessage();
       }
     }));
   add(new SignInForm("form"));
 }
 
開發者ID:ontopia,項目名稱:ontopia,代碼行數:18,代碼來源:SignInPage.java


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