Example usage for org.apache.wicket.markup.html.list ListView setOutputMarkupId

List of usage examples for org.apache.wicket.markup.html.list ListView setOutputMarkupId

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.list ListView setOutputMarkupId.

Prototype

public final Component setOutputMarkupId(final boolean output) 

Source Link

Document

Sets whether or not component will output id attribute into the markup.

Usage

From source file:com.evolveum.midpoint.web.component.prism.ContainerValuePanel.java

License:Apache License

private <IW extends ItemWrapper> void addOrReplaceContainers(IModel<ContainerValueWrapper<C>> model,
        final Form form, ItemVisibilityHandler isPanalVisible, boolean isToBeReplaced) {
    ListView<IW> containers = new ListView<IW>("containers", new PropertyModel<>(model, "properties")) {
        private static final long serialVersionUID = 1L;

        @Override/*from www  .  j a v a  2s . c o m*/
        protected void populateItem(final ListItem<IW> item) {
            item.setOutputMarkupId(true);
            if (item.getModel().getObject() instanceof ContainerWrapper) {
                PrismContainerPanel<C> containerPanel = new PrismContainerPanel<C>("container",
                        (IModel<ContainerWrapper<C>>) item.getModel(), true, form, isPanalVisible, pageBase,
                        false);
                containerPanel.setOutputMarkupId(true);
                item.add(containerPanel);
                item.add(new VisibleEnableBehaviour() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public boolean isVisible() {
                        if (!model.getObject().isExpanded()
                                && !model.getObject().getContainer().isShowOnTopLevel()) {
                            return false;
                        }

                        if (((ContainerWrapper) item.getModelObject() != null
                                && ((ContainerWrapper) item.getModelObject()).getItemDefinition() != null
                                && ((ContainerWrapper) item.getModelObject()).getItemDefinition()
                                        .getTypeName() != null
                                && ((ContainerWrapper) item.getModelObject()).getItemDefinition().getTypeName()
                                        .equals(MetadataType.COMPLEX_TYPE))
                                && (((ContainerWrapper) item.getModelObject()).getValues() != null
                                        && ((ContainerWrapper) item.getModelObject()).getValues().get(0) != null
                                        && !((ContainerWrapper<MetadataType>) item.getModelObject()).getValues()
                                                .get(0).isVisible())) {
                            return false;
                        }

                        if (model.getObject().containsMultipleMultivalueContainer(isPanalVisible)
                                && item.getModelObject().getItemDefinition().isMultiValue()
                                && CollectionUtils.isEmpty(item.getModelObject().getValues())) {
                            return false;
                        }

                        return containerPanel.isPanelVisible(isPanalVisible,
                                (IModel<ContainerWrapper<C>>) item.getModel());

                    }
                });
                if (!((ContainerWrapper) item.getModelObject() != null
                        && ((ContainerWrapper) item.getModelObject()).getItemDefinition() != null
                        && ((ContainerWrapper) item.getModelObject()).getItemDefinition().getTypeName() != null
                        && ((ContainerWrapper) item.getModelObject()).getItemDefinition().getTypeName()
                                .equals(MetadataType.COMPLEX_TYPE))) {
                    item.add(AttributeModifier.append("class", "container-wrapper"));
                }
                return;
            }
            WebMarkupContainer container = new WebMarkupContainer("container");
            item.add(new VisibleEnableBehaviour() {
                @Override
                public boolean isVisible() {
                    return false;
                }
            });
            item.add(container);
        }
    };
    containers.setReuseItems(true);
    containers.setOutputMarkupId(true);
    if (isToBeReplaced) {
        replace(containers);
    } else {
        add(containers);
    }
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.modal.LimitationsEditorDialog.java

License:Apache License

