Example usage for org.apache.wicket.ajax AjaxRequestTarget add

List of usage examples for org.apache.wicket.ajax AjaxRequestTarget add

Introduction

In this page you can find the example usage for org.apache.wicket.ajax AjaxRequestTarget add.

Prototype

void add(Component... components);

Source Link

Document

Adds components to the list of components to be rendered.

Usage

From source file:com.evolveum.midpoint.gui.impl.page.admin.configuration.component.LoggingConfigurationTabPanel.java

License:Apache License

private void loggerEditPerformed(AjaxRequestTarget target,
        IModel<ContainerValueWrapper<ClassLoggerConfigurationType>> rowModel,
        List<ContainerValueWrapper<ClassLoggerConfigurationType>> listItems) {
    if (rowModel != null) {
        ContainerValueWrapper<ClassLoggerConfigurationType> logger = rowModel.getObject();
        logger.setSelected(true);/*from  www  .ja  va2 s  .com*/
    } else {
        for (ContainerValueWrapper<ClassLoggerConfigurationType> logger : listItems) {
            logger.setSelected(true);
        }
    }
    target.add(getLoggersMultivalueContainerListPanel());
}

From source file:com.evolveum.midpoint.gui.impl.page.admin.configuration.component.NotificationConfigTabPanel.java

License:Apache License

