Example usage for org.apache.wicket.protocol.http WebSession get

List of usage examples for org.apache.wicket.protocol.http WebSession get

Introduction

In this page you can find the example usage for org.apache.wicket.protocol.http WebSession get.

Prototype

public static WebSession get() 

Source Link

Usage

From source file:com.ccc.crest.need.index.Index.java

License:Open Source License

public Index() {
    // Properties properties = (Properties) ((NeedServer) getApplication()).getServletContext().getAttribute(CoreController.PropertiesKey);

    headerPanel = new HeaderPanel("headerPanel");
    footerPanel = new FooterPanel("footerPanel");
    sidePanel = new WebMarkupContainer("sidePanel");
    add(new Label("nonPriviledgedMessage", "Everyone can see this"));
    sidePanel.add(new Label("priviledged", "Only authenticated users can see this"));

    //        AllocateInterfaceOptionPanel reservePanel = new AllocateInterfaceOptionPanel("allocateInterfaceOptionPanel");
    //        sidePanel.add(reservePanel);
    //        ViewAllocatedPanel viewAllocatedPanel = new ViewAllocatedPanel("viewAllocatedPanel");
    //        sidePanel.add(viewAllocatedPanel);

    //        reservePanel.setVisible(getClientInformation().isAuthenticated());
    //        viewAllocatedPanel.setVisible(getClientInformation().isAuthenticated());
    //        sidePanel.setVisible(getClientInformation().isAuthenticated());

    add(headerPanel);//  w  w  w  .j a  v  a 2  s.co m
    add(footerPanel);
    add(sidePanel);

    boolean isAuthenticated = ((WicketClientInfo) WebSession.get().getClientInfo()).isAuthenticated();
    sidePanel.setVisible(isAuthenticated);

    //        InterfaceData interfaceData = new InterfaceData("[1:{01}]", "1", "opendof");
    //        add(new InterfaceRequestForm("interfaceRequestForm", new CompoundPropertyModel<InterfaceData>(interfaceData)));
    //
    //        add(new BookmarkablePageLink<>("browse", Browse.class));
    //
    //        gcseDiv = new WebMarkupContainer("gcseDiv");
    // String cx = properties.getProperty(NeedServer.GoogleCSEcxKey);
    //        StringBuilder sb = new StringBuilder();
    //        sb.append("<script>");
    //        sb.append("(function() {");
    //        // sb.append("var cx = '" + cx + "';");
    //        sb.append("var gcse = document.createElement('script');");
    //        sb.append("gcse.type = 'text/javascript';");
    //        sb.append("gcse.async = true;");
    //        sb.append("gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;");
    //        sb.append("var s = document.getElementsByTagName('script')[0];");
    //        sb.append("s.parentNode.insertBefore(gcse, s);");
    //        sb.append("})();");
    //        sb.append("</script>");
    //        sb.append("<gcse:search></gcse:search>");
    //        gcseLabel = new Label("gcseLabel", sb.toString());
    //        gcseLabel.setEscapeModelStrings(false);
    //        gcseDiv.add(gcseLabel);
    //        add(gcseDiv);
}

From source file:com.ccc.crest.servlet.auth.CrestAuthCallback.java

License:Open Source License

public CrestAuthCallback(PageParameters parameters) throws Exception {
    super(parameters);
    SessionClientInfo sessionClientInfo = (SessionClientInfo) WebSession.get().getClientInfo();
    handleCallback(parameters, sessionClientInfo);
}

From source file:com.evolveum.midpoint.gui.api.page.PageBase.java

License:Apache License

protected void setTimeZone(PageBase page) {
    PrismObject<UserType> user = loadUserSelf(page);
    String timeZone = null;/*  w  ww .  j  ava  2 s . c  o m*/
    MidPointPrincipal principal = SecurityUtils.getPrincipalUser();
    if (user != null && user.asObjectable().getTimezone() != null) {
        timeZone = user.asObjectable().getTimezone();
    } else {
        timeZone = principal.getAdminGuiConfiguration().getDefaultTimezone();
    }
    if (timeZone != null) {
        WebSession.get().getClientInfo().getProperties().setTimeZone(TimeZone.getTimeZone(timeZone));
    }
}

From source file:com.evolveum.midpoint.web.page.admin.PageAdminFocus.java

License:Apache License