public void initLayout(WebMarkupContainer content) {
    Form form = new Form(ID_MAIN_FORM);
    form.setOutputMarkupId(true);/*from w w  w. j a v a  2s.c  o m*/
    content.add(form);

    ListView repeater = new ListView<PropertyLimitationsTypeDto>(ID_REPEATER, model) {

        @Override
        protected void populateItem(final ListItem<PropertyLimitationsTypeDto> item) {
            WebMarkupContainer linkContainer = new WebMarkupContainer(ID_LIMITATIONS_LINK);
            linkContainer.setOutputMarkupId(true);
            linkContainer.add(new AttributeModifier("href", createCollapseItemId(item, true)));
            item.add(linkContainer);

            Label linkLabel = new Label(ID_LIMITATIONS_LABEL, createLimitationsLabelModel(item));
            linkContainer.add(linkLabel);

            AjaxLink delete = new AjaxLink(ID_LIMITATION_DELETE) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteLimitationPerformed(target, item);
                }
            };
            linkContainer.add(delete);

            WebMarkupContainer limitationBody = new WebMarkupContainer(ID_BODY);
            limitationBody.setOutputMarkupId(true);
            limitationBody.setMarkupId(createCollapseItemId(item, false).getObject());
            if (changeState != ChangeState.SKIP) {
                limitationBody.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

                    @Override
                    public String getObject() {
                        if (changeState == ChangeState.FIRST && item.getIndex() == 0) {
                            return "panel-collapse collapse in";
                        } else if (changeState == ChangeState.LAST
                                && item.getIndex() == (getModelObject().size() - 1)) {
                            return "panel-collapse collapse in";
                        } else {
                            return "panel-collapse collapse";
                        }
                    }
                }));
            }
            item.add(limitationBody);
            initLimitationBody(limitationBody, item);

        }
    };
    repeater.setOutputMarkupId(true);
    form.add(repeater);

    initButtons(form);
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.ResourceDependencyEditor.java

License:Apache License

@Override
protected void initLayout() {
    WebMarkupContainer container = new WebMarkupContainer(ID_CONTAINER);
    container.setOutputMarkupId(true);//w  w w  . jav a 2s.  co m
    add(container);

    ListView repeater = new ListView<ResourceObjectTypeDependencyType>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<ResourceObjectTypeDependencyType> item) {
            WebMarkupContainer linkContainer = new WebMarkupContainer(ID_DEPENDENCY_LINK);
            linkContainer.setOutputMarkupId(true);
            linkContainer.add(new AttributeModifier("href", createCollapseItemId(item, true)));
            item.add(linkContainer);

            Label linkLabel = new Label(ID_DEPENDENCY_LINK_NAME, createDependencyLabelModel(item));
            linkContainer.add(linkLabel);

            AjaxLink delete = new AjaxLink(ID_DELETE_BUTTON) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteDependencyPerformed(target, item);
                }
            };
            linkContainer.add(delete);

            WebMarkupContainer dependencyBody = new WebMarkupContainer(ID_DEPENDENCY_BODY);
            dependencyBody.setOutputMarkupId(true);
            dependencyBody.setMarkupId(createCollapseItemId(item, false).getObject());

            if (changeState != ChangeState.SKIP) {
                dependencyBody.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

                    @Override
                    public String getObject() {
                        if (changeState == ChangeState.FIRST && item.getIndex() == 0) {
                            return "panel-collapse collapse in";
                        } else if (changeState == ChangeState.LAST
                                && item.getIndex() == (getModelObject().size() - 1)) {
                            return "panel-collapse collapse in";
                        } else {
                            return "panel-collapse collapse";
                        }
                    }
                }));
            }

            item.add(dependencyBody);

            TextField order = new TextField<>(ID_ORDER,
                    new PropertyModel<Integer>(item.getModelObject(), "order"));
            order.add(prepareAjaxOnComponentTagUpdateBehavior());
            dependencyBody.add(order);

            DropDownChoice strictness = new DropDownChoice<>(ID_STRICTNESS,
                    new PropertyModel<ResourceObjectTypeDependencyStrictnessType>(item.getModelObject(),
                            "strictness"),
                    WebMiscUtil.createReadonlyModelFromEnum(ResourceObjectTypeDependencyStrictnessType.class),
                    new EnumChoiceRenderer<ResourceObjectTypeDependencyStrictnessType>(this));
            strictness.add(prepareAjaxOnComponentTagUpdateBehavior());
            dependencyBody.add(strictness);

            DropDownChoice kind = new DropDownChoice<>(ID_KIND,
                    new PropertyModel<ShadowKindType>(item.getModelObject(), "kind"),
                    WebMiscUtil.createReadonlyModelFromEnum(ShadowKindType.class),
                    new EnumChoiceRenderer<ShadowKindType>(this));
            kind.add(prepareAjaxOnComponentTagUpdateBehavior());
            dependencyBody.add(kind);

            TextField intent = new TextField<>(ID_INTENT,
                    new PropertyModel<String>(item.getModelObject(), "intent"));
            intent.add(prepareAjaxOnComponentTagUpdateBehavior());
            dependencyBody.add(intent);

            DropDownChoice resource = new DropDownChoice<>(ID_REF,
                    new PropertyModel<ObjectReferenceType>(item.getModelObject(), "resourceRef"),
                    new AbstractReadOnlyModel<List<ObjectReferenceType>>() {

                        @Override
                        public List<ObjectReferenceType> getObject() {
                            return createResourceList();
                        }
                    }, new IChoiceRenderer<ObjectReferenceType>() {

                        @Override
                        public Object getDisplayValue(ObjectReferenceType object) {
                            return createResourceReadLabel(object);
                        }

                        @Override
                        public String getIdValue(ObjectReferenceType object, int index) {
                            return Integer.toString(index);
                        }
                    });
            resource.add(prepareAjaxOnComponentTagUpdateBehavior());
            dependencyBody.add(resource);

            Label orderTooltip = new Label(ID_T_ORDER);
            orderTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(orderTooltip);

            Label strictnessTooltip = new Label(ID_T_STRICTNESS);
            strictnessTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(strictnessTooltip);

            Label kindTooltip = new Label(ID_T_KIND);
            kindTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(kindTooltip);

            Label intentTooltip = new Label(ID_T_INTENT);
            intentTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(intentTooltip);

            Label resourceRefTooltip = new Label(ID_T_RESOURCE_REF);
            resourceRefTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(resourceRefTooltip);
        }
    };
    repeater.setOutputMarkupId(true);
    container.add(repeater);

    AjaxLink add = new AjaxLink(ID_ADD_BUTTON) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addDependencyPerformed(target);
        }
    };
    add(add);
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.ResourceProtectedEditor.java

