Example usage for org.apache.wicket RestartResponseAtInterceptPageException RestartResponseAtInterceptPageException

List of usage examples for org.apache.wicket RestartResponseAtInterceptPageException RestartResponseAtInterceptPageException

Introduction

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

Prototype

public RestartResponseAtInterceptPageException(Class<? extends Page> interceptPageClass) 

Source Link

Document

Redirects to the specified intercept page, this will result in a bookmarkable redirect.

Usage

From source file:cz.zcu.kiv.eegdatabase.wui.ui.pricing.PriceListPage.java

License:Apache License

public PriceListPage() {

    // XXX price list hidden for now. exception redirect for access via url.
    throw new RestartResponseAtInterceptPageException(ListExperimentsByPackagePage.class);
    /*//w ww .  j  a  v a  2s.  com
            
    setPageTitle(ResourceUtils.getModel("pageTitle.pricelist"));
    add(new ButtonPageMenu("leftMenu", ExperimentsPageLeftMenu.values()));
            
    setupComponents();
    */
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.scenarios.form.ScenarioFormPage.java

License:Apache License

public ScenarioFormPage(PageParameters params) {

    add(new ButtonPageMenu("leftMenu", ScenariosPageLeftMenu.values()));

    setPageTitle(ResourceUtils.getModel("pageTitle.editScenarioSchema"));

    add(new Label("title", ResourceUtils.getModel("pageTitle.editScenarioSchema")));

    int scenarioId = parseParameters(params);

    if (!security.userIsOwnerOfScenario(scenarioId) && !security.isAdmin())
        throw new RestartResponseAtInterceptPageException(ListScenariosPage.class);

    add(new ScenarioForm("form", new Model<Scenario>(scenarioFacade.read(scenarioId)), getFeedback()));
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.scenarios.ListScenariosPage.java

License:Apache License

public ListScenariosPage(PageParameters parameters) {
    StringValue paramValue = parameters.get(MY_SCENARIOS_PARAM);
    if (paramValue.isNull() || paramValue.isEmpty()) {
        throw new RestartResponseAtInterceptPageException(ListScenariosPage.class);
    } else {//w ww .ja  v  a 2  s .c o  m
        setPageTitle(ResourceUtils.getModel("menuItem.myScenarios"));
        add(new Label("title", ResourceUtils.getModel("menuItem.myScenarios")));
        setupComponents(new MyScenarioDataProvider(scenariosFacade));
    }
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.scenarios.ScenarioDetailPage.java

License:Apache License

private int parseParameters(PageParameters parameters) {

    StringValue value = parameters.get(BasePage.DEFAULT_PARAM_ID);
    if (value.isNull() || value.isEmpty()) {
        throw new RestartResponseAtInterceptPageException(EEGDataBaseApplication.get().getHomePage());
    }//from w w  w  . ja va  2  s .  com
    return value.toInt();
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.security.ConfirmPage.java

License:Apache License

private void setupConfirmation(PageParameters parameters) {

    boolean confirm = false;
    IModel<String> titleText;
    IModel<String> messageText;
    IModel<String> message2Text;

    if (!parameters.get(EMAIL).isNull()) {
        titleText = ResourceUtils.getModel("pageTitle.registrationSuccessfull");
        messageText = new Model<String>(ResourceUtils.getString("text.registrationSuccessfull.youNeedConfirm")
                + parameters.get(EMAIL).toString());
        message2Text = messageText;

    } else {/*  ww w  .ja  va 2 s .c om*/

        if (parameters.get(CONFIRM_ACTIVATION).isNull() || parameters.get(CONFIRM_ACTIVATION).isEmpty()) {
            throw new RestartResponseAtInterceptPageException(HomePage.class);
        }

        String activationHashCode = parameters.get(CONFIRM_ACTIVATION).toString();

        Person person = personFacade.getPersonByHash(activationHashCode);
        if (person == null) {
            titleText = ResourceUtils.getModel("pageTitle.registrationFalse");
            messageText = ResourceUtils.getModel("text.registrationExpired");
            message2Text = messageText;
        } else if (person.isConfirmed()) {
            titleText = ResourceUtils.getModel("pageTitle.confirmationRepeated");
            messageText = ResourceUtils.getModel("text.registrationConfirmedOnce");
            message2Text = messageText;
        } else if (confirmedInTime(System.currentTimeMillis(), person)) {
            confirm = true;
            person.setConfirmed(true);
            personFacade.update(person);
            titleText = ResourceUtils.getModel("pageTitle.confirmationSuccessfull");
            messageText = ResourceUtils.getModel("text.registrationSuccessfull.youCanLogIn.part1");
            message2Text = ResourceUtils.getModel("text.registrationSuccessfull.youCanLogIn.part2");
        } else {
            personFacade.delete(person);
            titleText = ResourceUtils.getModel("pageTitle.registrationFalse");
            messageText = ResourceUtils.getModel("text.registrationExpired");
            message2Text = messageText;
        }
    }

    Label title = new Label(TITLE_ID, titleText);
    Label message = new Label(MESSAGE_ID, messageText);
    Label message2 = new Label(MESSAGE_2_ID, message2Text);
    Link<Void> link = new Link<Void>("link") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            setResponsePage(HomePage.class);
        }
    };
    add(title, message, message2, link);
    link.setVisibilityAllowed(confirm);
    message2.setVisibilityAllowed(confirm);

}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.shoppingCart.PayPalConfirmPaymentPage.java

License:Apache License

public PayPalConfirmPaymentPage(PageParameters parameters) {
    // Token received from PayPal server. It contains token value for current order.
    String token = parameters.get("token").toString();
    if (token == null) {
        throw new RestartResponseAtInterceptPageException(EEGDataBaseApplication.get().getHomePage());
    }//ww w  .j a  v  a 2s  .  c  o  m
    setupComponents(token);
}

From source file:de.inren.frontend.auth.B4AuthorizationStrategy.java

License:Apache License

@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) {

    // Allow all non secured components
    if (!ISecured.class.isAssignableFrom(componentClass)) {
        return true;
    }/*www .java  2s .co m*/

    // Deny all others
    if (!((BasicAuthenticationSession) Session.get()).isSignedIn()) {
        throw new RestartResponseAtInterceptPageException(LoginPage.class);
    }

    return true;
}

From source file:dk.teachus.frontend.components.person.PersonPanel.java

License:Apache License

public PersonPanel(String id, final PersonModel<? extends Person> personModel) {
    super(id, personModel);

    if (allowUserEditing(TeachUsSession.get().getPerson(), personModel.getObject()) == false) {
        throw new RestartResponseAtInterceptPageException(Application.get().getHomePage());
    }/*from w w  w.  j  a v  a 2s.com*/

    FormPanel formPanel = new FormPanel("form"); //$NON-NLS-1$
    add(formPanel);

    // Name
    StringTextFieldElement nameField = new StringTextFieldElement(
            TeachUsSession.get().getString("General.name"), new PropertyModel<String>(personModel, "name"), //$NON-NLS-1$//$NON-NLS-2$
            true, 32);
    nameField.add(StringValidator.lengthBetween(2, 100));
    formPanel.addElement(nameField);

    // Email
    StringTextFieldElement emailField = new StringTextFieldElement(
            TeachUsSession.get().getString("General.email"), new PropertyModel<String>(personModel, "email"), //$NON-NLS-1$//$NON-NLS-2$
            true, 50);
    emailField.add(EmailAddressValidator.getInstance());
    formPanel.addElement(emailField);

    // Phone number
    formPanel.addElement(new IntegerFieldElement(TeachUsSession.get().getString("General.phoneNumber"), //$NON-NLS-1$
            new PropertyModel<Integer>(personModel, "phoneNumber"), 10)); //$NON-NLS-1$

    // Username
    if (isUsernameEnabled()) {
        StringTextFieldElement usernameField = new StringTextFieldElement(
                TeachUsSession.get().getString("General.username"), //$NON-NLS-1$
                new PropertyModel<String>(personModel, "username"), true); //$NON-NLS-1$
        usernameField.add(StringValidator.lengthBetween(3, 50));

        // Validate the username for correct content
        usernameField.add(new PatternValidator("^[a-zA-Z0-9-_]+$") { //$NON-NLS-1$
            private static final long serialVersionUID = 1L;

            @Override
            public void error(IValidatable<String> validatable) {
                ValidationError validationError = new ValidationError();
                validationError.setMessage(TeachUsSession.get().getString("PersonPanel.usernameCharacters"));
                validatable.error(validationError); //$NON-NLS-1$
            }
        });

        // validate the username checking for dublicates
        usernameField.add(new IValidator<String>() {
            private static final long serialVersionUID = 1L;

            public void validate(IValidatable<String> validatable) {
                PersonDAO personDAO = TeachUsApplication.get().getPersonDAO();
                String username = validatable.getValue();

                Person existingPerson = personDAO.usernameExists(username);

                if (existingPerson != null
                        && existingPerson.getId().equals(personModel.getPersonId()) == false) {
                    String localeString = TeachUsSession.get().getString("PersonPanel.userAlreadyExists"); //$NON-NLS-1$
                    localeString = localeString.replace("${username}", username); //$NON-NLS-1$
                    ValidationError validationError = new ValidationError();
                    validationError.setMessage(localeString);
                    validatable.error(validationError);
                }
            }
        });
        formPanel.addElement(usernameField);
    } else {
        formPanel.addElement(new ReadOnlyElement(TeachUsSession.get().getString("General.username"), //$NON-NLS-1$
                new PropertyModel<Object>(personModel, "username"))); //$NON-NLS-1$
    }

    // Password 1
    if (isPasswordVisible()) {
        final PasswordFieldElement password1Field = new PasswordFieldElement(
                TeachUsSession.get().getString("General.password"), //$NON-NLS-1$
                new PropertyModel<String>(this, "password1"), personModel.getPersonId() == null); //$NON-NLS-1$
        password1Field.add(StringValidator.lengthBetween(4, 32));
        formPanel.addElement(password1Field);

        // Password 2
        final PasswordFieldElement password2Field = new PasswordFieldElement(
                TeachUsSession.get().getString("PersonPanel.repeatPassword"), //$NON-NLS-1$
                new PropertyModel<String>(this, "password2")); //$NON-NLS-1$
        formPanel.addElement(password2Field);

        // Password validator
        formPanel.addValidator(new FormValidator() {
            private static final long serialVersionUID = 1L;

            public IFormValidator getFormValidator() {
                return new EqualInputValidator(password1Field.getFormComponent(),
                        password2Field.getFormComponent());
            }
        });
    }

    // Locale
    if (isLocaleVisible()) {
        List<Locale> availableLocales = TeachUsApplication.get().getAvailableLocales();
        formPanel.addElement(new DropDownElement<Locale>(TeachUsSession.get().getString("General.locale"), //$NON-NLS-1$
                new PropertyModel<Locale>(personModel, "locale"), availableLocales, //$NON-NLS-1$
                new LocaleChoiceRenderer()));
    }

    if (isCurrencyVisible()) {
        StringTextFieldElement currencyField = new StringTextFieldElement(
                TeachUsSession.get().getString("General.currency"), //$NON-NLS-1$
                new PropertyModel<String>(personModel, "currency"), 4); //$NON-NLS-1$
        currencyField.add(StringValidator.lengthBetween(0, 10));
        formPanel.addElement(currencyField); //$NON-NLS-1$ //$NON-NLS-2$
    }

    // Theme
    if (isThemeVisible()) {
        List<Theme> themes = Arrays.asList(Theme.values());
        formPanel.addElement(new DropDownElement<Theme>(TeachUsSession.get().getString("General.theme"), //$NON-NLS-1$
                new PropertyModel<Theme>(personModel, "theme"), themes, new ThemeChoiceRenderer())); //$NON-NLS-1$
    }

    // Teacher
    if (isTeacherVisible()) {
        formPanel.addElement(new ReadOnlyElement(TeachUsSession.get().getString("General.teacher"), //$NON-NLS-1$
                new PropertyModel<Object>(personModel, "teacher.name"))); //$NON-NLS-1$
    }

    // iCalendar URL
    formPanel.addElement(
            new ReadOnlyElement(TeachUsSession.get().getString("Ical.label"), new IcalUrlModel(personModel)));

    // Additional elements
    appendElements(formPanel);

    // Notes
    if (isNotesVisible()) {
        formPanel.addElement(new TextAreaElement("Notes", new PropertyModel<String>(personModel, "notes")));
    }

    // Buttons
    formPanel.addElement(new ButtonPanelElement() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onCancel() {
            getRequestCycle().setResponsePage(getPersonsPageClass());
        }

        @Override
        protected void onSave(AjaxRequestTarget target) {
            if (Strings.isEmpty(password1) == false) {
                personModel.setPassword(password1);
            }

            personModel.save();

            PersonPanel.this.onSave(personModel.getObject());

            getRequestCycle().setResponsePage(getPersonsPageClass());
        }
    });
}