protected void initLayout() {

    PropertyWrapperFromContainerWrapperModel<MailConfigurationType, NotificationConfigurationType> mailConfig = new PropertyWrapperFromContainerWrapperModel<MailConfigurationType, NotificationConfigurationType>(
            getModel().getObject(), NotificationConfigurationType.F_MAIL);

    add(createHeader(ID_MAIL_CONFIG_HEADER,
            mailConfig.getObject().getItemDefinition().getTypeName().getLocalPart() + ".details"));

    Form form = new Form<>("form");

    mailConfigType = new RealValueFromSingleValuePropertyWrapperModel<MailConfigurationType>(mailConfig)
            .getObject();/*from w w w  . ja va2  s.  com*/

    if (mailConfigType == null) {
        mailConfigType = new MailConfigurationType();
        ((PrismPropertyValue<MailConfigurationType>) mailConfig.getObject().getValues().get(0).getValue())
                .setValue(mailConfigType);
    }

    add(new TextFormGroup(ID_DEFAULT_FROM, new PropertyModel<String>(mailConfigType, "defaultFrom"),
            createStringResource(
                    mailConfig.getObject().getItemDefinition().getTypeName().getLocalPart() + ".defaultFrom"),
            "", getInputCssClass(), false, true));

    add(new TextFormGroup(ID_REDIRECT_TO_FILE, new PropertyModel<String>(mailConfigType, "redirectToFile"),
            createStringResource(mailConfig.getObject().getItemDefinition().getTypeName().getLocalPart()
                    + ".redirectToFile"),
            "", getInputCssClass(), false, true));

    add(new TextFormGroup(ID_LOG_TO_FILE, new PropertyModel<String>(mailConfigType, "logToFile"),
            createStringResource(
                    mailConfig.getObject().getItemDefinition().getTypeName().getLocalPart() + ".logToFile"),
            "", getInputCssClass(), false, true));

    add(new TriStateFormGroup(ID_DEBUG, new PropertyModel<Boolean>(mailConfigType, "debug"),
            createStringResource(
                    mailConfig.getObject().getItemDefinition().getTypeName().getLocalPart() + ".debug"),
            "", getInputCssClass(), false, true));

    add(createHeader(ID_MAIL_SERVER_CONFIG_HEADER,
            MailServerConfigurationType.COMPLEX_TYPE.getLocalPart() + ".details"));

    add(initServersTable());

    add(createHeader(ID_FILE_CONFIG_HEADER, FileConfigurationType.COMPLEX_TYPE.getLocalPart() + ".details"));

    PropertyWrapperFromContainerWrapperModel<FileConfigurationType, NotificationConfigurationType> fileConfig = new PropertyWrapperFromContainerWrapperModel<FileConfigurationType, NotificationConfigurationType>(
            getModel().getObject(), NotificationConfigurationType.F_FILE);

    WebMarkupContainer files = new WebMarkupContainer(ID_FILE_CONFIG);
    files.setOutputMarkupId(true);
    add(files);

    ListView<ValueWrapper<FileConfigurationType>> values = new ListView<ValueWrapper<FileConfigurationType>>(
            "values", new PropertyModel<>(fileConfig, "values")) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<ValueWrapper<FileConfigurationType>> item) {

            FileConfigurationType fileConfigType = item.getModelObject().getValue().getRealValue();

            item.add(createHeader(ID_VALUE_HEADER,
                    fileConfigType == null || fileConfigType.getName() == null
                            || fileConfigType.getName().isEmpty()
                                    ? (FileConfigurationType.COMPLEX_TYPE.getLocalPart() + ".details")
                                    : fileConfigType.getName()));

            AjaxLink removeButton = new AjaxLink(ID_REMOVE_BUTTON) {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    ((PrismPropertyValue<FileConfigurationType>) item.getModelObject().getValue())
                            .setValue(null);
                    item.getParent().remove(item.getId());
                    target.add(files);
                }
            };
            item.add(removeButton);

            TextFormGroup name = new TextFormGroup(ID_FILE_NAME,
                    fileConfigType != null ? new PropertyModel<String>(fileConfigType, "name") : Model.of(""),
                    createStringResource(fileConfigType == null ? ""
                            : (fileConfigType.COMPLEX_TYPE.getLocalPart() + ".name")),
                    "", getInputCssClass(), false, true);
            name.getField().add(new OnChangeAjaxBehavior() {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    ((FileConfigurationType) item.getModelObject().getValue().getRealValue())
                            .setName(name.getModelObject());
                }
            });
            item.add(name);

            TextFormGroup file = new TextFormGroup(ID_FILE_PATH,
                    fileConfigType != null ? new PropertyModel<String>(fileConfigType, "file") : Model.of(""),
                    createStringResource(fileConfigType == null ? ""
                            : (fileConfigType.COMPLEX_TYPE.getLocalPart() + ".file")),
                    "", getInputCssClass(), false, true);
            file.getField().add(new OnChangeAjaxBehavior() {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    ((FileConfigurationType) item.getModelObject().getValue().getRealValue())
                            .setFile(file.getModelObject());
                }
            });
            item.add(file);

            item.add(new VisibleEnableBehaviour() {

                @Override
                public boolean isVisible() {
                    return fileConfigType != null;
                }
            });
        }
    };
    values.add(new AttributeModifier("class", "col-md-6"));
    values.setReuseItems(true);
    files.add(values);

    AjaxLink addButton = new AjaxLink(ID_ADD_BUTTON) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            ValueWrapper<FileConfigurationType> newValue = fileConfig.getObject().createAddedValue();
            ((PrismPropertyValue<FileConfigurationType>) newValue.getValue())
                    .setValue(new FileConfigurationType());
            fileConfig.getObject().getValues().add(newValue);
            target.add(files);
        }
    };
    add(addButton);

}

From source file:com.evolveum.midpoint.gui.impl.page.admin.configuration.component.NotificationConfigTabPanel.java

License:Apache License

private void deleteItemPerformed(AjaxRequestTarget target, List<MailServerConfiguration> toDelete) {
    if (toDelete == null) {
        return;/*from   w  w w. ja  v  a2s .c om*/
    }

    RealValueOfSingleValuePropertyFromSingleValueContainerWrapperModel<MailConfigurationType, NotificationConfigurationType> mailConfigType = new RealValueOfSingleValuePropertyFromSingleValueContainerWrapperModel<>(
            getModel(), NotificationConfigurationType.F_MAIL);
    List<MailServerConfigurationType> servers = mailConfigType.getObject().getServer();

    toDelete.forEach(value -> {
        servers.remove(value.getValue());
    });
    target.add(this.addOrReplace(initServersTable()));
    reloadSavePreviewButtons(target);
}