License:Apache License

@Override
protected void initLayout() {
    WebMarkupContainer container = new WebMarkupContainer(ID_CONTAINER);
    container.setOutputMarkupId(true);//  w w  w.  j a  v  a  2  s .  c o  m
    add(container);

    ListView repeater = new ListView<ResourceObjectPatternType>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<ResourceObjectPatternType> item) {
            WebMarkupContainer linkCont = new WebMarkupContainer(ID_ACCOUNT_LINK);
            linkCont.setOutputMarkupId(true);
            linkCont.add(new AttributeModifier("href", createCollapseItemId(item, true)));
            item.add(linkCont);

            Label accountLabel = new Label(ID_ACCOUNT_NAME, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    StringBuilder sb = new StringBuilder();
                    ResourceObjectPatternType account = item.getModelObject();
                    sb.append("#").append(item.getIndex() + 1).append(" - ");

                    if (account.getUid() != null) {
                        sb.append(account.getUid()).append(":");
                    }

                    if (account.getName() != null) {
                        sb.append(account.getName());
                    }

                    return sb.toString();
                }
            });
            linkCont.add(accountLabel);

            AjaxLink delete = new AjaxLink(ID_BUTTON_DELETE) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteDependencyPerformed(target, item);
                }
            };
            linkCont.add(delete);

            WebMarkupContainer accountBody = new WebMarkupContainer(ID_ACCOUNT_BODY);
            accountBody.setOutputMarkupId(true);
            accountBody.setMarkupId(createCollapseItemId(item, false).getObject());

            if (changeState != ChangeState.SKIP) {
                accountBody.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

                    @Override
                    public String getObject() {
                        if (changeState == ChangeState.FIRST && item.getIndex() == 0) {
                            return "panel-collapse collapse in";
                        } else if (changeState == ChangeState.LAST
                                && item.getIndex() == (getModelObject().size() - 1)) {
                            return "panel-collapse collapse in";
                        } else {
                            return "panel-collapse collapse";
                        }
                    }
                }));
            }

            item.add(accountBody);

            //TODO - maybe add some validator and auto-complete functionality?
            TextField name = new TextField<>(ID_NAME, new PropertyModel<String>(item.getModelObject(), "name"));
            name.add(prepareAjaxOnComponentTagUpdateBehavior());
            accountBody.add(name);

            //TODO - maybe add some validator and auto-complete functionality?
            TextField uid = new TextField<>(ID_UID, new PropertyModel<String>(item.getModelObject(), "uid"));
            uid.add(prepareAjaxOnComponentTagUpdateBehavior());
            accountBody.add(uid);

            SearchFilterPanel searchFilterPanel = new SearchFilterPanel<>(ID_FILTER_EDITOR,
                    new PropertyModel<SearchFilterType>(item.getModelObject(), "filter"));
            accountBody.add(searchFilterPanel);

            Label nameTooltip = new Label(ID_T_NAME);
            nameTooltip.add(new InfoTooltipBehavior());
            accountBody.add(nameTooltip);

            Label uidTooltip = new Label(ID_T_UID);
            uidTooltip.add(new InfoTooltipBehavior());
            accountBody.add(uidTooltip);

            Label filterTooltip = new Label(ID_T_FILTER);
            filterTooltip.add(new InfoTooltipBehavior());
            accountBody.add(filterTooltip);
        }
    };
    repeater.setOutputMarkupId(true);
    container.add(repeater);

    AjaxLink add = new AjaxLink(ID_BUTTON_ADD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addProtectedAccountPerformed(target);
        }
    };
    add(add);
}

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