From source file:dk.teachus.frontend.pages.AuthenticatedBasePage.java

License:Apache License

public AuthenticatedBasePage(UserLevel userLevel, boolean explicitUserLevel) {
    TeachUsSession teachUsSession = TeachUsSession.get();

    if (userLevel.authorized(teachUsSession.getUserLevel()) == false) {
        throw new RestartResponseAtInterceptPageException(Application.get().getHomePage());
    }/*from  w ww  .j  ava2  s .co  m*/

    // If the userlevel is explicit, then only allow users of the same userlevel
    // on this page.
    if (explicitUserLevel) {
        if (teachUsSession.getUserLevel() != userLevel) {
            throw new RestartResponseAtInterceptPageException(Application.get().getHomePage());
        }
    }
}

From source file:dk.teachus.frontend.pages.calendar.TeacherCalendarPage.java

License:Apache License

public TeacherCalendarPage(DateMidnight pageDate) {
    super(UserLevel.TEACHER, true);

    if (TeachUsSession.get().getUserLevel() != UserLevel.TEACHER) {
        throw new RestartResponseAtInterceptPageException(Application.get().getHomePage());
    }//  ww w .ja  v  a2s  .  c  o m

    add(new TeacherPeriodsCalendarPanel("calendar", new Model<DateMidnight>(pageDate)));
}