@Override
public void finishProcessing(AjaxRequestTarget target, OperationResult result, boolean returningFromAsync) {

    if (previewRequested) {
        finishPreviewProcessing(target, result);
        return;//from  w  w w . j  a v a 2s .co m
    }
    if (result.isSuccess() && getDelta() != null
            && getDelta().getOid().equals(SecurityUtils.getPrincipalUser().getOid())) {
        UserType user = null;
        if (getObjectWrapper().getObject().asObjectable() instanceof UserType) {
            user = (UserType) getObjectWrapper().getObject().asObjectable();
        }
        Session.get().setLocale(WebModelServiceUtils.getLocale(user));
        LOGGER.debug("Using {} as locale", getLocale());
        WebSession.get().getClientInfo().getProperties().setTimeZone(WebModelServiceUtils.getTimezone(user));
        LOGGER.debug("Using {} as time zone", WebSession.get().getClientInfo().getProperties().getTimeZone());
    }
    boolean focusAddAttempted = getDelta() != null && getDelta().isAdd();
    boolean focusAddSucceeded = focusAddAttempted && StringUtils.isNotEmpty(getDelta().getOid());

    // we don't want to allow resuming editing if a new focal object was created (on second 'save' there would be a conflict with itself)
    // and also in case of partial errors, like those related to projections (many deltas would be already executed, and this could cause problems on second 'save').
    boolean canContinueEditing = !focusAddSucceeded && result.isFatalError();

    boolean canExitPage;
    if (returningFromAsync) {
        canExitPage = getProgressReporter().isAllSuccess(); // if there's at least a warning in the progress table, we would like to keep the table open
    } else {
        canExitPage = !canContinueEditing; // no point in staying on page if we cannot continue editing (in synchronous case i.e. no progress table present)
    }

    if (!isKeepDisplayingResults() && canExitPage) {
        showResult(result);
        redirectBack();
    } else {
        if (returningFromAsync) {
            getProgressReporter().showBackButton(target);
            getProgressReporter().hideAbortButton(target);
        }
        showResult(result);
        target.add(getFeedbackPanel());

        if (canContinueEditing) {
            getProgressReporter().hideBackButton(target);
            getProgressReporter().showContinueEditingButton(target);
        }
    }
}

From source file:com.gitblit.wicket.panels.ObjectContainer.java

License:Apache License

protected ClientProperties getClientProperties() {
    if (clientProperties == null) {
        ClientInfo clientInfo = WebSession.get().getClientInfo();

        if (clientInfo == null || !(clientInfo instanceof WebClientInfo)) {
            clientInfo = new WebClientInfo(getRequestCycle());
            WebSession.get().setClientInfo(clientInfo);
        }//www.j  a va2  s  .co  m

        clientProperties = ((WebClientInfo) clientInfo).getProperties();
    }
    return (clientProperties);
}

From source file:com.googlecode.wicket.jquery.ui.form.button.SecuredAjaxButton.java

License:Apache License

/**
 * Constructor//from   w  w w  .  j ava  2s.  com
 * @param id the markup id
 * @param roles list of roles allowed to enable the button
 */
public SecuredAjaxButton(String id, String... roles) {
    this(id, (IJQuerySecurityProvider) WebSession.get(), roles);
}

From source file:com.googlecode.wicket.jquery.ui.form.button.SecuredAjaxButton.java

License:Apache License

/**
 * Constructor/*  w  w  w  . ja  va  2  s  .  co  m*/
 * @param id the markup id
 * @param form the {@link Form}
 * @param roles list of roles allowed to enable the button
 */
public SecuredAjaxButton(String id, Form<?> form, String... roles) {
    this(id, form, (IJQuerySecurityProvider) WebSession.get(), roles);
}

From source file:com.googlecode.wicket.jquery.ui.form.button.SecuredAjaxButton.java

License:Apache License

/**
 * Constructor//from  ww  w  .  j a v a2s.c o  m
 * @param id the markup id
 * @param model the {@link IModel}
 * @param roles list of roles allowed to enable the button
 */
public SecuredAjaxButton(String id, IModel<String> model, String... roles) {
    this(id, model, (IJQuerySecurityProvider) WebSession.get(), roles);
}

From source file:com.googlecode.wicket.jquery.ui.form.button.SecuredAjaxButton.java

License:Apache License

/**
 * Constructor//from  w  w w . jav  a  2 s  .  c o  m
 * @param id the markup id
 * @param model the {@link IModel}
 * @param form the {@link Form}
 * @param roles list of roles allowed to enable the button
 */
public SecuredAjaxButton(String id, IModel<String> model, Form<?> form, String... roles) {
    this(id, model, form, (IJQuerySecurityProvider) WebSession.get(), roles);
}

From source file:com.googlecode.wicket.jquery.ui.form.button.SecuredButton.java

License:Apache License

/**
 * Constructor/*from  w w w  .ja  va2  s.com*/
 * @param id the markup id
 * @param roles list of roles allowed to enable the button
 */
public SecuredButton(String id, String... roles) {
    this(id, (IJQuerySecurityProvider) WebSession.get(), roles);
}