License:Apache License

private void initAssignments(final WebMarkupContainer assignments) {
    InlineMenu accountMenu = new InlineMenu(ID_ASSIGNMENT_MENU,
            new Model((Serializable) createAssignmentsMenu()));
    assignments.add(accountMenu);//from   w  ww .  ja  v  a  2  s.  c  o  m

    final ListView<AssignmentEditorDto> assignmentList = new ListView<AssignmentEditorDto>(ID_ASSIGNMENT_LIST,
            assignmentsModel) {

        @Override
        protected void populateItem(final ListItem<AssignmentEditorDto> item) {
            AssignmentEditorPanel assignmentEditor = new AssignmentEditorPanel(ID_ASSIGNMENT_EDITOR,
                    item.getModel());
            item.add(assignmentEditor);
        }
    };
    assignmentList.setOutputMarkupId(true);
    assignments.add(assignmentList);

    AjaxCheckBox assignmentCheckAll = new AjaxCheckBox(ID_ASSIGNMENT_CHECK_ALL, new Model()) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            for (AssignmentEditorDto item : assignmentList.getModelObject()) {
                item.setSelected(this.getModelObject());
            }

            target.add(assignments);
        }
    };
    assignments.add(assignmentCheckAll);
}

From source file:com.evolveum.midpoint.web.page.self.UserViewTabPanel.java

License:Apache License

private void initRelationsPanel(WebMarkupContainer sourceUserPanel) {
    ListView relationsPanel = new ListView<QName>(ID_SOURCE_USER_RELATIONS,
            new LoadableModel<List<QName>>(false) {
                @Override//w  w  w .ja va 2s.c o  m
                protected List<QName> load() {
                    return getRelationsList();
                }
            }) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<QName> item) {
            item.add(createRelationLink(ID_RELATION_LINK, item.getModel()));
        }
    };
    relationsPanel.setOutputMarkupId(true);

    sourceUserPanel.add(relationsPanel);
}

From source file:com.genericconf.bbbgateway.web.panels.AttendeeAndWaitingListPanel.java

License:Apache License

