Example usage for org.apache.wicket Session get

List of usage examples for org.apache.wicket Session get

Introduction

In this page you can find the example usage for org.apache.wicket Session get.

Prototype

public static Session get() 

Source Link

Document

Returns session associated to current thread.

Usage

From source file:abid.password.wicket.MutablePasswordSession.java

License:Apache License

public static MutablePasswordSession get() {
    return (MutablePasswordSession) Session.get();
}

From source file:at.ac.tuwien.ifs.tita.ui.login.TitaSession.java

License:Apache License

/**
 * Return the session.
 *
 * @return the session
 */
public static final TitaSession getSession() {
    return (TitaSession) Session.get();
}

From source file:at.ait.dme.yuma.suite.framework.YUMAWebSession.java

License:EUPL

/**
 * Utility method that returns the session.
 * @return the session
 */
public static YUMAWebSession get() {
    return (YUMAWebSession) Session.get();
}

From source file:at.molindo.wicketutils.openid.OpenIdSession.java

License:Apache License

public static IOpenIdWebSession getWebSession() {
    return (IOpenIdWebSession) Session.get();
}

From source file:at.molindo.wicketutils.openid.OpenIdSession.java

License:Apache License

private ConsumerManager getConsumerManager() {
    Application app = Session.get().getApplication();
    ConsumerManager consumerManager = app.getMetaData(CONSUMER_MANAGER_KEY);
    if (consumerManager == null) {
        // double checked locking
        synchronized (CONSUMER_MANAGER_KEY) {
            consumerManager = app.getMetaData(CONSUMER_MANAGER_KEY);
            if (consumerManager == null) {
                consumerManager = new ConsumerManager();
                consumerManager.setAssociations(new InMemoryConsumerAssociationStore());
                consumerManager.setNonceVerifier(new InMemoryNonceVerifier(10000));
                app.setMetaData(CONSUMER_MANAGER_KEY, consumerManager);
            }//from   w  w  w . j  a v a2  s  .  c om
        }
    }
    return consumerManager;
}

From source file:at.molindo.wicketutils.utils.MockUtilsTest.java

License:Apache License

@Test
public void withSession() throws Exception {
    DummyApplication testApp = new DummyApplication();
    try {// w  ww .  j  a  va 2 s  .  c o m

        assertFalse(Application.exists());
        assertFalse(Session.exists());
        assertFalse(RequestCycle.get() != null);

        String stringResource = MockUtils.withRequest(testApp, new MockRequestCallback<String>() {

            @Override
            public String call() {
                // some basic testing
                assertTrue(Application.exists());
                assertFalse(Session.exists());
                assertTrue(RequestCycle.get() != null);

                return new StringResourceModel("someResource", (IModel<?>) null, Model.of("default value"))
                        .getString();
            }

        });
        assertEquals("default value", stringResource);

        String url = MockUtils.withRequest(testApp, new MockRequestCallback<String>() {

            @Override
            public String call() {
                return RequestCycle.get().urlFor(HomePage.class, null).toString();
            }

        });
        assertEquals(".", url);

        Locale locale = MockUtils.withRequest(testApp, new IMockRequestCallback<Locale>() {

            @Override
            public void configure(MockRequest request) {
                request.setLocale(Locale.GERMAN);
            }

            @Override
            public Locale call() {
                return Session.get().getLocale();
            }

        });
        assertEquals(Locale.GERMAN, locale);

        assertFalse(Application.exists());
        assertFalse(Session.exists());
        assertFalse(RequestCycle.get() != null);
    } finally {
        testApp.destroy();
    }
}

From source file:at.molindo.wicketutils.utils.WicketUtils.java

License:Apache License

public static WebClientInfo getClientInfo() {
    return (WebClientInfo) Session.get().getClientInfo();
}

From source file:au.com.scds.isis.viewer.wicket.ui.components.entity.properties.MyEntityPropertiesForm.java

License:Apache License

private void addButtons(MarkupContainer markupContainer) {

    // edit button
    editButton = new AjaxButtonWithOnError(ID_EDIT_BUTTON, new ResourceModel("editLabel")) {
        private static final long serialVersionUID = 1L;

        @Override/*from   w w w .j av a 2 s.  c  o  m*/
        public void validate() {

            // same logic as in cancelButton; should this be factored out?
            try {
                getEntityModel().load(ConcurrencyChecking.CHECK);
            } catch (ConcurrencyException ex) {
                getMessageBroker().addMessage("Object changed by " + ex.getOid().getVersion().getUser()
                        + ", automatically reloading");
                getEntityModel().load(ConcurrencyChecking.NO_CHECK);
            }

            super.validate();
        }

        @Override
        public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            getEntityModel().resetPropertyModels();
            toEditMode(target);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.getAjaxCallListeners().add(new org.apache.wicket.ajax.attributes.AjaxCallListener() {

                private static final long serialVersionUID = 1L;

                @Override
                public CharSequence getSuccessHandler(Component component) {
                    // scroll to the top of the entity panel
                    return "$('html, body').animate({"
                            + "        scrollTop: $('.entityIconAndTitlePanel').offset().top" + "    }, 1000);";
                }
            });
        }
    };
    editButton.add(new Label("editLabel", editButton.getModel()));
    markupContainer.add(editButton);

    // ok button
    okButton = new AjaxButtonForValidate(ID_OK_BUTTON, new ResourceModel("okLabel"));
    markupContainer.add(okButton);

    // cancel button
    cancelButton = new AjaxButtonForCancel(ID_CANCEL_BUTTON, new ResourceModel("cancelLabel")) {
        private static final long serialVersionUID = 1L;

        @Override
        public void validate() {

            // same logic as in editButton; should this be factored out?
            try {
                getEntityModel().load(ConcurrencyChecking.CHECK);
            } catch (ConcurrencyException ex) {
                getMessageBroker().addMessage("Object changed by " + ex.getOid().getVersion().getUser()
                        + ", automatically reloading");
                getEntityModel().load(ConcurrencyChecking.NO_CHECK);
            }
            super.validate();
        }

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            Session.get().getFeedbackMessages().clear();
            getForm().clearInput();
            getForm().visitFormComponentsPostOrder(new IVisitor<FormComponent<?>, Void>() {

                @Override
                public void component(FormComponent<?> formComponent, IVisit<Void> visit) {
                    if (formComponent instanceof CancelHintRequired) {
                        final CancelHintRequired cancelHintRequired = (CancelHintRequired) formComponent;
                        cancelHintRequired.onCancel();
                    }
                }
            });

            try {
                getEntityModel().resetPropertyModels();
            } catch (RuntimeException ex) {
                throw ex;
            }
            toViewMode(target);
        }
    };

    markupContainer.add(cancelButton);

    okButton.setOutputMarkupPlaceholderTag(true);
    editButton.setOutputMarkupPlaceholderTag(true);
    cancelButton.setOutputMarkupPlaceholderTag(true);

    // flush any JGrowl messages (typically concurrency exceptions) if they
    // are added.
    okButton.add(new JGrowlBehaviour());
    editButton.add(new JGrowlBehaviour());
    cancelButton.add(new JGrowlBehaviour());
}