From source file:com.evolveum.midpoint.gui.impl.page.admin.configuration.component.NotificationConfigTabPanel.java

License:Apache License

private void mailServerEditPerformed(AjaxRequestTarget target, IModel<MailServerConfiguration> rowModel,
        List<MailServerConfiguration> listItems) {

    if (rowModel != null) {
        MailServerConfiguration server = rowModel.getObject();
        server.setEditing(true);//  ww w .jav  a 2s. co  m
        server.setSelected(true);
    } else {
        for (MailServerConfiguration server : listItems) {
            server.setSelected(true);
            server.setEditing(true);
        }
    }
    target.add(getMailServersTable());
}

From source file:com.evolveum.midpoint.web.component.AjaxTabbedPanel.java

License:Apache License

@Override
protected WebMarkupContainer newLink(final String linkId, final int index) {
    return new AjaxFallbackLink<Void>(linkId) {

        private static final long serialVersionUID = 1L;

        @Override/*w ww .  ja  v a  2s  .c  om*/
        public void onClick(final AjaxRequestTarget target) {
            setSelectedTab(index);
            if (target != null) {
                target.add(AjaxTabbedPanel.this);
            }
            onAjaxUpdate(target);
        }

    };
}

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

License:Apache License

protected void deleteAssignmentPerformed(AjaxRequestTarget target, AssignmentEditorDto dto) {
    List<AssignmentEditorDto> selected = getSelectedAssignments();

    if (dto == null && selected.isEmpty()) {
        warn(getNoAssignmentsSelectedMessage());
        target.add(getPageBase().getFeedbackPanel());
        return;//from  w  w w  . ja va 2 s. c o m
    }

    getPageBase().showMainPopup(getDeleteAssignmentPopupContent(dto), target);
}

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

License:Apache License

protected void deleteAssignmentConfirmedPerformed(AjaxRequestTarget target,
        List<AssignmentEditorDto> toDelete) {
    List<AssignmentEditorDto> assignments = getAssignmentModel().getObject();

    for (AssignmentEditorDto assignment : toDelete) {
        if (UserDtoStatus.ADD.equals(assignment.getStatus())) {
            assignments.remove(assignment);
        } else {//  w  w w .j  a  v  a2s. c  o m
            assignment.setStatus(UserDtoStatus.DELETE);
            assignment.setSelected(false);
        }
    }
    target.add(getPageBase().getFeedbackPanel());
    reloadMainAssignmentsComponent(target);
}

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

License:Apache License

private void addPerformed(AjaxRequestTarget target) {
    ACValueConstructionDto dto = getModel().getObject();
    ACAttributeDto attributeDto = dto.getAttribute();
    attributeDto.getValues().add(new ACValueConstructionDto(attributeDto, null));

    target.add(findParent(ACAttributePanel.class).getParent());

    //todo implement add to account construction
}

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

License:Apache License

private void removePerformed(AjaxRequestTarget target) {
    ACValueConstructionDto dto = getModel().getObject();
    ACAttributeDto attributeDto = dto.getAttribute();
    attributeDto.getValues().remove(dto);
    //todo implement remove from acctount construction

    target.add(findParent(ACAttributePanel.class).getParent());
}

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

License:Apache License

private void addSelectedAssignmentsPerformed(AjaxRequestTarget target, List<ObjectType> assignmentsList,
        QName relation) {/* w  ww.ja v  a 2s  .c  o  m*/
    if (assignmentsList == null || assignmentsList.isEmpty()) {
        warn(getPageBase().getString("AssignmentTablePanel.message.noAssignmentSelected"));
        target.add(getPageBase().getFeedbackPanel());
        return;
    }
    for (ObjectType object : assignmentsList) {
        AssignmentEditorDto dto = createAssignmentFromSelectedObjects(object, relation);
        getAssignmentModel().getObject().add(0, dto);
    }
    relationModel.setObject(RelationTypes.getRelationType(relation));
    initPaging();
    addOrReplaceAssignmentsTable(getAssignmentsContainer());
    reloadMainFormButtons(target);
    target.add(getAssignmentsContainer());
}