Example usage for org.apache.wicket RestartResponseException RestartResponseException

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

Introduction

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

Prototype

public RestartResponseException(final IRequestablePage page) 

Source Link

Document

Redirects to the specified page

Usage

From source file:com.barchart.kerberos.server.ui.panel.login.LoginPanel.java

License:Apache License

/**
 * Called when sign-in was remembered./*from w w  w. j  a  v a 2 s .  c  o m*/
 * <p>
 * By default tries to continue to the original destination or switches to
 * the application's home page.
 * <p>
 * Note: This method will be called during rendering of this panel, thus a
 * {@link RestartResponseException} has to be used to switch to a different
 * page.
 * 
 * @see #onConfigure()
 */
protected void onSignInRemembered() {
    // logon successful. Continue to the original destination
    continueToOriginalDestination();

    // Ups, no original destination. Go to the home page
    throw new RestartResponseException(getApplication().getHomePage());
}

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

License:Apache License

public Task createSimpleTask(String operation) {
    MidPointPrincipal user = SecurityUtils.getPrincipalUser();
    if (user == null) {
        throw new RestartResponseException(PageLogin.class);
    }//w ww.  jav a 2s.  c  o m
    return WebModelServiceUtils.createSimpleTask(operation, user.getUser().asPrismObject(), getTaskManager());
}

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

License:Apache License

public RestartResponseException getRestartResponseException(Class<? extends Page> defaultBackPageClass) {
    return new RestartResponseException(defaultBackPageClass);
}

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

License:Apache License

public RestartResponseException redirectBackViaRestartResponseException() {
    List<Breadcrumb> breadcrumbs = getSessionStorage().getBreadcrumbs();
    if (breadcrumbs.size() < 2) {
        getSessionStorage().clearBreadcrumbs();

        if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_DASHBOARD_URL,
                AuthorizationConstants.AUTZ_UI_HOME_ALL_URL)) {
            return new RestartResponseException(PageDashboard.class);
        } else {/*from ww  w.  j  av  a 2 s .c om*/
            return new RestartResponseException(PageSelfDashboard.class);
        }
    }

    Breadcrumb breadcrumb = breadcrumbs.get(breadcrumbs.size() - 2);
    redirectBackToBreadcrumb(breadcrumb);
    return breadcrumb.getRestartResponseException();
}

From source file:com.evolveum.midpoint.gui.api.util.WebModelServiceUtils.java

License:Apache License

public static Task createSimpleTask(String operation, PrismObject<UserType> owner, TaskManager manager) {
    Task task = manager.createTaskInstance(operation);

    if (owner == null) {
        MidPointPrincipal user = SecurityUtils.getPrincipalUser();
        if (user == null) {
            throw new RestartResponseException(PageLogin.class);
        } else {/*from  w  w  w.  j a v  a  2  s. c  o m*/
            owner = user.getUser().asPrismObject();
        }
    }

    task.setOwner(owner);
    task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI);

    return task;
}

From source file:com.evolveum.midpoint.gui.impl.model.FlexibleLabelModel.java

License:Apache License

private String getDefaultValue() {
    C object = model.getObject();/*from w w w  .j  a  v a  2  s . c o m*/
    PrismProperty<?> property;
    try {
        property = object.asPrismContainerValue().findOrCreateProperty(path);
    } catch (SchemaException ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't create property in path {}", ex, path);
        //todo show message in page error [lazyman]
        throw new RestartResponseException(PageError.class);
    }

    return getStringRealValue(property != null ? property.getRealValue() : null);
}

From source file:com.evolveum.midpoint.web.component.assignment.SelfConsentPanel.java

License:Apache License

public SelfConsentPanel(String id, IModel<AssignmentType> model, PageBase parentPage) {
    super(id, model);

    Task task = parentPage.createSimpleTask(OPERATION_LOAD_TARGET);
    OperationResult result = task.getResult();

    // TODO: is this OK? We should NOT be loading this in constructor, should we?
    // ... also, we should use utility method for loading

    PrismObject<AbstractRoleType> abstractRole = WebModelServiceUtils
            .loadObject(getModelObject().getTargetRef(), parentPage, task, result);

    if (abstractRole == null) {
        getSession().error("Failed to load target ref");
        throw new RestartResponseException(PageSelfDashboard.class);
    }/* w ww .  j a  v a 2s  .co m*/

    initLayout(abstractRole.asObjectable());
}

From source file:com.evolveum.midpoint.web.component.breadcrumbs.BreadcrumbPageClass.java

License:Apache License

@Override
public RestartResponseException getRestartResponseException() {
    if (parameters == null) {
        return new RestartResponseException(page);
    } else {/*from ww w .j av a 2  s .  c  om*/
        return new RestartResponseException(page, parameters);
    }
}

From source file:com.evolveum.midpoint.web.component.breadcrumbs.BreadcrumbPageInstance.java

License:Apache License

@Override
public RestartResponseException getRestartResponseException() {
    return new RestartResponseException(page);
}

From source file:com.evolveum.midpoint.web.component.data.column.ObjectNameColumn.java

License:Apache License

@Override
public void populateItem(final Item<ICellPopulator<SelectableBean<O>>> cellItem, String componentId,
        final IModel<SelectableBean<O>> rowModel) {

    IModel<String> labelModel = new AbstractReadOnlyModel<String>() {
        private static final long serialVersionUID = 1L;

        @Override/*from  www .  ja v  a  2  s.  c o m*/
        public String getObject() {
            SelectableBean<O> selectableBean = rowModel.getObject();
            O value = selectableBean.getValue();
            if (value == null) {
                OperationResult result = selectableBean.getResult();
                OperationResultStatusPresentationProperties props = OperationResultStatusPresentationProperties
                        .parseOperationalResultStatus(result.getStatus());
                return cellItem.getString(props.getStatusLabelKey());
            } else {
                String name = WebComponentUtil.getName(value);
                if (selectableBean.getResult() != null) {
                    StringBuilder complexName = new StringBuilder();
                    complexName.append(name);
                    complexName.append(" (");
                    complexName.append(selectableBean.getResult().getStatus());
                    complexName.append(")");
                    return complexName.toString();
                }
                return name;

            }
        }
    };

    if (isClickable(rowModel)) { // beware: rowModel is very probably resolved at this moment; but it seems to cause no problems
        cellItem.add(new LinkPanel(componentId, labelModel) {
            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                SelectableBean<O> selectableBean = rowModel.getObject();
                O value = selectableBean.getValue();
                if (value == null) {
                    OperationResult result = selectableBean.getResult();
                    throw new RestartResponseException(new PageOperationResult(result));
                } else {
                    if (selectableBean.getResult() != null) {
                        throw new RestartResponseException(new PageOperationResult(selectableBean.getResult()));
                    } else {
                        ObjectNameColumn.this.onClick(target, rowModel);
                    }
                }
            }
        });
    } else {
        cellItem.add(new Label(componentId, labelModel));
    }
}