本文整理汇总了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;
}
示例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;
}
}
}
示例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;
}
示例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();
}
示例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());
}
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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));
}
示例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()
);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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"));
}