List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink AjaxLink
public AjaxLink(final String id)
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();// w w w. j av a 2 s . c o m 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.web.component.assignment.ACAttributeValuePanel.java
License:Apache License
private void initPanel(Form form) { ACValueConstructionDto dto = getModel().getObject(); PrismPropertyDefinition definition = dto.getAttribute().getDefinition(); boolean required = definition.getMinOccurs() > 0; InputPanel input = createTypedInputComponent(ID_INPUT, definition); for (FormComponent comp : input.getFormComponents()) { comp.setLabel(new PropertyModel(dto.getAttribute(), ACAttributeDto.F_NAME)); comp.setRequired(required);/* w w w . j ava2 s .c o m*/ comp.add(new AjaxFormComponentUpdatingBehavior("onBlur") { @Override protected void onUpdate(AjaxRequestTarget target) { } }); } add(input); AjaxLink addLink = new AjaxLink(ID_ADD) { @Override public void onClick(AjaxRequestTarget target) { addPerformed(target); } }; add(addLink); addLink.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return isAddVisible(); } }); AjaxLink removeLink = new AjaxLink(ID_REMOVE) { @Override public void onClick(AjaxRequestTarget target) { removePerformed(target); } }; add(removeLink); removeLink.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return isRemoveVisible(); } }); }
From source file:com.evolveum.midpoint.web.component.assignment.AssignmentEditorPanel.java
License:Apache License
private void initPanelLayout() { WebMarkupContainer headerRow = new WebMarkupContainer(ID_HEADER_ROW); headerRow.add(AttributeModifier.append("class", createHeaderClassModel(getModel()))); headerRow.setOutputMarkupId(true);/*from www . ja v a 2 s . com*/ add(headerRow); AjaxCheckBox selected = new AjaxCheckBox(ID_SELECTED, new PropertyModel<Boolean>(getModel(), AssignmentEditorDto.F_SELECTED)) { @Override protected void onUpdate(AjaxRequestTarget target) { //do we want to update something? } }; headerRow.add(selected); WebMarkupContainer typeImage = new WebMarkupContainer(ID_TYPE_IMAGE); typeImage.add(AttributeModifier.replace("class", createImageTypeModel( new PropertyModel<AssignmentEditorDtoType>(getModel(), AssignmentEditorDto.F_TYPE)))); headerRow.add(typeImage); AjaxLink name = new AjaxLink(ID_NAME) { @Override public void onClick(AjaxRequestTarget target) { nameClickPerformed(target); } }; headerRow.add(name); Label nameLabel = new Label(ID_NAME_LABEL, new PropertyModel<String>(getModel(), AssignmentEditorDto.F_NAME)); name.add(nameLabel); Label activation = new Label(ID_ACTIVATION, createActivationModel()); headerRow.add(activation); WebMarkupContainer main = new WebMarkupContainer(ID_MAIN); main.setOutputMarkupId(true); add(main); WebMarkupContainer body = new WebMarkupContainer(ID_BODY); body.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { AssignmentEditorDto editorDto = AssignmentEditorPanel.this.getModel().getObject(); return !editorDto.isMinimized(); } }); main.add(body); initBodyLayout(body); }
From source file:com.evolveum.midpoint.web.component.assignment.AssignmentEditorPanel.java
License:Apache License
private void initBodyLayout(WebMarkupContainer body) { TextArea description = new TextArea(ID_DESCRIPTION, new PropertyModel(getModel(), AssignmentEditorDto.F_DESCRIPTION)); body.add(description);// ww w.ja v a 2 s .c o m TextField relation = new TextField(ID_RELATION, new PropertyModel(getModel(), AssignmentEditorDto.F_RELATION)); relation.setEnabled(false); body.add(relation); WebMarkupContainer activationBlock = new WebMarkupContainer(ID_ACTIVATION_BLOCK); activationBlock.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { //enabled activation in assignments for now. return true; } }); body.add(activationBlock); DropDownChoicePanel administrativeStatus = WebMiscUtil.createActivationStatusPanel(ID_ADMINISTRATIVE_STATUS, new PropertyModel<ActivationStatusType>(getModel(), AssignmentEditorDto.F_ACTIVATION + "." + ActivationType.F_ADMINISTRATIVE_STATUS.getLocalPart()), this); activationBlock.add(administrativeStatus); DateInput validFrom = new DateInput(ID_VALID_FROM, createDateModel(new PropertyModel<XMLGregorianCalendar>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validFrom"))); activationBlock.add(validFrom); DateInput validTo = new DateInput(ID_VALID_TO, createDateModel(new PropertyModel<XMLGregorianCalendar>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validTo"))); activationBlock.add(validTo); WebMarkupContainer targetContainer = new WebMarkupContainer(ID_TARGET_CONTAINER); targetContainer.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { AssignmentEditorDto dto = getModel().getObject(); return !AssignmentEditorDtoType.ACCOUNT_CONSTRUCTION.equals(dto.getType()); } }); body.add(targetContainer); Label target = new Label(ID_TARGET, createTargetModel()); targetContainer.add(target); WebMarkupContainer constructionContainer = new WebMarkupContainer(ID_CONSTRUCTION_CONTAINER); constructionContainer.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { AssignmentEditorDto dto = getModel().getObject(); return AssignmentEditorDtoType.ACCOUNT_CONSTRUCTION.equals(dto.getType()); } }); body.add(constructionContainer); AjaxLink showEmpty = new AjaxLink(ID_SHOW_EMPTY) { @Override public void onClick(AjaxRequestTarget target) { showEmptyPerformed(target); } }; constructionContainer.add(showEmpty); Label showEmptyLabel = new Label(ID_SHOW_EMPTY_LABEL, createShowEmptyLabel()); showEmptyLabel.setOutputMarkupId(true); showEmpty.add(showEmptyLabel); initAttributesLayout(constructionContainer); addAjaxOnUpdateBehavior(body); }
From source file:com.evolveum.midpoint.web.component.assignment.DelegationEditorPanel.java
License:Apache License
@Override protected void initHeaderRow() { PageBase pageBase = getPageBase();//w ww . ja v a2s. co m if (delegatedToMe) { privilegesListModel = new LoadableModel<List<AssignmentInfoDto>>(false) { @Override protected List<AssignmentInfoDto> load() { return DelegationEditorPanel.this.getModelObject().getPrivilegeLimitationList(); } }; } AjaxCheckBox selected = new AjaxCheckBox(ID_SELECTED, new PropertyModel<>(getModel(), AssignmentEditorDto.F_SELECTED)) { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { } }; selected.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return !getModel().getObject().isSimpleView(); } }); headerRow.add(selected); Label arrowIcon = new Label(ID_ARROW_ICON); headerRow.add(arrowIcon); WebMarkupContainer typeImage = new WebMarkupContainer(ID_TYPE_IMAGE); typeImage.add(AttributeModifier.append("class", createImageTypeModel(getModel()))); headerRow.add(typeImage); AjaxLink name = new AjaxLink(ID_NAME) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { nameClickPerformed(target); } }; headerRow.add(name); Label nameLabel; if (delegatedToMe) { OperationResult result = new OperationResult(OPERATION_GET_TARGET_REF_NAME); Task task = pageBase.createSimpleTask(OPERATION_GET_TARGET_REF_NAME); nameLabel = new Label(ID_NAME_LABEL, WebModelServiceUtils .resolveReferenceName(getModelObject().getTargetRef(), pageBase, task, result)); } else { nameLabel = new Label(ID_NAME_LABEL, pageBase.createStringResource("DelegationEditorPanel.meLabel")); } nameLabel.setOutputMarkupId(true); name.add(nameLabel); AssignmentEditorDto dto = getModelObject(); dto.getTargetRef(); WebMarkupContainer delegatedToTypeImage = new WebMarkupContainer(ID_DELEGATED_TO_IMAGE); if (delegatedToMe) { delegatedToTypeImage.add(AttributeModifier.append("class", WebComponentUtil.createDefaultIcon(((PageUser) pageBase).getObjectWrapper().getObject()))); } else { if (getModelObject().getDelegationOwner() != null) { delegatedToTypeImage.add(AttributeModifier.append("class", WebComponentUtil.createDefaultIcon(getModelObject().getDelegationOwner().asPrismObject()))); } } headerRow.add(delegatedToTypeImage); AjaxLink delegatedToName = new AjaxLink(ID_DELEGATED_TO) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { nameClickPerformed(target); } }; headerRow.add(delegatedToName); Label delegatedToNameLabel; if (delegatedToMe) { delegatedToNameLabel = new Label(ID_DELEGATED_TO_LABEL, pageBase.createStringResource("DelegationEditorPanel.meLabel")); } else { delegatedToNameLabel = new Label(ID_DELEGATED_TO_LABEL, getUserDisplayName()); } delegatedToNameLabel.setOutputMarkupId(true); delegatedToName.add(delegatedToNameLabel); ToggleIconButton expandButton = new ToggleIconButton(ID_EXPAND, GuiStyleConstants.CLASS_ICON_EXPAND, GuiStyleConstants.CLASS_ICON_COLLAPSE) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { nameClickPerformed(target); } @Override public boolean isOn() { return !DelegationEditorPanel.this.getModelObject().isMinimized(); } }; headerRow.add(expandButton); }
From source file:com.evolveum.midpoint.web.component.assignment.MultipleAssignmentSelector.java
License:Apache License
private void initLayout(PageBase pageBase) { setOutputMarkupId(true);//from ww w . ja v a2 s . co m WebMarkupContainer filterButtonContainer = new WebMarkupContainer(ID_FILTER_BUTTON_CONTAINER); AjaxLink<String> filterByUserButton = new AjaxLink<String>(ID_FILTER_BY_USER_BUTTON) { @Override public void onClick(AjaxRequestTarget target) { if (showDialog) { labelValue = createStringResource("MultipleAssignmentSelector.filterByUser").getString(); initUserDialog(createStringResource("MultipleAssignmentSelector.filterByUser"), target); } showDialog = true; } }; filterButtonContainer.add(filterByUserButton); labelValue = pageBase.createStringResource("MultipleAssignmentSelector.filterByUser").getString(); Label label = new Label(ID_LABEL, createLabelModel()); label.setRenderBodyOnly(true); filterByUserButton.add(label); AjaxLink deleteButton = new AjaxLink(ID_DELETE_BUTTON) { @Override public void onClick(AjaxRequestTarget target) { labelValue = createStringResource("MultipleAssignmentSelector.filterByUser").getString(); showDialog = false; deleteFilterPerformed(target); } }; filterByUserButton.add(deleteButton); add(filterButtonContainer); initSearchPanel(); add(initTablePanel()); }
From source file:com.evolveum.midpoint.web.component.assignment.MultipleAssignmentSelectorPanel.java
License:Apache License
private void initLayout(Class<H> targetFocusClass, PageBase page) { IModel<List<AssignmentEditorDto>> availableAssignmentModel = createAvailableAssignmentModel(); final MultipleAssignmentSelector availableAssignmentsPanel = new MultipleAssignmentSelector<F, H>( ID_AVAILABLE_ASSIGNMENTS, availableAssignmentModel, targetFocusClass, type, focus, getFilterModel(true), page); final MultipleAssignmentSelector currentAssignmentsPanel = new MultipleAssignmentSelector<F, H>( ID_CURRENT_ASSIGNMENTS, assignmentsModel, targetFocusClass, type, null, getFilterModel(true), page) {/*from w w w. j a va 2 s .co m*/ @Override protected List<AssignmentEditorDto> getListProviderDataList() { return assignmentsModel.getObject(); } }; currentAssignmentsPanel.setFilterButtonVisibility(false); AjaxButton add = new AjaxButton(ID_BUTTON_ADD) { @Override protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form form) { addToAssignmentsModel(target, availableAssignmentsPanel, currentAssignmentsPanel); } }; AjaxButton remove = new AjaxButton(ID_BUTTON_REMOVE) { @Override protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form form) { deleteFromAssignmentsModel(target, currentAssignmentsPanel, availableAssignmentsPanel); } }; remove.add(new VisibleEnableBehaviour() { @Override public boolean isEnabled() { return WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_UNASSIGN_ACTION_URL); } }); AjaxLink<String> buttonReset = new AjaxLink<String>(ID_BUTTON_RESET) { @Override public void onClick(AjaxRequestTarget target) { reset(currentAssignmentsPanel); target.add(currentAssignmentsPanel); } }; buttonReset.setBody(createStringResource("MultipleAssignmentSelector.reset")); Form<?> form = new Form<Void>(ID_FORM); form.add(createTenantContainer()); form.add(createOrgContainer()); form.add(availableAssignmentsPanel); form.add(currentAssignmentsPanel); form.add(buttonReset); form.add(add); form.add(remove); add(form); }
From source file:com.evolveum.midpoint.web.component.assignment.RoleCatalogItemButton.java
License:Apache License
private void initLayout() { setOutputMarkupId(true);/*from www . java 2 s . c o m*/ WebMarkupContainer itemButtonContainer = new WebMarkupContainer(ID_ITEM_BUTTON_CONTAINER); itemButtonContainer.setOutputMarkupId(true); itemButtonContainer.add(new AttributeAppender("class", getBackgroundClass(getModelObject()))); add(itemButtonContainer); AjaxLink inner = new AjaxLink(ID_INNER) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget ajaxRequestTarget) { targetObjectDetailsPerformed(RoleCatalogItemButton.this.getModelObject(), ajaxRequestTarget); } }; inner.add(new VisibleEnableBehaviour() { private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { return isMultiUserRequest() || canAssign(RoleCatalogItemButton.this.getModelObject()); } }); inner.add(new AttributeAppender("title", getModelObject().getName())); itemButtonContainer.add(inner); Label nameLabel = new Label(ID_INNER_LABEL, getModelObject().getName()); inner.add(nameLabel); Label descriptionLabel = new Label(ID_INNER_DESCRIPTION, getModelObject().getTargetRef() != null ? getModelObject().getTargetRef().getDescription() : ""); descriptionLabel.setOutputMarkupId(true); inner.add(descriptionLabel); AjaxLink detailsLink = new AjaxLink(ID_DETAILS_LINK) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget ajaxRequestTarget) { assignmentDetailsPerformed(RoleCatalogItemButton.this.getModelObject(), ajaxRequestTarget); } }; detailsLink.add(getFooterLinksEnableBehaviour()); detailsLink.add(AttributeAppender.append("title", AssignmentsUtil.getShoppingCartAssignmentsLimitReachedTitleModel(getPageBase()))); detailsLink.add(AttributeAppender.append("class", new LoadableModel<String>() { @Override protected String load() { return detailsLink.isEnabled() ? "shopping-cart-item-button-details" : "shopping-cart-item-button-details-disabled"; } })); itemButtonContainer.add(detailsLink); Label detailsLinkLabel = new Label(ID_DETAILS_LINK_LABEL, createStringResource("MultiButtonPanel.detailsLink")); detailsLinkLabel.setRenderBodyOnly(true); detailsLink.add(detailsLinkLabel); AjaxLink detailsLinkIcon = new AjaxLink(ID_DETAILS_LINK_ICON) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { } }; detailsLinkIcon.add(getFooterLinksEnableBehaviour()); detailsLink.add(detailsLinkIcon); AjaxLink addToCartLink = new AjaxLink(ID_ADD_TO_CART_LINK) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget ajaxRequestTarget) { addAssignmentPerformed(RoleCatalogItemButton.this.getModelObject(), ajaxRequestTarget); } }; addToCartLink.add(getFooterLinksEnableBehaviour()); addToCartLink.add(AttributeAppender.append("title", AssignmentsUtil.getShoppingCartAssignmentsLimitReachedTitleModel(getPageBase()))); addToCartLink.add(AttributeAppender.append("class", new LoadableModel<String>() { @Override protected String load() { return addToCartLink.isEnabled() ? "shopping-cart-item-button-add" : "shopping-cart-item-button-add-disabled"; } })); itemButtonContainer.add(addToCartLink); AjaxLink addToCartLinkIcon = new AjaxLink(ID_ADD_TO_CART_LINK_ICON) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { } }; addToCartLinkIcon.add(getFooterLinksEnableBehaviour()); addToCartLink.add(addToCartLinkIcon); WebMarkupContainer icon = new WebMarkupContainer(ID_TYPE_ICON); icon.add(new AttributeAppender("class", WebComponentUtil.createDefaultBlackIcon(getModelObject().getType().getQname()))); itemButtonContainer.add(icon); WebMarkupContainer alreadyAssignedIcon = new WebMarkupContainer(ID_ALREADY_ASSIGNED_ICON); alreadyAssignedIcon.add(new AttributeAppender("title", getAlreadyAssignedIconTitleModel(getModelObject()))); alreadyAssignedIcon.add(new VisibleEnableBehaviour() { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return !isMultiUserRequest() && getModelObject().isAlreadyAssigned(); } }); itemButtonContainer.add(alreadyAssignedIcon); }
From source file:com.evolveum.midpoint.web.component.assignment.SimpleParametricRoleSelector.java
License:Apache License
private void initLayout() { IModel<String> labelParamModel = new IModel<String>() { @Override/*from ww w. ja va2s . c o m*/ public void detach() { } @Override public String getObject() { return getLabelParam(); } @Override public void setObject(String object) { } }; add(new Label(ID_LABEL_PARAM, labelParamModel) { @Override protected void onConfigure() { setVisible(getLabelParam() != null); super.onConfigure(); } }); IModel<String> labelRoleModel = new IModel<String>() { @Override public void detach() { } @Override public String getObject() { return getLabelRole(); } @Override public void setObject(String object) { } }; add(new Label(ID_LABEL_ROLE, labelRoleModel) { @Override protected void onConfigure() { setVisible(getLabelRole() != null); super.onConfigure(); } }); paramList = new ListView<String>(ID_LIST_PARAM, paramListModel) { @Override protected void populateItem(ListItem<String> item) { item.add(createParamLink(ID_ITEM_PARAM, item.getModel())); } }; paramList.setOutputMarkupId(true); add(paramList); final Model<String> addInputModel = new Model<String>(); TextField<String> addInput = new TextField<>(ID_ADD_INPUT, addInputModel); addInput.setOutputMarkupId(true); addInput.add(new AjaxFormComponentUpdatingBehavior("blur") { @Override protected void onUpdate(AjaxRequestTarget target) { // nothing to do, Ajax behavior is there only to get data to model } }); add(addInput); AjaxLink<String> addLink = new AjaxLink<String>(ID_ADD_LINK) { @Override public void onClick(AjaxRequestTarget target) { String newParam = addInputModel.getObject(); LOGGER.debug("ADD cliked, input field value: {}", newParam); if (!StringUtils.isBlank(newParam)) { addParam(newParam); } addInputModel.setObject(null); target.add(SimpleParametricRoleSelector.this); } }; add(addLink); AjaxLink<String> deleteLink = new AjaxLink<String>(ID_DELETE_LINK) { @Override public void onClick(AjaxRequestTarget target) { LOGGER.debug("DELETE cliked, selected param: {}", selectedParam); deleteParam(selectedParam); target.add(SimpleParametricRoleSelector.this); } }; add(deleteLink); }
From source file:com.evolveum.midpoint.web.component.assignment.SimpleRoleSelector.java
License:Apache License
private void initLayout() { setOutputMarkupId(true);/*from w w w . j ava2 s . c om*/ ListView<PrismObject<R>> list = new ListView<PrismObject<R>>(ID_LIST, availableRoles) { @Override protected void populateItem(ListItem<PrismObject<R>> item) { item.add(createRoleLink(ID_ITEM, item.getModel())); } }; list.setOutputMarkupId(true); add(list); AjaxLink<String> buttonReset = new AjaxLink<String>(ID_BUTTON_RESET) { @Override public void onClick(AjaxRequestTarget target) { reset(); target.add(SimpleRoleSelector.this); } }; buttonReset.setBody(createStringResource("SimpleRoleSelector.reset")); add(buttonReset); }