private Component createAttendeeList(final String id, IModel<? extends List<? extends Attendee>> listmodel) {
    ListView<Attendee> lv = new PropertyListView<Attendee>(id, listmodel) {
        private static final long serialVersionUID = 1L;

        @Override/*w  w w .  ja  v a 2  s  .c  o m*/
        protected void populateItem(final ListItem<Attendee> item) {
            item.setOutputMarkupId(true);
            item.add(new Label("name"));
            item.add(new Label("userID") {
                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    return getDefaultModelObject() != null;
                }
            });
            item.add(new Label("role"));

            final WebMarkupContainer admin = new WebMarkupContainer("admin") {
                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    return "waiters".equals(id) && allowAdminControls;
                }
            };
            item.add(admin.setOutputMarkupId(true));
            admin.add(new AjaxLink<Void>("allowToJoin") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    item.getModelObject().setAllowedToJoin(true);
                    target.addComponent(admin);
                }

                @Override
                protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
                    final Attendee att = item.getModelObject();
                    String text = att.isAllowedToJoin() ? "already allowed in" : "allow to join";
                    replaceComponentTagBody(markupStream, openTag, text);
                }

                @Override
                public boolean isEnabled() {
                    return item.getModelObject().isAllowedToJoin() == false;
                }

            });
            admin.add(new AjaxLink<Void>("swapRole") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    Role newRole = Role.VIEWER.equals(item.getModelObject().getRole()) ? Role.MODERATOR
                            : Role.VIEWER;
                    item.getModelObject().setRole(newRole);
                    target.addComponent(AttendeeAndWaitingListPanel.this);
                }

                @Override
                protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
                    final Attendee att = item.getModelObject();
                    String text = Role.VIEWER.equals(att.getRole()) ? "make moderator" : "make viewer";
                    replaceComponentTagBody(markupStream, openTag, text);
                }

            });
        }
    };
    lv.setOutputMarkupId(true);
    return lv;
}

From source file:com.hubeleon.wicket.clearing.ConfirmCDRs.java

private void populateScreen() {
    LOG.entering(CLASS_NAME, "populateScreen");

    List<CDRInfoModel> cdrInfoArray = new ArrayList();

    LOG.warning("cdrInfoList result before = " + cdrInfoArray.size());
    cdrInfoArray.addAll(cdrInfoBO.findForReview());
    LOG.warning("cdrInfoList result after = " + cdrInfoArray.size());

    final WebMarkupContainer divList = new WebMarkupContainer("ochConfirmCDRsTable");

    final ListView list = new ListView<CDRInfoModel>("listview", cdrInfoArray) {

        protected void populateItem(final ListItem<CDRInfoModel> listItem) {

            CDRInfoModel cdr = (CDRInfoModel) listItem.getModelObject();

            listItem.add(new Label("cdrId", (cdr.getCdrId() != null ? cdr.getCdrId() : "")));
            listItem.add(new Label("evseId", (cdr.getEvseId() != null ? cdr.getEvseId() : "")));

            listItem.add(new Label("startDateTime",
                    (cdr.getStartDateTime().toString() != null ? cdr.getStartDateTime().toString() : "")));
            listItem.add(new Label("endDateTime",
                    (cdr.getEndDateTime().toString() != null ? cdr.getEndDateTime().toString() : "")));
            listItem.add(new Label("duration", (cdr.getDuration() != null ? cdr.getDuration() : "")));

            listItem.add(new Label("instance", cdr.getInstance() != null ? cdr.getInstance() : ""));
            listItem.add(new Label("tokenType", cdr.getTokenType() != null ? cdr.getTokenType() : ""));
            listItem.add(new Label("tokenSubType", cdr.getTokenSubType() != null ? cdr.getTokenSubType() : ""));
            listItem.add(new Label("contractId", cdr.getContractId() != null ? cdr.getContractId() : ""));
            listItem.add(new Label("liveAuthId", cdr.getLiveAuthId() != null ? cdr.getLiveAuthId() : ""));

        }//from ww w  .  ja  v  a2  s .  c om
    };
    list.setOutputMarkupId(true);
    list.setOutputMarkupPlaceholderTag(true);
    divList.setOutputMarkupId(true);
    divList.setOutputMarkupPlaceholderTag(true);
    divList.add(list);
    add(divList);

    LOG.exiting(CLASS_NAME, "populateScreen");
}

From source file:com.hubeleon.wicketlist.HomePage.java

License:Open Source License