From source file:au.org.theark.core.web.component.customfield.SearchResultListPanel.java

License:Open Source License

private WebMarkupContainer buildLinkWMC(final Item<CustomField> item) {

    WebMarkupContainer customfieldLinkWMC = new WebMarkupContainer("customfieldLinkWMC", item.getModel());
    ArkBusyAjaxLink link = new ArkBusyAjaxLink(Constants.CUSTOMFIELD_NAME) {
        @Override/*from  www  . j  ava  2 s  . c  om*/
        public void onClick(AjaxRequestTarget target) {
            // Sets the selected object into the model
            CustomField cf = (CustomField) (getParent().getDefaultModelObject());
            CompoundPropertyModel<CustomFieldVO> newModel = new CompoundPropertyModel<CustomFieldVO>(
                    new CustomFieldVO());
            newModel.getObject().setCustomField(cf);
            newModel.getObject().setUseCustomFieldDisplay(cpModel.getObject().isUseCustomFieldDisplay());

            DetailPanel detailPanel = new DetailPanel("detailPanel", feedbackPanel, newModel,
                    arkCrudContainerVO);
            arkCrudContainerVO.getDetailPanelContainer().addOrReplace(detailPanel);
            ArkCRUDHelper.preProcessDetailPanelOnSearchResults(target, arkCrudContainerVO);
            //Added on 2016-05-26 to stop showing the previous feed back message when deleting or updating in the form.
            //This will clear the feedback message.
            Session.get().cleanupFeedbackMessages();
            target.add(feedbackPanel);
        }
    };
    // Add the label for the link
    CustomField field = item.getModelObject();
    Label nameLinkLabel = new Label("nameLbl", field.getName());
    link.add(nameLinkLabel);
    customfieldLinkWMC.add(link);
    return customfieldLinkWMC;
}

From source file:au.org.theark.core.web.component.customfieldcategory.SearchResultListPanel.java

License:Open Source License

private WebMarkupContainer buildLinkWMC(final Item<CustomFieldCategory> item) {

    WebMarkupContainer customfieldCategoryLinkWMC = new WebMarkupContainer("customfieldCategoryLinkWMC",
            item.getModel());/*  ww w .j  a  v  a  2 s  . c o m*/
    ArkBusyAjaxLink link = new ArkBusyAjaxLink(Constants.CUSTOMFIELDCATEGORY_NAME) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            // Sets the selected object into the model
            CustomFieldCategory cf = (CustomFieldCategory) (getParent().getDefaultModelObject());
            CompoundPropertyModel<CustomFieldCategoryVO> newModel = new CompoundPropertyModel<CustomFieldCategoryVO>(
                    new CustomFieldCategoryVO());
            newModel.getObject().setCustomFieldCategory(cf);
            //newModel.getObject().setUseCustomFieldCategoryDisplay(cpModel.getObject().isUseCustomFieldCategoryDisplay());

            DetailPanel detailPanel = new DetailPanel("detailPanel", feedbackPanel, newModel,
                    arkCrudContainerVO);
            arkCrudContainerVO.getDetailPanelContainer().addOrReplace(detailPanel);
            ArkCRUDHelper.preProcessDetailPanelOnSearchResults(target, arkCrudContainerVO);
            //Added on 2016-05-26 to stop showing the previous feed back message when deleting or updating in the form.
            //This will clear the feedback message.
            Session.get().cleanupFeedbackMessages();
            target.add(feedbackPanel);

        }
    };

    // Add the label for the link
    CustomFieldCategory category = item.getModelObject();
    //Label nameLinkLabel = new Label("nameLbl", category.getName());
    Label nameLinkLabel = new Label("nameLbl", CustomFieldCategoryOrderingHelper.getInstance()
            .preTextDecider(category).concat(category.getName()));
    link.add(nameLinkLabel);
    customfieldCategoryLinkWMC.add(link);
    return customfieldCategoryLinkWMC;
}