public HomePage() {

    final WebMarkupContainer divList = new WebMarkupContainer("ochConfirmCDRsTable");
    divList.setOutputMarkupId(true);// w w w . ja v a 2s  .  c o  m
    divList.setOutputMarkupPlaceholderTag(true);
    setVersioned(false);

    final List<CDRInfo> cdrInfoArray = new ArrayList();
    if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Development) {
        try (Closeable closeable = ObjectifyService.begin()) {
            System.out.println(" #######  get all cdr list");
            List<CDRInfo> ths = ofy().load().type(CDRInfo.class).list();
            cdrInfoArray.addAll(ths);
        }
    }

    final ListView list = new ListView<CDRInfo>("listview", cdrInfoArray) {

        protected void populateItem(final ListItem<CDRInfo> listItem) {

            final CDRInfo cdr = (CDRInfo) listItem.getModelObject();

            System.out.println("Populating List for  " + cdr.getCdrId() + " with status  "
                    + cdr.getCdrStatusType() + " retrieved from database ");

            listItem.setOutputMarkupId(true);
            listItem.setOutputMarkupPlaceholderTag(true);

            listItem.add(new Label("cdr", (cdr.getCdrId() != null ? cdr.getCdrId() : "")));
            listItem.add(new Label("evseId", (cdr.getEvseId() != null ? cdr.getEvseId() : "")));
            final Label lblStatus = new Label("status", new PropertyModel<String>(cdr, "cdrStatusType"));
            lblStatus.setOutputMarkupId(true);
            lblStatus.setOutputMarkupPlaceholderTag(true);

            listItem.add(lblStatus);

            listItem.add(new Label("startDateTime",
                    (cdr.getStartDateTime().toString() != null ? cdr.getStartDateTime().toString() : "")));
            listItem.add(new Label("endDateTime",
                    (cdr.getEndDateTime().toString() != null ? cdr.getEndDateTime().toString() : "")));
            listItem.add(new Label("duration", (cdr.getDuration() != null ? cdr.getDuration() : "")));

            listItem.add(new Label("instance", cdr.getInstance() != null ? cdr.getInstance() : ""));
            listItem.add(new Label("tokenType", cdr.getTokenType() != null ? cdr.getTokenType() : ""));
            listItem.add(new Label("tokenSubType", cdr.getTokenSubType() != null ? cdr.getTokenSubType() : ""));
            listItem.add(new Label("contractId", cdr.getContractId() != null ? cdr.getContractId() : ""));
            listItem.add(new Label("liveAuthId", cdr.getLiveAuthId() != null ? cdr.getLiveAuthId() : ""));

            final Form<CDRInfo> form = new Form<CDRInfo>("myForm", new Model(cdr)) {

                /**
                 * 
                 */
                private static final long serialVersionUID = 1L;

                protected void onSubmit(AjaxRequestTarget target, Form<CDRInfo> form) {
                    CDRInfo c = (CDRInfo) this.getModelObject();
                    System.err.println("######## STATUS:" + c.getCdrStatusType());
                    //this.setResponsePage(new MovieDisplayPage(movie));
                };
            };

            form.setOutputMarkupId(true);
            form.setOutputMarkupPlaceholderTag(true);

            final HiddenField currentState = new HiddenField("currentState",
                    new PropertyModel<String>(cdr, "cdrStatusType"));
            currentState.setOutputMarkupId(true);
            form.add(currentState);

            final HiddenField hcdr = new HiddenField("cdrId", new PropertyModel<String>(cdr, "cdrId"));
            hcdr.setOutputMarkupId(true);
            form.add(hcdr);

            final Model<String> btnStyle = new Model<String>("btn-warning");

            AjaxButton btn = new AjaxButton("stateAcceptButton",
                    new PropertyModel<String>(cdr, "cdrStatusType"), form) {

                protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
                    super.updateAjaxAttributes(attributes);
                    attributes.setWicketAjaxResponse(false);
                }

                protected void onClick(AjaxRequestTarget target, Form form) {

                }

                protected void onSubmit(AjaxRequestTarget target, Form form) {
                    System.out.println(" ####### " + hcdr.getDefaultModelObjectAsString() + " - "
                            + currentState.getDefaultModelObjectAsString());
                    if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Development) {
                        try (Closeable closeable = ObjectifyService.begin()) {
                            CDRInfo result = (CDRInfo) ofy().load().type(CDRInfo.class)
                                    .id(hcdr.getDefaultModelObjectAsString()).now();
                            result.setCdrStatusType("Accepted");
                            System.out.println("Persisting to database " + result.getCdrId() + " - "
                                    + result.getCdrStatusType() + " ::: " + target.getLastFocusedElementId());
                            ofy().save().entity(result).now();
                            setReuseItems(true);
                            addStateChange();
                            modelChanging();
                            // Remove item and invalidate listView
                            List<CDRInfo> currentList = (List<CDRInfo>) getList();
                            for (CDRInfo i : currentList) {
                                if (i.getCdrId().equalsIgnoreCase(result.getCdrId())) {
                                    System.out.println("#### Found entry and updating state to : "
                                            + result.getCdrStatusType());
                                    currentList.remove(i);
                                    i.setCdrStatusType(result.getCdrStatusType());
                                    System.out.println("#### set list " + currentList);
                                    setList(currentList);
                                    target.appendJavaScript(" document.getElementById('" + lblStatus.getId()
                                            + "').value='" + result.getCdrStatusType() + "';");
                                    System.out.println("#### model changed ");
                                    modelChanged();
                                    System.out.println("#### remove all ");
                                    removeAll();
                                    break;
                                } else {
                                    System.out.println("#### NOT FOUND as charge record " + i.getCdrId()
                                            + ", while we are looking for " + result.getCdrId());
                                }
                            }
                        }
                    }
                    target.add(lblStatus);
                    setResponsePage(HomePage.class);
                }

            };

            btn.add(AttributeModifier.append("class", btnStyle));

            btn.add(new AttributeModifier("cdrStatusType", cdr) {
                protected String newValue(final String currentValue, final String replacementValue) {
                    System.out
                            .println("######## New Value 1:" + replacementValue + " old value " + currentValue);
                    return currentValue + replacementValue;
                }

            });

            form.add(btn);

            AjaxButton btnReject = new AjaxButton("stateRejectButton",
                    new PropertyModel<String>(cdr, "cdrStatusType"), form) {

                protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
                    super.updateAjaxAttributes(attributes);
                    attributes.setWicketAjaxResponse(false);
                    System.out.println("########updateAjaxAttributes");
                }

                protected void onSubmit(AjaxRequestTarget target, Form form) {
                    System.out.println(" ####### " + hcdr.getDefaultModelObjectAsString() + " - "
                            + currentState.getDefaultModelObjectAsString());
                    if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Development) {
                        try (Closeable closeable = ObjectifyService.begin()) {
                            CDRInfo result = (CDRInfo) ofy().load().type(CDRInfo.class)
                                    .id(hcdr.getDefaultModelObjectAsString()).now();
                            result.setCdrStatusType("Rejected");
                            System.out.println("Persisting to database " + result.getCdrId() + " - "
                                    + result.getCdrStatusType() + " ::: " + target.getLastFocusedElementId());
                            ofy().save().entity(result).now();
                            getList().remove(result);
                        }
                    }
                    target.add(divList);
                }

            };

            btnReject.add(AttributeModifier.append("class", btnStyle));

            btnReject.add(new AttributeModifier("cdrStatusType", cdr) {
                protected String newValue(final String currentValue, final String replacementValue) {
                    System.out.println("######## New Value Reject Button:" + replacementValue + " old value "
                            + currentValue);
                    return currentValue + replacementValue;
                }

            });

            form.add(btnReject);
            listItem.add(form);

        }
    };
    list.setOutputMarkupId(true);
    list.setOutputMarkupPlaceholderTag(true);
    divList.setOutputMarkupId(true);
    divList.setOutputMarkupPlaceholderTag(true);
    divList.add(list);

    add(divList);

}

From source file:de.alpharogroup.wicket.components.radio.RadioGroupPanel.java

License:Apache License

/**
 * Factory method for create the new {@link ListView} for the {@link Radio} objects. This method
 * is invoked in the constructor from the derived classes and can be overridden so users can
 * provide their own version of a new {@link ListView} for the {@link Radio} objects.
 *
 * @param id//www.  ja  v a 2s  . c  o  m
 *            the id
 * @param model
 *            the model
 * @return the new {@link ListView} for the {@link Radio} objects.
 */
protected ListView<T> newRadioListView(final String id, final IModel<RadioGroupModelBean<T>> model) {
    final ListView<T> radioListView = new ListView<T>("choice", model.getObject().getRadios()) {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        /**
         * {@inheritDoc}
         */
        @Override
        protected void populateItem(final ListItem<T> item) {
            final Radio<T> radio = new Radio<>("radio", item.getModel(), RadioGroupPanel.this.group);
            radio.setOutputMarkupId(true);
            item.add(radio);
            item.add(RadioGroupPanel.this.newLabel("label", radio.getMarkupId(), item.getModel()));
        }
    };
    radioListView.setOutputMarkupId(true);
    return radioListView;
}